Skip to content

Commit

Permalink
pathogen-repo-ci: Don't run workflow build steps if they're not going…
Browse files Browse the repository at this point in the history
… to do anything

Instead of checking for whether to do anything or not _inside_ each
build step individually, move the check to the step's condition.  This
will make the logs a lot clearer and mean the GitHub workflow metadata
stays more in sync with reality.

I've used hashFiles() to check for file existence—it returns the empty
string, a falsey value, when there are no matching files—but we could
swap that out for using the output of a prior setup step that runs some
shell to determine what to run and what to skip.  Doing so might make
more sense if the conditional becomes more complicated or we want to do
more detailed reporting on _why_ steps were skipped or not.

With the changes, the internal-to-this-workflow action,
run-nextstrain-ci-build, is no longer that useful and so I've removed it
in favor of inlining things.  I think this is an improvement for
readability.

Related-to: <#95 (review)>
  • Loading branch information
tsibley committed Jun 12, 2024
1 parent 422bff1 commit b215385
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 93 deletions.
63 changes: 42 additions & 21 deletions .github/workflows/pathogen-repo-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ on:
artifact-name:
description: >-
A base name to use for the uploaded artifacts from the
build. This will be concatenated with the directory name
build. This will be concatenated with the runtime name
used to invoke the build to generate the full artifact file
name.
Expand Down Expand Up @@ -252,35 +252,56 @@ jobs:
runtime: ${{ matrix.runtime }}

- name: Run ingest
if: hashFiles('ingest/Snakefile', 'ingest/build-configs/ci/config.yaml')
id: ingest
uses: ./.git/nextstrain/.github/actions/run-nextstrain-ci-build
with:
directory: ingest
runtime: ${{ matrix.runtime }}
artifact-name: ${{ inputs.artifact-name }}
run: nextstrain build ingest --configfile build-configs/ci/config.yaml

- name: Run phylogenetic
if: hashFiles('phylogenetic/Snakefile', 'phylogenetic/build-configs/ci/config.yaml')
id: phylogenetic
uses: ./.git/nextstrain/.github/actions/run-nextstrain-ci-build
with:
directory: phylogenetic
runtime: ${{ matrix.runtime }}
artifact-name: ${{ inputs.artifact-name }}
run: nextstrain build phylogenetic --configfile build-configs/ci/config.yaml

- name: Run nextclade
if: hashFiles('nextclade/Snakefile', 'nextclade/build-configs/ci/config.yaml')
id: nextclade
uses: ./.git/nextstrain/.github/actions/run-nextstrain-ci-build
run: nextstrain build nextclade --configfile build-configs/ci/config.yaml

- if: always()
uses: actions/upload-artifact@v4
with:
directory: nextclade
runtime: ${{ matrix.runtime }}
artifact-name: ${{ inputs.artifact-name }}
name: ${{ inputs.artifact-name }}-${{ inputs.runtime }}
if-no-files-found: ignore
# @actions/glob has no support for brace expansion. Hrumph.
path: |
ingest/.snakemake/log/
ingest/auspice/
ingest/benchmarks/
ingest/logs/
ingest/results/
phylogenetic/.snakemake/log/
phylogenetic/auspice/
phylogenetic/benchmarks/
phylogenetic/logs/
phylogenetic/results/
nextclade/.snakemake/log/
nextclade/auspice/
nextclade/benchmarks/
nextclade/logs/
nextclade/results/
- name: Verify a workflow ran
env:
ingest: ${{ steps.ingest.conclusion }}
phylogenetic: ${{ steps.phylogenetic.conclusion }}
nextclade: ${{ steps.nextclade.conclusion }}
run: |
# shellcheck disable=SC2242
# Show step conclusions.
echo "ingest $ingest"
echo "phylogenetic $phylogenetic"
echo "nextclade $nextclade"
# if we see at least one success, we're good
echo "INGEST ATTEMPTED=${{ steps.ingest.outputs.run-attempted }}"
echo "PHYLOGENETIC ATTEMPTED=${{ steps.phylogenetic.outputs.run-attempted }}"
echo "NEXTCLADE ATTEMPTED=${{ steps.nextclade.outputs.run-attempted }}"
exit ${{ contains(steps.*.outputs.run-attempted, 'true') && '0' || '1' }}
# Assert status; if we see at least one attempt, regardless of
# success/failure, we're good.
[[ $ingest != skipped || $phylogenetic != skipped || $nextclade != skipped ]]
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ See also GitHub's [documentation on issue and PR templates](https://docs.github.

Invoked by our GitHub Actions workflows, including the reusable workflows below.

- [Run Nextstrain CI Build](actions/run-nextstrain-ci-build/action.yaml)
- [Setup Nextstrain CLI](actions/setup-nextstrain-cli/action.yaml)
- [shellcheck](actions/shellcheck/action.yaml)
- [Setup SSH](actions/setup-ssh/action.yaml) access to runner machine
Expand Down
71 changes: 0 additions & 71 deletions actions/run-nextstrain-ci-build/action.yaml

This file was deleted.

0 comments on commit b215385

Please sign in to comment.