Skip to content

Commit

Permalink
[🔥AUDIT🔥] Fix GitHub workflow to check for release PRs (#2367)
Browse files Browse the repository at this point in the history
🖍 _This is an audit!_ 🖍

## Summary:

There's an issue when a new Release Pull Request is created.

The problem is that one of the workflow job steps is failing because it cannot
find the base commit of the PR and it defaults to `00000000....00` instead.

https://github.com/Khan/wonder-blocks/actions/runs/11937708116/job/33275169358#step:5:23

This has been temporarily solved by pushing an empty commit to the PR branch
which causes the branch/PR to have clean its state and have a base commit.

### Possible cause:

My theory is that the PR/branch cannot determine the base commit because of the
way GH configures the COMMIT_SHA for this type of event (creating a PR/branch in
this case).

> Last commit on the created branch or tag.

My thinking is that the base commit is not being fetched because the workflow
automatically creates a new branch so there's no commit to compare it to.

For reference: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#create


### Solution:

This PR fixes the issue by adding a `fetch-depth` value to the `checkout` action in
the CI workflow. This will allow the workflow to fetch all the tags and commits
from the repository, so the base commit can be found.

Issue: XXX-XXXX

## Test plan:

Verify that there are no PR check errors the next time the "Release PR" is
created (unfortunately, this is the only way to test these type of changes).

Author: jandrade

Auditors: beaesguerra

Required Reviewers:

Approved By: beaesguerra

Checks: ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ⏭️  Chromatic - Skip on Release PR (changesets), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald, ⏭️  dependabot

Pull Request URL: #2367
  • Loading branch information
jandrade authored Nov 20, 2024
1 parent 5afa445 commit 951105d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .changeset/afraid-buckets-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
5 changes: 4 additions & 1 deletion .github/workflows/node-ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ jobs:
os: [ubuntu-latest]
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down

0 comments on commit 951105d

Please sign in to comment.