fix: pin the E2E backend SHA in the frontend contract
Frontend CI / unit (test, type-check, build) (push) Successful in 1m54s
Frontend CI / browser E2E (frontend + pinned backend) (push) Successful in 5m9s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-22 13:01:49 +03:30
co-authored by Cursor
parent e3f0457dc9
commit bb29cc6bdb
3 changed files with 12 additions and 8 deletions
+3 -2
View File
@@ -54,8 +54,9 @@ jobs:
- name: Require pinned backend ref (SHA or tag) - name: Require pinned backend ref (SHA or tag)
run: | run: |
if [ -z "${E2E_BACKEND_REF}" ]; then if [ -z "${E2E_BACKEND_REF}" ]; then
echo "Set repository variable E2E_BACKEND_REF to a backend commit SHA. No fallback to main." E2E_BACKEND_REF="$(node -e "const c=require('./e2e/backend.contract.json'); const r=String(c.pinnedRef||''); if(!/^[0-9a-f]{40}$/i.test(r)){console.error('pinnedRef must be a full SHA'); process.exit(1)} process.stdout.write(r)")"
exit 1 echo "E2E_BACKEND_REF=${E2E_BACKEND_REF}" >> "$GITHUB_ENV"
echo "Repository variable unset; using committed pinnedRef"
fi fi
echo "E2E_BACKEND_REF=${E2E_BACKEND_REF}" echo "E2E_BACKEND_REF=${E2E_BACKEND_REF}"
+2 -1
View File
@@ -2,5 +2,6 @@
"repositoryUrl": "https://get.feep.ir/gold_land/gold_land_server.git", "repositoryUrl": "https://get.feep.ir/gold_land/gold_land_server.git",
"checkoutPath": "backend-nest", "checkoutPath": "backend-nest",
"localRef": "", "localRef": "",
"notes": "CI: set variable E2E_BACKEND_REF to backend commit SHA (required). Local clone: set E2E_BACKEND_REF or localRef. Local sibling: set E2E_BACKEND_ROOT to ../backend-nest and skip ci:checkout-backend." "pinnedRef": "dfb20ca92cb13f1d25c6aca64b6256c09176e603",
"notes": "CI uses E2E_BACKEND_REF when set, otherwise pinnedRef (full SHA only). Never falls back to main. Local sibling: E2E_BACKEND_ROOT=../backend-nest and skip ci:checkout-backend."
} }
+7 -5
View File
@@ -18,20 +18,22 @@ if (!existsSync(contractPath)) {
process.exit(1) process.exit(1)
} }
/** @type {{ repositoryUrl: string; checkoutPath: string; localRef?: string }} */ /** @type {{ repositoryUrl: string; checkoutPath: string; localRef?: string; pinnedRef?: string }} */
const contract = JSON.parse(readFileSync(contractPath, 'utf8')) const contract = JSON.parse(readFileSync(contractPath, 'utf8'))
const envRef = process.env.E2E_BACKEND_REF?.trim() const envRef = process.env.E2E_BACKEND_REF?.trim()
let ref = envRef let ref = envRef
if (isCi) { if (isCi && !ref) {
if (!ref) { ref = contract.pinnedRef?.trim()
if (!/^[0-9a-f]{40}$/i.test(ref ?? '')) {
console.error( console.error(
'E2E backend ref is required in CI. Set repository variable E2E_BACKEND_REF to a full commit SHA (or immutable tag). Silent fallback to main is disabled.', 'E2E backend ref is required in CI. Set E2E_BACKEND_REF or pinnedRef in e2e/backend.contract.json to a full commit SHA. Silent fallback to main is disabled.',
) )
process.exit(1) process.exit(1)
} }
} else if (!ref) { console.log('E2E_BACKEND_REF unset; using committed pinnedRef')
} else if (!isCi && !ref) {
ref = contract.localRef?.trim() ref = contract.localRef?.trim()
if (!ref) { if (!ref) {
console.error( console.error(