Repository navigation
95 lines (95 loc) · 4.24 KB
/
Copy pathsync-candidate.yml
File metadata and controls
95 lines (95 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Validate Cursor catalog candidate
on:
workflow_dispatch:
inputs:
pr:
description: Proposal pull request number
required: true
head:
description: Expected proposal head commit
required: true
base:
description: Expected maintained main commit
required: true
target:
description: Expected Cursor pstack commit
required: true
permissions: {}
concurrency:
group: sync-candidate-${{ inputs.pr }}
cancel-in-progress: true
jobs:
verify:
if: github.repository == 'arjitj2/open-pstack' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
persist-credentials: false
- name: Validate the metadata-only proposal
env:
GH_TOKEN: ${{ github.token }}
CANDIDATE_PR: ${{ inputs.pr }}
CANDIDATE_HEAD: ${{ inputs.head }}
CANDIDATE_BASE: ${{ inputs.base }}
CANDIDATE_TARGET: ${{ inputs.target }}
run: >-
python3 scripts/fork-maintenance.py check-candidate
--pr "$CANDIDATE_PR" --head "$CANDIDATE_HEAD"
--base "$CANDIDATE_BASE" --target "$CANDIDATE_TARGET"
- name: Check the proposed ledger
env:
CANDIDATE_HEAD: ${{ inputs.head }}
run: |
git show "$CANDIDATE_HEAD:maintenance/upstream-ledger.json" > candidate-ledger.json
python3 scripts/fork-maintenance.py check-ledger --file candidate-ledger.json
- name: Test fork maintenance
run: python3 tests/test-fork-maintenance.py
report:
needs: verify
if: always() && github.repository == 'arjitj2/open-pstack' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
statuses: write
pull-requests: read
steps:
- name: Attach result to the reviewed head
env:
GH_TOKEN: ${{ github.token }}
CANDIDATE_PR: ${{ inputs.pr }}
CANDIDATE_HEAD: ${{ inputs.head }}
CANDIDATE_BASE: ${{ inputs.base }}
CANDIDATE_TARGET: ${{ inputs.target }}
RESULT: ${{ needs.verify.result }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
python3 - <<'PY'
import json, os, re, subprocess
pr, head, base = [os.environ[k] for k in ('CANDIDATE_PR', 'CANDIDATE_HEAD', 'CANDIDATE_BASE')]
assert re.fullmatch(r'[1-9][0-9]*', pr)
assert all(re.fullmatch(r'[0-9a-f]{40}', sha) for sha in (head, base))
current = json.loads(subprocess.check_output(['gh', 'api', f'repos/arjitj2/open-pstack/pulls/{pr}']))
main_ref = json.loads(subprocess.check_output(['gh', 'api', 'repos/arjitj2/open-pstack/git/ref/heads/main']))
if main_ref['object']['sha'] != base:
raise SystemExit('Main advanced after validation; no stale status published.')
head_repo = (current.get('head') or {}).get('repo') or {}
if head_repo.get('full_name') != 'arjitj2/open-pstack':
raise SystemExit('Candidate head is not in this repository; no status published.')
if current['state'] != 'open' or current['head']['sha'] != head or current['base']['sha'] != base:
raise SystemExit('Candidate was superseded; no stale status published.')
branch = 'automation/cursor-' + os.environ['CANDIDATE_TARGET'][:12] + '-' + base[:12]
if current['base']['ref'] != 'main' or current['head']['ref'] != branch:
raise SystemExit('Candidate branch changed; no stale status published.')
payload = {'state': 'success' if os.environ['RESULT'] == 'success' else 'failure',
'context': 'cursor-catalog/candidate',
'description': 'Metadata-only proposal validation; adoption still requires a normal PR with installed-host evidence.',
'target_url': os.environ['RUN_URL']}
subprocess.run(['gh', 'api', f'repos/arjitj2/open-pstack/statuses/{head}', '--method', 'POST', '--input', '-'],
input=json.dumps(payload), text=True, check=True)
PY