Skip to content

Commit 27be06f

Browse files
committed
Add workflow to regenerate required checks
Update contributing guide. Ensure this workflow runs once a week.
1 parent 0235de0 commit 27be06f

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
# This job updates the required checks on the codeql-action repository based on the
3+
# checks performed on the most recent commit.
4+
5+
name: Update required checks
6+
on:
7+
schedule:
8+
# 23:01 on Saturdays
9+
- cron: "1 23 * * 6"
10+
workflow_dispatch:
11+
12+
jobs:
13+
update-required-checks:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Dump environment
17+
run: env
18+
19+
- name: Dump GitHub context
20+
env:
21+
GITHUB_CONTEXT: '${{ toJson(github) }}'
22+
run: echo "$GITHUB_CONTEXT"
23+
24+
- name: Update checks
25+
run: |
26+
# Update the required checks based on the current branch.
27+
# Typically, this will be main.
28+
SHA="$(git rev-parse HEAD)"
29+
echo "Getting checks for $SHA"
30+
31+
# Ignore any checks with "https://", CodeQL, LGTM, and Update checks.
32+
CHECKS="$(gh api repos/github/codeql-action/commits/${SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or contains("Update") | not)] | sort')"
33+
34+
echo "::group::New Checks"
35+
echo "$CHECKS" | jq
36+
echo "::endgroup::"
37+
38+
echo "{\"contexts\": ${CHECKS}}" > checks.json
39+
echo "Updating main"
40+
gh api -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json
41+
echo "Updating v2"
42+
gh api -X "PATCH" repos/github/codeql-action/branches/releases/v2/protection/required_status_checks --input checks.json
43+
echo "Updating v1"
44+
gh api -X "PATCH" repos/github/codeql-action/branches/releases/v1/protection/required_status_checks --input checks.json

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ Here are a few things you can do that will increase the likelihood of your pull
8080

8181
## Keeping the PR checks up to date (admin access required)
8282

83-
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred jobs that need to pass in order for a PR to turn green. Managing these PR checks manually is time consuming and complex. Here is a semi-automated approach.
83+
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred jobs that need to pass in order for a PR to turn green. You can regenerate the checks automatically by running the [Update required checks](.github/workflows/update-required-checks.yml) workflow.
8484

85-
To regenerate the PR jobs for the action:
85+
Or you can use this semi-automated approach:
8686

8787
1. From a terminal, run the following commands (replace `SHA` with the sha of the commit whose checks you want to use, typically this should be the latest from `main`):
8888

0 commit comments

Comments
 (0)