Files
dc/.gitea/scripts/tests/cypress-changes.test.sh
T
dc ecc87021c3
Build / Build-and-ng-test (pull_request) Successful in 6m32s
Lighthouse Checks / lighthouse (pull_request) Successful in 9m59s
Build / Build-and-test-development (pull_request) Successful in 27m9s
fix(build): publish the changed-path decision and pin the matcher with tests
Two review findings on the first two commits.

The two jobs no longer decide separately. Build-and-ng-test now publishes
`client` as a job output and Build-and-test-development consumes it instead of
re-diffing the base branch: a base commit landing between the two decisions
could make the Cypress job expect an artifact the build job had already
skipped, and the failure would read as a missing artifact. An empty output
(the build job could not decide) still runs everything.

The path list is now a PATHS variable the script can be asked about directly
(`--match` with a file list on stdin), and tests/cypress-changes.test.sh pins
one case per alternative plus the negatives (a sas/ service, docs, the
Lighthouse workflow, a "clientx/" directory, the sas lockfile). The build job
runs the test, so dropping an alternative is red rather than a suite that
silently stops covering a class of change. Checked the test fails when the
pattern is mutated.
2026-11-04 19:17:35 +00:00

51 lines
1.8 KiB
Bash

#!/usr/bin/env bash
# The path list in cypress-changes.sh is the whole gate: drop an alternative
# and the Cypress suite silently stops running for a class of change, with a
# green job that just finished sooner. These cases pin the list to what the
# suite actually reads, and run in the build job on every pull request.
#
# Run by hand: bash .gitea/scripts/tests/cypress-changes.test.sh
set -uo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
matcher="$here/../cypress-changes.sh"
fails=0
check() { # <expected> <path>...
local want="$1" got
shift
got=$(printf '%s\n' "$@" | bash "$matcher" --match)
if [ "$got" != "$want" ]; then
echo "FAIL: expected $want for: $*"
echo " got: $got"
fails=$((fails + 1))
fi
}
# Everything the Cypress job reads: the client it drives, the mock estate it
# deploys, the CLI pin it installs, the scripts that decide what it runs, and
# the dependency/workflow files that change the first two.
check true client/src/app/app.component.ts
check true sas/mocks/sasjs/services/makedata.js
check true sas/package.json
check true .gitea/scripts/cypress-specs.sh
check true package-lock.json
check true .gitea/workflows/build.yaml
# Not inputs: a sas/ service the mock estate does not deploy, documentation,
# the Lighthouse workflow, an unrelated directory whose name starts with
# "client", and the sas lockfile (the job installs the CLI by version string,
# so the lockfile cannot change what it resolves).
check false sas/macros/mp_abort.sas
check false AGENTS.md
check false docs/readme.md
check false .gitea/workflows/lighthouse.yaml
check false clientx/foo.ts
check false sas/package-lock.json
if [ "$fails" -ne 0 ]; then
echo "cypress-changes matcher: $fails case(s) failed"
exit 1
fi
echo "cypress-changes matcher: all cases passed"