Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP | Dev: Initial bit integration #1029

Closed

Conversation

mtreacy002
Copy link
Member

@mtreacy002 mtreacy002 commented Mar 3, 2021

Description

Add initial integration for BIT backend to MS backend

Fixes #1028

Type of Change:

  • Code
  • Quality Assurance

Code/Quality Assurance Only

  • This change requires a documentation update (software upgrade on readme file)
  • New feature (non-breaking change which adds functionality pre-approved by mentors)

How Has This Been Tested?

  1. Complete the local development setup as instructed on BIT wiki page. For ms-backend-server bit version, run it from this PR branch.
  2. run BIT backend server FIRST to create the schemas inside postgresql. then run MS backend server from this PR branch.
  3. Register a user and see success message.

Screen Shot 2021-03-03 at 5 39 20 pm

4. run tests by executing the command `python -m unittest discover tests` and see all test run successfully

Screen Shot 2021-03-03 at 5 49 24 pm

  1. Login on BIT Swagger UI and make call requests related to MS users service (on gif below GET user/personal_details and GET users/{user_id} were made as examples)
    ezgif com-gif-maker (36)

Checklist:

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials
  • I have commented my code or provided relevant documentation, particularly in hard-to-understand areas
  • Any dependent changes have been merged
  • Update requirements.txt

Code/Quality Assurance Only

  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Additional note
For the giithub action to run test successfully, the main.yml need to be modified to include adding postgresql plugin and creating test database with the 2 schemas as it was done on Travis.yml on BIT backend repository.
Screen Shot 2021-03-03 at 5 55 38 pm

