Skip to content
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

pathogen-repo-ci: Don't run workflow build steps if they're not going to do anything #96

Merged
merged 6 commits into from
Jun 14, 2024

Conversation

tsibley
Copy link
Member

@tsibley tsibley commented Jun 12, 2024

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)

Checklist

  • Checks pass
  • Verify a repo without pathogen-nextstrain.yaml fails as expected proof
  • Verify a repo that has pathogen-nextstrain.yaml but lacking required files for all build steps fails as expected proof
  • Verify a repo that has one step that attempts to run succeeds as expected proof
  • Verify a repo that runs two steps still succeeds as expected proof

@tsibley tsibley force-pushed the trs/pathogen-repo-ci/skip-it-skip-it branch 2 times, most recently from 6917e28 to 6c28c6b Compare June 12, 2024 19:16
@tsibley tsibley requested review from a team and genehack June 12, 2024 20:54
@genehack genehack force-pushed the bring-tha-noise-92 branch 2 times, most recently from 1bad99e to df99e08 Compare June 13, 2024 00:36
@genehack
Copy link
Contributor

I don't understand why it needs to be generated from a template? What's going on with that?

@genehack genehack force-pushed the bring-tha-noise-92 branch from df99e08 to fea28cb Compare June 13, 2024 17:13
Base automatically changed from bring-tha-noise-92 to master June 13, 2024 17:43
Copy link
Contributor

@joverlee521 joverlee521 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes here make sense to me 👍

.github/workflows/pathogen-repo-ci.yaml Outdated Show resolved Hide resolved
tsibley added a commit that referenced this pull request Jun 14, 2024
tsibley added 5 commits June 13, 2024 23:03
… 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)>
No longer configurable as of "Refactor `pathogen-repo-ci` to be smarter
[#89]" (d3730bc).
…ed input YAML

This allows us to author the workflow using YAML anchors/references
(especially with merge keys) since GitHub Actions doesn't otherwise
support those YAML features.

The lack of support is a shame because GitHub Actions workflows can be
very repetitive and anchors/references/merges are a decent solution to
that.  I'm about to add substantial conceptual replication that we won't
want to maintain concretely replicated in the file.

Since the generated file must be checked in, a CI step ensures the
generated file matches the authored file and the generated file is
excluded from git diffs by default.  An optional local pre-commit hook
is also available for making sure you craft commits that won't run afoul
of the CI check later.  Or you can, as necessary, run `make` manually
before committing.

(Commit messaged based on edd3290.)
This lets us more easily test it in development.

(Commit based on 1f41bea.)
Handy for running this workflow against non-default refs for testing.
tsibley added a commit that referenced this pull request Jun 14, 2024
@tsibley tsibley force-pushed the trs/pathogen-repo-ci/skip-it-skip-it branch from d279c5c to 89092f6 Compare June 14, 2024 06:05
@tsibley
Copy link
Member Author

tsibley commented Jun 14, 2024

Rebased to account for later updates made in #95 and resolve conflicts.

tsibley added a commit that referenced this pull request Jun 14, 2024
@tsibley tsibley force-pushed the trs/pathogen-repo-ci/skip-it-skip-it branch 2 times, most recently from efb5519 to d46b0d6 Compare June 14, 2024 06:11
@tsibley tsibley merged commit 73e2b75 into master Jun 14, 2024
36 checks passed
@tsibley tsibley deleted the trs/pathogen-repo-ci/skip-it-skip-it branch June 14, 2024 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants