Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 12 additions & 23 deletions .github/workflows/test_node-checkout-and-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,15 @@ permissions:
contents: read

env:
# The fixture published at the root of a branch, for the tests that let the
# action download metadata and check out the repository itself. Regenerate
# with node-checkout-and-setup/test/publish-fixture.sh after changing the
# fixture; the fixture-branch-up-to-date job fails until then.
# A Yarn workspace at the root of a branch, for the tests that let the action
# download metadata and check out the repository itself. The tests read it as
# it is and never compare it with node-checkout-and-setup/test-fixture, so
# the fixture can change (by hand, in a pull request or by Renovate) without
# republishing the branch. To make these tests use a newer fixture, run
# node-checkout-and-setup/test/publish-fixture.sh from main.
FIXTURE_BRANCH: test-fixtures/node-checkout-and-setup

jobs:
# ---------------------------------------------------------------------------
# Fixture branch matches the fixture directory
# ---------------------------------------------------------------------------
fixture-branch-up-to-date:
name: Fixture branch is up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Compare fixture branch with node-checkout-and-setup/test-fixture
run: |
git fetch --depth 1 origin "$FIXTURE_BRANCH"
if ! git diff --exit-code --stat FETCH_HEAD HEAD:node-checkout-and-setup/test-fixture; then
echo "::error::$FIXTURE_BRANCH differs from node-checkout-and-setup/test-fixture. Run node-checkout-and-setup/test/publish-fixture.sh."
exit 1
fi

# ---------------------------------------------------------------------------
# Script tests
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -99,8 +83,13 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
OWNER_AND_REPO: ${{ github.repository }}
FIXTURE: ${{ github.workspace }}/node-checkout-and-setup/test-fixture
FIXTURE: ${{ runner.temp }}/fixture-branch
run: |
# The files the downloads must match: the fixture branch's own.
git fetch --depth 1 origin "$FIXTURE_BRANCH"
mkdir "$FIXTURE"
git archive FETCH_HEAD -- .nvmrc package.json yarn.lock | tar -x -C "$FIXTURE"

for visibility in public private; do
echo "::group::$visibility"
dir="$(mktemp -d)"
Expand Down
13 changes: 5 additions & 8 deletions node-checkout-and-setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,8 @@ Annotations can't be read from inside a job, so the warning about `ref` and `per
in a checked-out workspace is tested by running `scripts/warn-ignored-checkout-inputs.sh` in the
scripts job.

Some tests need the fixture at the root of a ref of this repository. After changing
`test-fixture/`, commit, then run `test/publish-fixture.sh` to update the
`test-fixtures/node-checkout-and-setup` branch.

There is one fixture branch for the whole repository. When a pull request changes the fixture and
republishes it, the fixture-branch-up-to-date job fails on every other open pull request until the
change merges and they are rebased onto it. Merge fixture changes before other pull requests that
touch this action.
Some tests need a Yarn workspace at the root of a ref of this repository. They use the
`test-fixtures/node-checkout-and-setup` branch as it is, and compare downloads with the branch's own
files, so changing `test-fixture/` doesn't require republishing it. To make these tests use a newer
fixture, run `test/publish-fixture.sh` from `main`. There is one branch for every pull request, so
don't run it from a pull request's branch.
6 changes: 4 additions & 2 deletions node-checkout-and-setup/test/publish-fixture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#
# Publishes node-checkout-and-setup/test-fixture, as committed at HEAD, as the
# root of the test-fixtures/node-checkout-and-setup branch. Some tests need a
# ref of this repository whose root is a Yarn workspace. Run it after changing
# the fixture; the fixture-branch-up-to-date test job fails until then.
# ref of this repository whose root is a Yarn workspace. They use the branch as
# it is, so it doesn't have to match the fixture: run this from main only when
# those tests should use a newer fixture. Every pull request uses the branch
# from then on, so don't run it from a pull request's branch.

set -euo pipefail

Expand Down
Loading