|
| 1 | +name: Chronus Verify |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "sdk/*/*/**" |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: chronus-verify-${{ github.event.pull_request.number }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + chronus-verify: |
| 15 | + name: Verify Chronus Change Descriptions |
| 16 | + if: github.event.pull_request.user.login != 'azure-sdk' |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + issues: write |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 23 | + with: |
| 24 | + fetch-depth: 0 # needed so chronus can diff against base branch |
| 25 | + persist-credentials: false |
| 26 | + |
| 27 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 28 | + with: |
| 29 | + node-version: "22" |
| 30 | + cache: npm |
| 31 | + cache-dependency-path: .github/chronus/package-lock.json |
| 32 | + |
| 33 | + - name: Install pinned dependencies |
| 34 | + run: npm ci |
| 35 | + working-directory: .github/chronus |
| 36 | + |
| 37 | + - name: Run chronus verify |
| 38 | + id: verify |
| 39 | + run: npm exec --no --prefix .github/chronus/ -- chronus verify |
| 40 | + |
| 41 | + # Sticky comment is only post-able when GITHUB_TOKEN has write scope — |
| 42 | + # i.e. PRs from the main repo. Fork PRs see only the error annotation below. |
| 43 | + - name: Post sticky fix-instructions PR comment on failure |
| 44 | + if: failure() && steps.verify.conclusion == 'failure' && github.event.pull_request.head.repo.full_name == github.repository |
| 45 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 46 | + with: |
| 47 | + script: | |
| 48 | + const HEADER = '<!-- chronus-verify-sticky -->'; |
| 49 | + const body = [ |
| 50 | + HEADER, |
| 51 | + '### 📝 Missing changelog entry', |
| 52 | + '', |
| 53 | + 'This PR touches package source under `sdk/*/*/**` but no Chronus', |
| 54 | + 'change description was found. CI requires every user-affecting', |
| 55 | + 'change to have one.', |
| 56 | + '', |
| 57 | + '#### How to fix', |
| 58 | + '', |
| 59 | + 'Run the following from the repo root (or from within the package', |
| 60 | + 'directory) and push the new `.chronus/changes/*.md` file:', |
| 61 | + '', |
| 62 | + '```bash', |
| 63 | + 'azpysdk changelog add', |
| 64 | + '```', |
| 65 | + '', |
| 66 | + 'This adds a change entry for each modified package. If your change', |
| 67 | + 'is not user-facing (e.g. tests or docs only), choose the `internal`', |
| 68 | + 'kind to satisfy the check without bumping the version.', |
| 69 | + '', |
| 70 | + '> 💡 You can also ask **GitHub Copilot** to fix this failing check', |
| 71 | + '> for you directly from the PR\'s *Checks* tab.', |
| 72 | + '', |
| 73 | + 'See [`doc/dev/changelog_updates.md`](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/changelog_updates.md) for full instructions.', |
| 74 | + ].join('\n'); |
| 75 | +
|
| 76 | + const comments = await github.paginate(github.rest.issues.listComments, { |
| 77 | + owner: context.repo.owner, |
| 78 | + repo: context.repo.repo, |
| 79 | + issue_number: context.payload.pull_request.number, |
| 80 | + }); |
| 81 | + const existing = comments.find(c => c.body && c.body.startsWith(HEADER)); |
| 82 | + if (existing) { |
| 83 | + await github.rest.issues.updateComment({ |
| 84 | + owner: context.repo.owner, |
| 85 | + repo: context.repo.repo, |
| 86 | + comment_id: existing.id, |
| 87 | + body, |
| 88 | + }); |
| 89 | + } else { |
| 90 | + await github.rest.issues.createComment({ |
| 91 | + owner: context.repo.owner, |
| 92 | + repo: context.repo.repo, |
| 93 | + issue_number: context.payload.pull_request.number, |
| 94 | + body, |
| 95 | + }); |
| 96 | + } |
| 97 | +
|
| 98 | + - name: Emit annotation on failure |
| 99 | + if: failure() && steps.verify.conclusion == 'failure' |
| 100 | + run: | |
| 101 | + echo "::error::Chronus verification failed. Run 'azpysdk changelog add' locally and push the new .chronus/changes/*.md file, or ask GitHub Copilot to fix this check from the PR's Checks tab." |
| 102 | + echo "::error::See https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/changelog_updates.md for instructions." |
0 commit comments