-
Notifications
You must be signed in to change notification settings - Fork 214
Add GHA to update template nf-test snapshots #3723
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
093a173
add GHA to update template nf-test snapshots
mirpedrol 40313ba
[automated] Update CHANGELOG.md
nf-core-bot 3201d00
Merge branch 'dev' into update-template-snapshots
mirpedrol ef628f3
update gha triggers for snapshot updates
mirpedrol 9e03edc
update changelog
mirpedrol 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,160 @@ | ||
name: Update Template snapshots from a comment | ||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
prepare-matrix: | ||
name: Retrieve all template features | ||
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords | ||
if: > | ||
contains(github.event.comment.html_url, '/pull/') && | ||
contains(github.event.comment.body, '@nf-core-bot') && | ||
contains(github.event.comment.body, 'update template snapshots') && | ||
github.repository == 'nf-core/tools' | ||
runs-on: ubuntu-latest | ||
outputs: | ||
all_features: ${{ steps.create_matrix.outputs.matrix }} | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | ||
- name: Create Matrix | ||
id: create_matrix | ||
run: | | ||
echo "matrix=$(yq '.[].features | keys | filter(. != "github") | filter(. != "is_nfcore") | filter(. != "test_config")' nf_core/pipelines/create/template_features.yml | \ | ||
yq 'flatten | tojson(0)' -)" >> $GITHUB_OUTPUT | ||
update-snapshots: | ||
needs: [prepare-matrix] | ||
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords | ||
if: > | ||
contains(github.event.comment.html_url, '/pull/') && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
contains(github.event.comment.body, '@nf-core-bot') && | ||
contains(github.event.comment.body, 'update template snapshots') && | ||
github.repository == 'nf-core/tools' | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
TEMPLATE: ${{ fromJson(needs.prepare-matrix.outputs.all_features) }} | ||
include: | ||
- TEMPLATE: all | ||
fail-fast: false | ||
steps: | ||
# Use the @nf-core-bot token to check out so we can push later | ||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | ||
with: | ||
token: ${{ secrets.nf_core_bot_auth_token }} | ||
|
||
# indication that the command is running | ||
- name: React on comment | ||
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 | ||
with: | ||
comment-id: ${{ github.event.comment.id }} | ||
reactions: eyes | ||
|
||
# Action runs on the issue comment, so we don't get the PR by default | ||
# Use the gh cli to check out the PR | ||
- name: Checkout Pull Request | ||
run: gh pr checkout ${{ github.event.issue.number }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }} | ||
|
||
# Install dependencies and run pytest | ||
- name: Set up Python | ||
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | ||
with: | ||
python-version: "3.13" | ||
cache: "pip" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip -r requirements-dev.txt | ||
pip install -e . | ||
# Create template files | ||
- name: Create template skip ${{ matrix.TEMPLATE }} | ||
run: | | ||
mkdir create-test-lint-wf | ||
export NXF_WORK=$(pwd) | ||
if [ ${{ matrix.TEMPLATE }} == "all" ] | ||
then | ||
printf "org: my-prefix\nskip_features: ${{ needs.prepare-matrix.outputs.all_features }}" > create-test-lint-wf/template_skip_all.yml | ||
else | ||
printf "org: my-prefix\nskip_features: [${{ matrix.TEMPLATE }}]" > create-test-lint-wf/template_skip_${{ matrix.TEMPLATE }}.yml | ||
fi | ||
# Create a pipeline from the template | ||
- name: create a pipeline from the template ${{ matrix.TEMPLATE }} | ||
run: | | ||
cd create-test-lint-wf | ||
nf-core --log-file log.txt pipelines create -n testpipeline -d "This pipeline is for testing" -a "Testing McTestface" --template-yaml template_skip_${{ matrix.TEMPLATE }}.yml | ||
# Copy snapshot file | ||
- name: copy snapshot file | ||
if: ${{ matrix.TEMPLATE != 'all' && matrix.TEMPLATE != 'nf-test' }} | ||
run: | | ||
if [ ! -f ${{ github.workspace }}/.github/snapshots/${{ matrix.TEMPLATE }}.nf.test.snap ]; then | ||
echo "Generate a snapshot when creating a pipeline and skipping the feature ${{ matrix.TEMPLATE }}." | ||
echo "Then, copy it to the directory .github/snapshots" | ||
else | ||
cp ${{ github.workspace }}/.github/snapshots/${{ matrix.TEMPLATE }}.nf.test.snap create-test-lint-wf/my-prefix-testpipeline/tests/default.nf.test.snap | ||
fi | ||
# Run pipeline with nf-test | ||
- name: run pipeline nf-test | ||
if: ${{ matrix.TEMPLATE != 'all' && matrix.TEMPLATE != 'nf-test' }} | ||
id: nf-test | ||
shell: bash | ||
run: | | ||
cd create-test-lint-wf/my-prefix-testpipeline | ||
nf-test test \ | ||
--profile=+docker \ | ||
--verbose | ||
- name: Update nf-test snapshot | ||
if: steps.nf-test.outcome == 'success' | ||
run: | | ||
cp ${{ github.workspace }}/create-test-lint-wf/my-prefix-testpipeline/tests/default.nf.test.snap ${{ github.workspace }}/.github/snapshots/${{ matrix.TEMPLATE }}.nf.test.snap | ||
# indication that the run has finished | ||
- name: react if finished succesfully | ||
if: steps.nf-test.outcome == 'success' | ||
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 | ||
with: | ||
comment-id: ${{ github.event.comment.id }} | ||
reactions: "+1" | ||
|
||
- name: Commit & push changes | ||
id: commit-and-push | ||
if: steps.nf-test.outcome == 'success' | ||
run: | | ||
git config user.email "core@nf-co.re" | ||
git config user.name "nf-core-bot" | ||
git config push.default upstream | ||
git add . | ||
git status | ||
git commit -m "[automated] Update Template snapshots" | ||
git push | ||
- name: react if snapshots were updated | ||
id: react-if-updated | ||
if: steps.commit-and-push.outcome == 'success' | ||
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 | ||
with: | ||
comment-id: ${{ github.event.comment.id }} | ||
reactions: hooray | ||
|
||
- name: react if snapshots were not updated | ||
if: steps.commit-and-push.outcome == 'failure' | ||
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 | ||
with: | ||
comment-id: ${{ github.event.comment.id }} | ||
reactions: confused | ||
|
||
- name: react if snapshots were not updated | ||
if: steps.commit-and-push.outcome == 'failure' | ||
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
@${{ github.actor }} I tried to update the snapshots, but it didn't work. Please update them manually. |
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
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.
do we need this?
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 think so? Otherwise, it would try to run on comments to issues too