Skip to content

Commit

Permalink
Check for in progress releases before trying to do snapshots (#2044)
Browse files Browse the repository at this point in the history
## Summary:
This PR modifies our node-ci workflow so that we don't bother trying to do snapshots if we see a release workflow in progress.

Issue: FEI-6062

## Test plan:
To test this out, we will need to:

1. Have a Version Packages release ready to merge (DO NOT MERGE YET)
2. Have a PR ready that will trigger a snapshot (a simple change in an existing package, like a comment - we're not actually landing the PR)
3. Merge that release
4. Immediately `git pull && git merge origin/main && git push` on the PR
5. Watch the workflows. The release workflow should succeed and publish the packages. The snapshot workflow should fail with a message about a release in progress, and it should update the PR comment saying the snapshot was not created.

Author: somewhatabstract

Reviewers: somewhatabstract, jeremywiebe

Required Reviewers:

Approved By: jeremywiebe

Checks: ⌛ Publish npm snapshot (ubuntu-latest, 20.x), ⌛ Cypress (ubuntu-latest, 20.x), ⌛ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⌛ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⌛ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ⏹️  [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⌛ Publish Storybook to Chromatic (ubuntu-latest, 20.x)

Pull Request URL: #2044
  • Loading branch information
somewhatabstract authored Dec 20, 2024
1 parent 641afcf commit ab294b6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .changeset/serious-jokes-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
46 changes: 45 additions & 1 deletion .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,32 @@ jobs:
git checkout main
git checkout $REF
# Helper to get the URL of the current run, if we need it.
- name: Get workflow run URL
id: get-run-url
run: echo "run_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT

# We need to see if any releases are in progress.
# We do not want to try and publish anything if a publish is
# pending. We fail here, but we make sure to update the
# PR comment later. This has to come after the checkout.
- name: Check for release
id: check-release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Releases are triggered by merging "Version Packages" PRs.
# So we look for instances of the release.yml workflow, with
# a title containing "Version Packages", that are in progress.
release_count=$(gh run list --workflow release.yml --json status,displayTitle --jq '[.[] | select(.status == "in_progress" and (.displayTitle | contains("Version Packages")))] | length')
echo "release_count=$release_count" >> $GITHUB_OUTPUT
if [ "$release_count" -ne 0 ]; then
echo "Error: There are $release_count releases in progress."
exit 1
else
echo "No releases in progress."
fi
- name: Install & cache node_modules
uses: ./.github/actions/shared-node-cache
with:
Expand All @@ -249,6 +275,8 @@ jobs:
# Note: these two actions are locked to the latest version that were
# published when I created this yml file (just for security).
- name: Find existing comment
# Even if we're failing, we want to update the comments.
if: always()
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e
id: find-comment
with:
Expand Down Expand Up @@ -282,7 +310,7 @@ jobs:
./dev/tools/bump_perseus_version.sh -t PR${{ github.event.pull_request.number }}
```
- name: Create or update npm snapshot comment - failure
- name: Create or update npm snapshot comment - failure, snapshot publish failed
if: steps.publish-snapshot.outputs.npm_snapshot_tag == ''
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
Expand All @@ -295,3 +323,19 @@ jobs:
Oh noes!! We couldn't find any changesets in this PR (${{
steps.short-sha.outputs.short_sha }}). As a result, we did not
publish an npm snapshot for you.
- name: Create or update npm snapshot comment - failure, concurrent with release
if: failure() && steps.check-release.outputs.release_count != '0'
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
# npm Snapshot: **NOT** Published
Oh noes!! We couldn't publish an npm snapshot for you because
there is a release in progress. Please wait for the release to
finish, then retry this workflow.
[View the workflow run](${{ steps.get-run-url.outputs.run_url }})

0 comments on commit ab294b6

Please sign in to comment.