Skip to content
Merged
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
7 changes: 6 additions & 1 deletion .github/workflows/production-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ name: Deployed site acceptance

on:
workflow_run:
workflows: ["pages build and deployment"]
workflows: ["CI"]
types: [completed]
branches: [main]
workflow_dispatch:

permissions:
contents: read
actions: read

jobs:
production:
Expand All @@ -32,6 +33,10 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Confirm successful Pages deployment for this revision
env:
GITHUB_TOKEN: ${{ github.token }}
run: python3 tests/acceptance/wait_pages.py
- uses: actions/setup-node@v4
with:
node-version: '24'
Expand Down
18 changes: 13 additions & 5 deletions docs/ACCEPTANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,19 @@ Reports are written under `test-results/production/` and
`playwright-report/production/`, separately from the existing browser suite.

The normal CI matrix runs the local rehearsal on all three engines. The
`Deployed site acceptance` workflow is configured to run after a successful,
same-repository main-branch Pages workflow, and can also be dispatched manually.
It checks out the triggering deployment's source revision. The new workflow
must be merged to the default branch before its post-deployment trigger can be
verified; its configured trigger is not evidence that it has run.
`Deployed site acceptance` workflow runs after successful same-repository
main-branch CI, and can also be dispatched manually. Before checking the live
site, it requires a successful GitHub-managed Pages deployment of that exact
revision, with a three-minute bounded wait. A failed or missing deployment fails
the gate; an older deployment cannot satisfy it. The checked-out revision and
browser report metadata use the triggering CI's source SHA.

The first PR #10 merge (`dfbed94`) passed main CI and Pages, but the original
`workflow_run` subscription to the GitHub-managed dynamic Pages workflow did
not start any acceptance run. The follow-up uses the repository's normal CI
workflow as its entry point and checks Pages explicitly. Its actual hosted
trigger remains unverified until the follow-up merges and runs; a configured
trigger alone is not evidence of execution.

## Native macOS dry-run compatibility

Expand Down
26 changes: 26 additions & 0 deletions outputs/verification.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,31 @@
"reason": "BRITX dry run exceeded original 60-second collector budget",
"realInstallationPerformed": false
}
},
"deploymentTriggerFollowUp": {
"verifiedDateBrasilia": "2026-10-25",
"testedBaseCommit": "dfbed9484a85124d88859be8797fbe147dcd6856",
"mainCi": "https://github.com/pedrobritx/mac-setup/actions/runs/40199599717",
"mainCiConclusion": "success",
"pagesDeployment": "https://github.com/pedrobritx/mac-setup/actions/runs/40199599590",
"pagesDeploymentConclusion": "success",
"originalPagesWorkflowSubscriptionProducedAcceptanceRun": false,
"replacementEntryPoint": "successful same-repository main CI; require successful Pages run for the exact SHA",
"localTests": {
"node": 15,
"python": 21,
"deploymentGateRegressions": 4
},
"realApiDeploymentGatePassed": true,
"workflowLint": "actionlint 1.7.12 passed",
"dockerAvailable": false,
"hostedReplacementTriggerVerified": false,
"realInstallationPerformed": false,
"humanAcceptancePerformed": false,
"sourceSha256": {
".github/workflows/production-smoke.yml": "694ee7202f7dd5381e45e92f09fcdd251be8e3a91453c7b6eb838ef2ccf29b89",
"tests/acceptance/wait_pages.py": "cd7bdc8e586de024222e3ed27678308cc7d16b760e2d4cb1faf71aa9f6e443a3",
"tests/test_deployment_gate.py": "bf0185049ede5ed39426f55c64ca0a23d3cdf50199184e867d0fa146eba049ab"
}
}
}
48 changes: 48 additions & 0 deletions tests/acceptance/wait_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Require a successful Pages deployment of the exact revision under test."""

import json
import os
import time
from urllib.parse import urlencode
from urllib.request import Request, urlopen


def wait_for_pages(fetch_runs, sha, repository, *, timeout=180, interval=5,
clock=time.monotonic, pause=time.sleep):
deadline = clock() + timeout
while True:
candidates = [run for run in fetch_runs() if (
run.get("path") == "dynamic/pages/pages-build-deployment"
and run.get("head_sha") == sha
and run.get("head_branch") == "main"
and (run.get("head_repository") or {}).get("full_name") == repository
)]
if candidates:
run = max(candidates, key=lambda run: run["id"])
if run["status"] == "completed":
if run["conclusion"] != "success":
raise RuntimeError(f"Pages deployment {run['id']}: {run['conclusion']}")
return run
if clock() >= deadline:
raise TimeoutError(f"No successful Pages deployment for {sha} within {timeout}s")
pause(min(interval, max(0, deadline - clock())))


def fetch_runs(repository, sha):
query = urlencode({"head_sha": sha, "per_page": 100})
headers = {"Accept": "application/vnd.github+json"}
if os.environ.get("GITHUB_TOKEN"):
headers["Authorization"] = "Bearer " + os.environ["GITHUB_TOKEN"]
request = Request(
f"https://api.github.com/repos/{repository}/actions/runs?{query}",
headers=headers,
)
with urlopen(request, timeout=15) as response:
return json.load(response)["workflow_runs"]


if __name__ == "__main__":
repository = os.environ["GITHUB_REPOSITORY"]
sha = os.environ["MAC_SETUP_EXPECTED_COMMIT"]
run = wait_for_pages(lambda: fetch_runs(repository, sha), sha, repository)
print(f"Confirmed Pages deployment for {sha}: {run['html_url']}")
57 changes: 57 additions & 0 deletions tests/test_deployment_gate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""Deployment gate checks: require the tested revision, never an older success."""

import importlib.util
from pathlib import Path
import unittest

spec = importlib.util.spec_from_file_location(
"wait_pages", Path(__file__).parent / "acceptance/wait_pages.py"
)
gate = importlib.util.module_from_spec(spec)
spec.loader.exec_module(gate)


class DeploymentGateTests(unittest.TestCase):
def run_record(self, **changes):
return dict({
"id": 1, "path": "dynamic/pages/pages-build-deployment",
"head_sha": "tested", "head_branch": "main",
"head_repository": {"full_name": "owner/repo"},
"status": "completed", "conclusion": "success",
}, **changes)

def wait(self, batches):
now = [0]
def pause(seconds):
now[0] += seconds
return gate.wait_for_pages(
lambda: next(batches), "tested", "owner/repo", timeout=2,
interval=1, clock=lambda: now[0], pause=pause,
)

def test_waits_for_matching_revision_and_completed_deployment(self):
result = self.wait(iter([
[self.run_record(head_sha="old")],
[self.run_record(status="in_progress", conclusion=None)],
[self.run_record()],
]))
self.assertEqual(result["head_sha"], "tested")

def test_latest_failed_run_cannot_be_hidden_by_old_success(self):
with self.assertRaisesRegex(RuntimeError, "Pages deployment 2: failure"):
self.wait(iter([[self.run_record(), self.run_record(id=2, conclusion="failure")]]))

def test_wrong_workflow_branch_and_repository_cannot_satisfy_gate(self):
runs = [self.run_record(path=".github/workflows/ci.yml"),
self.run_record(head_branch="feature"),
self.run_record(head_repository={"full_name": "fork/repo"})]
with self.assertRaises(TimeoutError):
self.wait(iter([runs, runs, runs]))

def test_missing_run_expires_instead_of_accepting_old_deployment(self):
with self.assertRaises(TimeoutError):
self.wait(iter([[], [], []]))


if __name__ == "__main__":
unittest.main()
Loading