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
28 changes: 26 additions & 2 deletions .github/workflows/upstream-watch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions docs/agents/ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
46 changes: 46 additions & 0 deletions packaging/ci/test-upstream-watch-reporting.py
Original file line number Diff line number Diff line change
@@ -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()
Loading