-
Notifications
You must be signed in to change notification settings - Fork 3.3k
107 lines (98 loc) · 4.33 KB
/
chronus-verify.yml
File metadata and controls
107 lines (98 loc) · 4.33 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
name: Chronus Verify
on:
pull_request:
branches: [main]
paths:
- "sdk/*/*/**"
concurrency:
group: chronus-verify-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
chronus-verify:
name: Verify Chronus Change Descriptions
if: github.event.pull_request.user.login != 'azure-sdk'
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0 # needed so chronus can diff against base branch
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: lts/*
cache: npm
cache-dependency-path: .github/chronus/package-lock.json
- name: Install pinned dependencies
run: npm ci
working-directory: .github/chronus
- name: Run chronus verify
id: verify
run: .github/chronus/node_modules/.bin/chronus verify
# Sticky comment is only post-able when GITHUB_TOKEN has write scope —
# i.e. PRs from the main repo. Fork PRs see only the error annotation
# below, which is fine because /chronus add doesn't work for forks anyway.
- name: Post sticky one-click-fix PR comment on failure
if: failure() && steps.verify.conclusion == 'failure' && github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const HEADER = '<!-- chronus-verify-sticky -->';
const body = [
HEADER,
'### 📝 Missing changelog entry',
'',
'This PR touches package source under `sdk/*/*/**` but no Chronus',
'change description was found. CI requires every user-affecting',
'change to have one.',
'',
'#### ⚡ One-click fix',
'',
'**Comment `/chronus add` on this PR** and a bot will commit a',
'changelog entry for you, derived from your PR title.',
'',
'Customise the entry kind by appending it to the command:',
'',
'- `/chronus add` → defaults to `internal`',
'- `/chronus add fix` → bug fix',
'- `/chronus add feature` → new feature',
'- `/chronus add breaking` → breaking change',
'- `/chronus add deprecation` → deprecation',
'- `/chronus add dependencies` → dependency bump',
'',
'> ℹ️ For PRs from forks, run the command locally instead:',
'>',
'> ```bash',
'> azpysdk changelog add',
'> ```',
'',
'See [`doc/dev/changelog_updates.md`](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/changelog_updates.md) for full instructions.',
].join('\n');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});
const existing = comments.find(c => c.body && c.body.startsWith(HEADER));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body,
});
}
- name: Emit annotation on failure
if: failure() && steps.verify.conclusion == 'failure'
run: |
echo "::error::Chronus verification failed. Comment '/chronus add' on this PR for an automated fix, or run 'azpysdk changelog add' locally."
echo "::error::See https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/changelog_updates.md for instructions."