-
Notifications
You must be signed in to change notification settings - Fork 9
ci: add tests-on-pr workflow file that doesn't upload to codecov #178
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
243a316
ci: add tests-on-pr workflow file that doesn't upload to codecov
zmx27 03e579c
chore: add news file
zmx27 cfe3751
refactor: create chained workflow calls for tests-on-pr
zmx27 e29b9c7
chore: update news file
zmx27 0d8b438
chore: change the syntax to call reusable workflow files
zmx27 c1f5a4b
chore: revert to previous workflow version without the chained workfl…
zmx27 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| name: Tests on PR | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| project: | ||
| description: 'Name of the project to test' | ||
| default: 'PROJECT_NAME' | ||
| required: false | ||
| type: string | ||
| python_version: | ||
| description: 'Python version for Conda environment' | ||
| default: 3.13 | ||
| required: false | ||
| type: number | ||
| c_extension: | ||
| description: 'Whether the project has a C extension' | ||
| default: false | ||
| required: false | ||
| type: boolean | ||
| headless: | ||
| description: 'Whether to run headless tests' | ||
| default: false | ||
| required: false | ||
| type: boolean | ||
| run: | ||
| description: 'Extra CLI commands to run after installing the project' | ||
| default: 'echo "No extra commands"' | ||
| required: false | ||
| type: string | ||
|
|
||
| jobs: | ||
| validate: | ||
| defaults: | ||
| run: | ||
| shell: bash -l {0} | ||
|
|
||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out ${{ inputs.project }} | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Initialize miniconda | ||
| uses: conda-incubator/setup-miniconda@v3 | ||
| with: | ||
| activate-environment: test | ||
| channels: conda-forge | ||
| auto-update-conda: true | ||
| auto-activate-base: false | ||
| python-version: ${{ inputs.python_version }} | ||
|
|
||
| - name: Conda config | ||
| run: >- | ||
| conda config --set always_yes yes | ||
| --set changeps1 no | ||
|
|
||
| - name: Install ${{ inputs.project }} and requirements | ||
| run: | | ||
| conda install --file requirements/conda.txt | ||
| conda install --file requirements/tests.txt | ||
| if ${{ inputs.c_extension }}; then | ||
| conda install --file requirements/build.txt | ||
| fi | ||
| python -m pip install . --no-deps | ||
|
|
||
| - name: Run extra user-defined CLI commands | ||
| run: | | ||
| echo "${{ inputs.run }}" > user-commands.sh | ||
| bash user-commands.sh | ||
|
|
||
| - name: Start Xvfb | ||
| if: ${{ inputs.headless }} | ||
| run: | | ||
| sudo apt-get install -y xvfb | ||
| export DISPLAY=:99 | ||
| Xvfb :99 -screen 0 1024x768x16 & | ||
|
|
||
| - name: Validate ${{ inputs.project }} | ||
| run: | | ||
| if ${{ inputs.headless }}; then | ||
| export DISPLAY=:99 | ||
| fi | ||
| pytest --cov | ||
| coverage report -m | ||
| codecov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Upload to Codecov | ||
|
|
||
| on: | ||
| workflow_call: | ||
| secrets: | ||
| CODECOV_TOKEN: | ||
| description: 'Codecov token' | ||
| required: true | ||
|
|
||
| jobs: | ||
| upload: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Upload to Codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| verbose: true | ||
| fail_ci_if_error: true | ||
| token: ${{ secrets.CODECOV_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| **Added:** | ||
|
|
||
| * Add tests-on-pr workflow file that doesn't upload to codecov for private repos | ||
|
|
||
| **Changed:** | ||
|
|
||
| * Create chained workflows for tests-on-pr.yml that calls tests-on-r-no-codecov.yml and upload-to-codecov.yml | ||
|
|
||
| **Deprecated:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Removed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Fixed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Security:** | ||
|
|
||
| * <news item> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
these need an
@v0at the end of the line.please crosscheck carefully with other workflows using this construction in this repo for any other details. I am not sure how the pass-through of
inputs.<whatever>work as it is not clear to me how these workflows pass this info throughThere 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.
From what I understand from the GitHub Docs, the
withkeyword will pass in the inputs to the called reusable workflow. Here's how I thought about it: in our case, we'd be calling_tests-on-pr.ymlfrom another repo with certain inputsproject,headless, etc, and these are going to be stored asinputs.<whatever>inside_tests-on-pr.yml. These values (and secret tokens in the next codecov section) then gets passed as the inputs to the next reusable workflow (_tests-on-pr-no-codecov.ymland_upload-to-codecov.yml) where it is then used to run all the jobs stated there. Feel free to correct me if I'm wrong about any of this!