@mtreacy002 mtreacy002 requested a review from isabelcosta March 3, 2021 06:42
@mtreacy002 mtreacy002 force-pushed the initial-bit-integration branch from 8988f98 to f66749b Compare March 3, 2021 07:02
@mtreacy002 mtreacy002 changed the title Initial bit integration Dev: Initial bit integration Mar 3, 2021
@mtreacy002 mtreacy002 force-pushed the initial-bit-integration branch from f66749b to fe7a5f3 Compare March 3, 2021 07:22
config.py Show resolved Hide resolved
config.py Outdated
db_user_arg=os.getenv("DB_USERNAME"),
db_password_arg=os.getenv("DB_PASSWORD"),
db_endpoint_arg=os.getenv("DB_ENDPOINT"),
db_name_arg=os.getenv("DB_NAME"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then why not use the DB_NAME variable instead of refetching them from the environment variables?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm following, 🤔.

This was a continuation from the above comment. On line 44 there is a variable called DB_NAME that has this value, then why not use that here instead of fetching the environment variable again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing it now. Thanks for pointing that out 😊

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epicadk , done. Can you please check again? Thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 💯

@@ -16,6 +19,8 @@ def create_app(config_filename: str) -> Flask:

migrate = Migrate(app, db)

cors.init_app(app, resources={r"*": {"origins": "http:localhost:5000"}})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does BIT required access to all endpoints of the mentorship backend or can we give access to specific endpoints instead of all the endpoints?

Copy link
Member Author

@mtreacy002 mtreacy002 Mar 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @epicadk. With users functionaliities and mentorship relation are managed by Mentorship System, BIT does need to have access to all Mentoship System api endpoints 😉.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should fetch the origins property based on the build type i.e. production, dev, local etc.?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epicadk, I think it's best to keep it as it for now, coz majority of contributors work on local machine atm. When we have remote servers for dev and production, we can revisit this origin property.

@mtreacy002 mtreacy002 force-pushed the initial-bit-integration branch 6 times, most recently from 6bdac97 to c0c7e58 Compare March 3, 2021 13:38
@mtreacy002
Copy link
Member Author

mtreacy002 commented Mar 3, 2021

@epicadk and @annabauza . I'm trying to set up postgresql inside github action but having trouble getting it right.
Screen Shot 2021-03-04 at 12 42 22 am

Here's the modification to main.yml i've done.
From the PR description above (Additional Content) you can see how I've done it using Travis CI
PS: I've never written CI/CD to github action before so, any help would be appreciated.

@epicadk
Copy link
Member

epicadk commented Mar 3, 2021

It won't let you create a database for some reason it is setup just fine. Is there anyone to set these from the python code?

@mtreacy002
Copy link
Member Author

It won't let you create a database for some reason it is setup just fine. Is there anyone to set these from the python code?

can you explain what you mean by setting up on the python code, @epicadk ?

@epicadk
Copy link
Member

epicadk commented Mar 4, 2021

It won't let you create a database for some reason it is setup just fine. Is there anyone to set these from the python code?

can you explain what you mean by setting up on the python code, @epicadk ?

Like we do for the mentorship system db.create_all() over here

@mtreacy002 mtreacy002 force-pushed the initial-bit-integration branch 3 times, most recently from 56a531f to ee9f17c Compare March 4, 2021 07:09
@mtreacy002
Copy link
Member Author

It won't let you create a database for some reason it is setup just fine. Is there anyone to set these from the python code?

can you explain what you mean by setting up on the python code, @epicadk ?

Like we do for the mentorship system db.create_all() over here

I've done that, @epicadk , but still facing error 😓

@mtreacy002 mtreacy002 force-pushed the initial-bit-integration branch 8 times, most recently from 9c868ff to 6ee8b47 Compare March 4, 2021 13:00
@mtreacy002
Copy link
Member Author

mtreacy002 commented Mar 4, 2021

Update @epicadk :
I'm now able to create test db and connect to Postgres in the build 🎉 💃
But now I'm stuck with install dependencies as shown below. Any idea why this happens? Does this have something to do with permission level to the Mentorship System GitHub repo? cc @isabelcosta
Screen Shot 2021-03-05 at 12 02 34 am

I also noticed that when the PR #654 for initial MS migration to GitHub action was merged, the Run test workflow did not get triggered. It was only triggered on the PR after (#655). I wonder why 🤔...
Screen Shot 2021-03-05 at 12 24 02 am

@mtreacy002 mtreacy002 force-pushed the initial-bit-integration branch from 6ee8b47 to 8a78c49 Compare March 4, 2021 13:07
@epicadk
Copy link
Member

epicadk commented Mar 13, 2021

@mtreacy002 could you avoid force pushing the changes? Kinda makes it harder to review. I had discussed this with @isabelcosta in the QA open session and I think the conclusion was that only while merging the maintainer needs to follow the commit guidelines given in the contributing guidelines. cc @isabelcosta . 😅

@mtreacy002
Copy link
Member Author

@mtreacy002 could you avoid force pushing the changes? Kinda makes it harder to review. I had discussed this with @isabelcosta in the QA open session and I think the conclusion was that only while merging the maintainer needs to follow the commit guidelines given in the contributing guidelines. cc @isabelcosta . 😅

Ok, it makes sense actually 😁. It's just a habit from squashing commits, I guess (which I actually forgot to do on the latest push 🤣). Will just do normal push the next one 😉

@mtreacy002
Copy link
Member Author

mtreacy002 commented Mar 13, 2021

Oh, on the codecov report, I check the anitab codecov.io, and it looks like it's passing, so I'm not sure why it says failed here 🤔
Screen Shot 2021-03-14 at 12 38 22 am

@epicadk
Copy link
Member

epicadk commented Mar 13, 2021

I don't have much knowledge of the subject 😅. I think @devkapilbansal can help out here.

@mtreacy002
Copy link
Member Author

mtreacy002 commented Mar 13, 2021

I don't have much knowledge of the subject 😅. I think @devkapilbansal can help out here.

no worries..., @epicadk 😉. @devkapilbansal can you please share some input 🙏.

@mtreacy002 mtreacy002 added the Help Wanted Extra attention is needed. label Mar 13, 2021
Copy link
Member

@devkapilbansal devkapilbansal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtreacy002 this PR consists of 5 commits but only one is relevant. All four are possibly because bit branch is not updated with develop branch.
So they should be removed.
Otherwise it is good for me.

replace db uri

add Flask-Cors to requirements.txt

linting with black formatter

remove fetch env variables duplication

change pull-push branch for github action to bit branch

add postgresql test db

add shell_context_processor

Add -h postgres to psql command

Place PGPASSWORD at the start of psql command

Add env for running test

* Update main.yml (Patch #21)

Co-authored-by: Aditya Kurkure

use non-macOS syntax for db_uri and add db envs

Add postgres db url for github action

Add test for db_test_uri

remove hard coded test db uri

Add psycopg2

Fix db type to postgres+psycopg2

add env to Generate coverage report

move env to global runner

focus pytest cov on tests folder

Remove print command
@mtreacy002 mtreacy002 force-pushed the initial-bit-integration branch from 3ab6260 to 928bbe5 Compare March 13, 2021 21:34
@mtreacy002
Copy link
Member Author

@mtreacy002 this PR consists of 5 commits but only one is relevant. All four are possibly because bit branch is not updated with develop branch.
So they should be removed.
Otherwise it is good for me.

Done, @devkapilbansal , I removed the other 4 commits. It was initially to update bit branch with develop. But the maintainers can do that from their side too 😉

@mtreacy002
Copy link
Member Author

@epicadk , should I also integrate your push for docker change in here? Or that can be done after?

@epicadk
Copy link
Member

epicadk commented Mar 14, 2021

@epicadk , should I also integrate your push for docker change in here? Or that can be done after?

It can be done after. I'll send open the pr on this repository.

@mtreacy002
Copy link
Member Author

@devkapilbansal and @epicadk , can you please re-approve this PR now so it can be merged? That way the contributors can push directly to upstream bit branch instead of to my fork ms repo. Thanks again 😉

Copy link
Member

@epicadk epicadk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Member

@isabelcosta isabelcosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! @mtreacy002 🤗

@isabelcosta
Copy link
Member

@mtreacy002 this is working for your specific case right? Should we test this again? or pass that, because you were already using this for BIT?

Copy link
Member

@devkapilbansal devkapilbansal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

P.S.:- I haven't tested it

@devkapilbansal
Copy link
Member

devkapilbansal commented Mar 14, 2021

@epicadk, can you please tell me how to fix the failed codecov? Also, why is the codecov report is not showing for this PR just like it is shown on the other PR for develop branch (e.g. #1039)?

@mtreacy002 @epicadk looking into the codecov reports, it fails because of changes in run.py file. Also, in workflows, branches mentioned is develop. That's why codecov report is not shown here

@mtreacy002
Copy link
Member Author

mtreacy002 commented Mar 15, 2021

@mtreacy002 this is working for your specific case right? Should we test this again? or pass that, because you were already using this for BIT?

@isabelcosta , I believe since the GitHub action shows that the build is passing here we won't need to do the manual testing again. I also have been using this branch for my BIT for MS backend server and able to use existing features as normal.
PS: I've added a gif on successful calls to MS users REST API from BIT Swagger UI using this PR branch under How has this been tested section.

@epicadk, can you please tell me how to fix the failed codecov? Also, why is the codecov report is not showing for this PR just like it is shown on the other PR for develop branch (e.g. #1039)?

@mtreacy002 @epicadk looking into the codecov reports, it fails because of changes in run.py file. Also, in workflows, branches mentioned is develop. That's why codecov report is not shown here

@devkapilbansal, can you tell me where the develop branches being mentioned in workflows that causing the codecov fails? as I've changed this to bit in the main.yml on this pr.
Screen Shot 2021-03-15 at 12 17 18 pm

Are you talking on the codecov.io settings of AnitaB? Perhaps this must be done from the admins side since they have the authority on that?

@mtreacy002
Copy link
Member Author

@devkapilbansal , @epicadk , can you please let me know what else I need to do for this PR? If nothing else needed, we can label this issue Ready to merge so the maintainer can merge it to the MS bit branch.

@epicadk
Copy link
Member

epicadk commented Mar 18, 2021

@devkapilbansal , @epicadk , can you please let me know what else I need to do for this PR? If nothing else needed, we can label this issue Ready to merge so the maintainer can merge it to the MS bit branch.

We have code approval . Now it needs testing . Busy with college this week i'll test it tonight.

@epicadk epicadk added Status: Needs Testing Work has been reviewed and needs the code tested by the quality assurance team. and removed Status: Needs Review PR needs an additional review or a maintainer's review. labels Mar 18, 2021
@epicadk
Copy link
Member

epicadk commented Mar 18, 2021

Okay I just realized I'll need to have postgreSQL installed to test this which I haven't installed yet.

@mtreacy002 mtreacy002 mentioned this pull request Mar 24, 2021
4 tasks
@mtreacy002 mtreacy002 added the Status: On Hold Issue or PR needs more info, a discussion, a review or approval from a Maintainer/Code Owner. label Apr 11, 2021
@mtreacy002 mtreacy002 changed the title Dev: Initial bit integration WIP | Dev: Initial bit integration Apr 11, 2021
@mtreacy002
Copy link
Member Author

Will close this issue as we're moving to full BIT-MS integration as discussed on BIT Open Session Sunday, 11th April.

@mtreacy002 mtreacy002 closed this Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BIT This labels issues that need to be completed to help BIT Category: Coding Changes to code base or refactored code that doesn't fix a bug. Help Wanted Extra attention is needed. Status: Needs Testing Work has been reviewed and needs the code tested by the quality assurance team. Status: On Hold Issue or PR needs more info, a discussion, a review or approval from a Maintainer/Code Owner. Type: Maintenance Repository maintenance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants