From 21e79b52eb184376b6572c1776b9550dcc03b664 Mon Sep 17 00:00:00 2001 From: Paul Golmann Date: Mon, 16 Nov 2026 21:20:36 +0100 Subject: [PATCH] fix(ci): handle freshness reporting with issues disabled --- .github/workflows/upstream-watch.yml | 28 ++++++++++- docs/agents/ci-cd.md | 4 ++ packaging/ci/test-upstream-watch-reporting.py | 46 +++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 packaging/ci/test-upstream-watch-reporting.py diff --git a/.github/workflows/upstream-watch.yml b/.github/workflows/upstream-watch.yml index 06b10e9..05d6ec8 100644 --- a/.github/workflows/upstream-watch.yml +++ b/.github/workflows/upstream-watch.yml @@ -50,6 +50,9 @@ jobs: steps: - uses: actions/checkout@v7 + - name: Test issue-reporting contract offline + run: python3 packaging/ci/test-upstream-watch-reporting.py + # `runner.temp` is unavailable in a job-level `env:` block, so the body path is declared # per step. It stays out of the checkout so the workspace is never dirtied. - name: Enumerate upstream + salsa tags and compare against the pins @@ -69,8 +72,29 @@ jobs: exit "$rc" ;; esac + - name: Check whether issue reporting is available + id: reporting + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + BEHIND: ${{ steps.check.outputs.behind }} + run: | + set -euo pipefail + enabled="$(gh api "repos/$GH_REPO" --jq .has_issues)" + case "$enabled" in + true) echo "enabled=true" >> "$GITHUB_OUTPUT" ;; + false) + echo "enabled=false" >> "$GITHUB_OUTPUT" + echo "Issue reporting is disabled for this repository." >> "$GITHUB_STEP_SUMMARY" + if [ "$BEHIND" = true ]; then + echo "::error::Pins are behind; enable issues to receive the tracking report." + exit 1 + fi ;; + *) echo "::error::Unexpected has_issues response"; exit 1 ;; + esac + - name: Open or update the single tracking issue - if: steps.check.outputs.behind == 'true' + if: steps.reporting.outputs.enabled == 'true' && steps.check.outputs.behind == 'true' env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} @@ -94,7 +118,7 @@ jobs: fi - name: Close the tracking issue once every pin is current again - if: steps.check.outputs.behind == 'false' + if: steps.reporting.outputs.enabled == 'true' && steps.check.outputs.behind == 'false' env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} diff --git a/docs/agents/ci-cd.md b/docs/agents/ci-cd.md index f638f73..491a7b6 100644 --- a/docs/agents/ci-cd.md +++ b/docs/agents/ci-cd.md @@ -109,3 +109,7 @@ major action versions, per-manager caches, weekly grouped Dependabot, test-befor Action pins track the latest stable **major** (resolved via the `gh api` releases/latest endpoint); Dependabot keeps them current. JS/TS CI runs on **Node 26** — the CeraLive CI baseline, and the runtime the published tarball's consumer fixture asserts on. + +When repository issues are disabled, the watch still compares every pin. It skips +issue reconciliation for current pins, but fails visibly if pins are behind. +API failures remain errors; issue availability never suppresses a failed check. diff --git a/packaging/ci/test-upstream-watch-reporting.py b/packaging/ci/test-upstream-watch-reporting.py new file mode 100644 index 0000000..9a54ec2 --- /dev/null +++ b/packaging/ci/test-upstream-watch-reporting.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +"""Execute the workflow reporting step against isolated GitHub responses.""" +import os +from pathlib import Path +import subprocess +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[2] + + +class ReportingTest(unittest.TestCase): + def test_reporting(self): + workflow = (ROOT / '.github/workflows/upstream-watch.yml').read_text() + reporting = workflow.split(' - name: Check whether issue reporting is available\n', 1)[1] + block = reporting.split(' run: |\n', 1)[1].split(' - name:', 1)[0] + script = '\n'.join(line[10:] for line in block.splitlines() if line.strip()) + for name in ('Open or update the single tracking issue', + 'Close the tracking issue once every pin is current again'): + condition = workflow.split(' - name: ' + name + '\n', 1)[1].splitlines()[0] + self.assertIn("steps.reporting.outputs.enabled == 'true'", condition) + for enabled, behind, api_rc, expected in ( + ('true', 'false', 0, 0), ('true', 'true', 0, 0), + ('false', 'false', 0, 0), ('false', 'true', 0, 1), + ('', 'false', 1, 1), ('unexpected', 'false', 0, 1), + ): + with self.subTest(enabled=enabled, behind=behind, api_rc=api_rc): + with tempfile.TemporaryDirectory() as scratch: + directory = Path(scratch) + gh = directory / 'gh' + gh.write_text('#!/bin/sh\nprintf "%s\\n" "$RESPONSE"\nexit "$API_RC"\n') + gh.chmod(0o755) + output = directory / 'output' + result = subprocess.run(['bash', '-c', script], capture_output=True, + env={**os.environ, 'PATH': scratch + ':' + os.environ['PATH'], + 'GH_REPO': 'example/project', 'BEHIND': behind, + 'RESPONSE': enabled, 'API_RC': str(api_rc), + 'GITHUB_OUTPUT': str(output), + 'GITHUB_STEP_SUMMARY': str(directory / 'summary')}) + self.assertEqual(result.returncode, expected, result.stderr) + if api_rc == 0 and enabled in ('true', 'false'): + self.assertEqual(output.read_text(), f'enabled={enabled}\n') + + +if __name__ == '__main__': + unittest.main()