-
Notifications
You must be signed in to change notification settings - Fork 0
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
chore: initialize pytest and create workflow #155
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! We just need to make sure we run pytest in the proper virtual environment, with our poetry
setup
.github/workflows/pytest.yaml
Outdated
branches: [main, develop, 73-initialize-pytest] | ||
pull_request: | ||
branches: [main, develop, 73-initialize-pytest] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can remove your branch now
branches: [main, develop, 73-initialize-pytest] | |
pull_request: | |
branches: [main, develop, 73-initialize-pytest] | |
branches: [main, develop] | |
pull_request: | |
branches: [main, develop] | |
Since we have the pull_request
here, you don't need to explicitely have your branch name in here, you can just open a Draft PR in github and it'll run the actions for you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, I keep forgetting this. Thanks Pierre!
requirements.txt
Outdated
@@ -1,2 +1,3 @@ | |||
pre-commit==2.19.0 | |||
gitlint==0.19.1 | |||
pytest==8.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think pytest should be added as a dependency for the whole app (we use this top-level requirements file for pre-commit).
pytest is already installed as a dev dependency in /server/pyproject.toml
.github/workflows/pytest.yaml
Outdated
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Test with pytest | ||
run: | | ||
pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will install the top-level python dependencies, which are separate from our poetry venv and Django app.
You can look at the registration action that runs poetry pytest
in the /server/
folder:
.github/workflows/pytest.yaml
Outdated
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This job could greately benefit from caching to avoid reinstalling all dependencies every run
Issue: https://github.com/orgs/bcgov/projects/123/views/2?pane=issue&itemId=49861478
Initializing pytest with a sample test, creating the workflow, and updating the readme with instructions.
To test manually:
In the terminal navigate to the
/server/
directoryDo the command
pytest
You should get a message like "[100%] 1 passed in 0.00s"
To test the workflow, it should appear as one of the tests that is automatically run when this PR is created.