-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add pytest in GitHub Actions #9
Conversation
Add pytest with conda Allow workflow to run on pytest branch Fix script location Fix conda environment sourcing Add conda version script Add conda init Test setup miniconda Add conda creation Test Fix conda environment name Add execute permissions Fix pytest command Activate emcommon Fix footprint calculations Attempt to fix footprint test Attempt to fix footprint test Add MODE for footprint test Reset test footprint Sync with Jack
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.
Thanks for the contribution. This has been on my todo list.
I think this can be significantly simplified and expanded to include the Javascript tests as well
bin/run_pytest.sh
Outdated
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.
there's no diff here so I'm guessing you just made it executable, which is good
.github/workflows/pytest.yml
Outdated
on: | ||
push: | ||
branches: | ||
- master | ||
- pytest | ||
- gis-based-mode-detection | ||
pull_request: | ||
branches: | ||
- master | ||
- pytest | ||
- gis-based-mode-detection | ||
schedule: | ||
# * is a special character in YAML so you have to quote this string | ||
- cron: '5 4 * * 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.
It can run on any push or PR to master. Don't need the other branches and don't need a schedule
.github/workflows/pytest.yml
Outdated
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: |
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.
Ultimately I'd like to have 2 jobs that run in parallel, one for pytest
and one for jest
. Maybe this workflow can be named more generally
.github/workflows/pytest.yml
Outdated
- uses: actions/checkout@v2 | ||
|
||
- name: Install and start MongoDB | ||
uses: supercharge/[email protected] | ||
with: | ||
mongodb-version: 4.4.0 | ||
|
||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
miniconda-version: "latest" | ||
channels: bioconda, conda-forge, defaults | ||
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! | ||
auto-update-conda: true | ||
auto-activate-base: true | ||
|
||
- name: Check existing version of miniconda | ||
shell: bash -l {0} | ||
run: conda info -a | ||
|
||
- name: Install emcommon conda environment | ||
shell: bash -l {0} | ||
run: | | ||
# echo Test | ||
conda env update -n emcommon -f bin/environment.yml | ||
|
||
- name: Show current conda environment | ||
shell: bash -l {0} | ||
run: | | ||
conda activate emcommon && conda info --envs | ||
|
||
- name: Switch to emcommon and run the tests | ||
shell: bash -l {0} | ||
run: | | ||
conda activate emcommon | ||
PYTHONPATH=./src pytest test --asyncio-mode=auto |
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 all of this is needed because setup.sh
handles setting up the conda environment.
Can it just run setup.sh
followed by run_pytest.sh
?
I have implemented all of the above. Thank you for your feedback. |
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 apologize for this late feedback; I wrote these comments weeks ago but had left them "pending" so they were not visible yet.
README.md
Outdated
Anaconda is required. | ||
|
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.
It should not be necessary to install Anaconda manually, since the setup script automatically downloads miniconda and uses that.
Does this differ from what you've experienced?
README.md
Outdated
@@ -21,7 +23,7 @@ Re-run this if you change the dependencies in `environment.yml` or `package.json | |||
## To contribute | |||
|
|||
1. Make your changes to Python code under the `src` directory. | |||
1. Run `bash bin/compile_to_js.sh` to build the JavaScript. This will produce output JS files in the `emcommon_js` directory. | |||
1. Run `bash bin/compile_to_js.sh` to build the JavaScript. This will produce output JS files in the `emcommon_js` directory. However, `pip install transcrypt` is required. |
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.
The setup script should automatically install transcrypt
to the emcommon
conda environment, so pip install transcrypt
should not be necessary either
export_versions.sh is in the 'setup' folder of e-mission-server and will be downloaded dynamically via bin/setup.sh; does not need to be duplicated here We do not need babel to run the jest tests because Transcrypt outputs jest-compliant JS
This reverts commit a9fdffd.
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.
Since I was so late with giving feedback and we want to unblock #10, I went ahead and made the changes I was looking for to the workflow.
Next I will squash merge to keep the commit history clean.
This change adds an automated pytest using the conda environment.
The workflow is inspired from the one in e-mission-server: https://github.com/e-mission/e-mission-server/blob/master/.github/workflows/test-with-manual-install.yml