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

Run release from CI workflow #1634

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Run release from CI workflow #1634

merged 1 commit into from
Sep 23, 2024

Conversation

victorlin
Copy link
Member

@victorlin victorlin commented Sep 17, 2024

Description of proposed changes

This leverages the existing test matrix setup for CI which can sufficiently replace devel/test. A downside is that it does not test the changes created by devel/release, but those should not have an impact on test results.

Related issue(s)

Closes #1633

Checklist

Copy link
Member

@tsibley tsibley left a comment

Choose a reason for hiding this comment

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

In general this seems fine. It's an improvement over the current thing in terms of testing. Note it does mean that the release process will take much longer (not a nonstarter, but noting it).

A downside is that it does not test the changes created by devel/release

It's not just the source code changes created by devel/release that aren't tested, but that the actual release distributions (also currently created by devel/release) aren't ever tested themselves. Only the source code form is tested.

In the future, I'd encourage reorganizing to a stricter CI/CD flow where distribution artifacts are always built and those artifacts are the things tested and ultimately released (if appropriate). (For an example, see what I did for Nextstrain CLI.)

@@ -348,3 +354,50 @@ jobs:
echo "If there are changes to the Augur CLI, please manually adjust files under 'docs/usage/cli/'." >&2
exit 1
fi

release:
if: github.event_name == 'workflow_call' && github.workflow == 'Release'
Copy link
Member

Choose a reason for hiding this comment

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

non-blocking

This is an oddly tight binding of the two workflows to me. If we're going to do it, let's condition on the workflow file path instead of its name (which seems much more subject to change, and thus breakage)?

Alternatively, why condition here at all beyond the workflow_call event?

Copy link
Member Author

@victorlin victorlin Sep 20, 2024

Choose a reason for hiding this comment

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

Updated to condition on file path + branch:

# Only run when called by the release workflow on the default branch
if: github.event_name == 'workflow_call' && github.workflow_ref == format('{0}/.github/workflows/release.yaml@refs/heads/{1}', github.repository, github.event.repository.default_branch)

Alternatively, why condition here at all beyond the workflow_call event?

Conditioning only on workflow_call would mean "run release steps when the CI workflow is called by another workflow" which seems too loosely coupled. The CI workflow could be called by another workflow for other reasons in which release shouldn't happen.

If anything, I think the workflow_call condition is redundant and can be removed. The path being anything other than .github/workflows/ci.yaml implies workflow_call as the triggering event.

Copy link
Member

Choose a reason for hiding this comment

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

Conditioning only on workflow_call would mean "run release steps when the CI workflow is called by another workflow" which seems too loosely coupled. The CI workflow could be called by another workflow for other reasons in which release shouldn't happen.

The workflow_call trigger requires a version input, so any call of it with a version seems to me like a release is intended.

In any case, the larger point is that I think the coupling here between the two workflows is weird and an artifact of trying to preserve the "Release" workflow.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. I meant for this PR to be a small change to prevent release on failing tests. Maybe it'd be better to drop the "Release" workflow, but that needs a larger discussion around aligning release procedures between Augur/Auspice/Nextstrain CLI. I'll keep it in this PR.

The workflow_call trigger requires a version input, so any call of it with a version seems to me like a release is intended.

True, but when browsing the code I think (2) reads better than (1):

  1. release:
      # Only run when the triggered by workflow_call with input.version
      if: github.event_name == 'workflow_call'
      needs: [pytest-cram]
  2. release:
      # Only run when called by the release workflow on the default branch
      if: github.workflow_ref == format('{0}/.github/workflows/release.yaml@refs/heads/{1}', github.repository, github.event.repository.default_branch)
      needs: [pytest-cram]

Checking default branch is important. With (1) it could happen in release.yaml, but (2) comes with added context of actual release steps.

Copy link
Member

Choose a reason for hiding this comment

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

I meant for this PR to be a small change to prevent release on failing tests.

Yep, and that's fine, hence why I said at the top: "In general this seems fine. It's an improvement over the current thing in terms of testing." :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've removed the workflow_call condition in #1675

@victorlin
Copy link
Member Author

the actual release distributions (also currently created by devel/release) aren't ever tested themselves

That is already the case prior to this PR, but point taken. I'll create a separate issue for improvements once this PR is merged.

@victorlin victorlin marked this pull request as ready for review September 20, 2024 20:58
This leverages the existing test matrix setup for CI which can
sufficiently replace devel/test. A downside is that it does not test the
changes created by devel/release, but those should not have an impact on
test results.
@victorlin victorlin merged commit d10c3fb into master Sep 23, 2024
30 checks passed
@victorlin victorlin deleted the victorlin/release-in-ci branch September 23, 2024 23:40
victorlin added a commit that referenced this pull request Nov 12, 2024
This was flawed: even though ci.yaml is called by another workflow, the
`github` context is associated with the caller workflow¹ so event_name
is "workflow_dispatch" during a release run.

It doesn't make sense to update the condition to match
"workflow_dispatch", since there are valid reasons for running ci.yaml
using workflow_dispatch.

I think it makes more sense to simply remove this half of the condition
as redundant². The other half of the condition sufficiently ensures that
the job is run only when called by the release workflow on the default
branch.

¹ <https://docs.github.com/en/actions/sharing-automations/reusing-workflows>
² <#1634 (comment)>
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.

Release workflow doesn't run tests successfully but continues anyway
2 participants