Repository navigation
142 lines (128 loc) · 4.85 KB
/
Copy pathupstream-drift.yml
File metadata and controls
142 lines (128 loc) · 4.85 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Upstream drift
# The client implementation must not silently drift with upstream: a change to
# the normative protocol documents has to be seen and assessed by a human. This
# runs daily and opens an issue when — and only when — a normative file changes.
on:
schedule:
- cron: '17 6 * * *'
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
drift:
name: Check protocol baseline against upstream
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Clone upstream
run: git clone --quiet https://github.com/NodePassProject/Nowhere.git upstream-nowhere
- name: Drift check
id: drift
run: |
set +e
OUT="$(bash conformance/scripts/drift-check.sh "$GITHUB_WORKSPACE/upstream-nowhere" 2>&1)"
CODE=$?
echo "$OUT"
{
echo 'report<<DRIFT_EOF'
echo "$OUT"
echo 'DRIFT_EOF'
} >> "$GITHUB_OUTPUT"
echo "code=$CODE" >> "$GITHUB_OUTPUT"
exit 0
- name: Summary
run: |
{
echo '## Drift check'
echo
echo '```'
echo '${{ steps.drift.outputs.report }}'
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
# The mirror image of the step below. An issue that is only ever opened
# stays open after the baseline has been advanced, and a marker that is
# permanently red is one nobody reads. The same check that raised it is
# the thing entitled to withdraw it.
- name: Close the drift issue once the baseline agrees again
if: steps.drift.outputs.code == '0'
uses: actions/github-script@v9
with:
script: |
const report = ${{ toJSON(steps.drift.outputs.report) }};
const existing = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'upstream-drift',
});
const body = [
'The drift check passes again: `conformance/PROTOCOL_BASELINE` and',
'upstream agree. Closing automatically.',
'',
'```',
report,
'```',
'',
`Run: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
].join('\n');
for (const issue of existing.data) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body,
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed',
state_reason: 'completed',
});
}
- name: Open an issue on normative change
if: steps.drift.outputs.code != '0'
uses: actions/github-script@v9
with:
script: |
const report = ${{ toJSON(steps.drift.outputs.report) }};
const title = 'Upstream normative change detected';
// One open issue at a time; append to it rather than filing duplicates.
const existing = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'upstream-drift',
});
const body = [
'A normative file changed upstream. The protocol baseline pinned in',
'`conformance/PROTOCOL_BASELINE` no longer matches upstream, and the',
'difference is in a file that defines behaviour rather than in',
'implementation or surrounding docs.',
'',
'**Do not advance the baseline without reading the diff.** The tracking',
'policy in `conformance/PROTOCOL_BASELINE` explains why the pin is held.',
'',
'```',
report,
'```',
'',
`Run: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
].join('\n');
if (existing.data.length > 0) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existing.data[0].number,
body,
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title,
body,
labels: ['upstream-drift'],
});
}