Skip to content

Commit 8b84880

Browse files
[Backport release-24.11] workflows/{pr,push}: init (#417826)
2 parents 6ce6e47 + ca70494 commit 8b84880

File tree

10 files changed

+126
-100
lines changed

10 files changed

+126
-100
lines changed

.github/workflows/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Thus, it is important how to construct the group keys:
2929

3030
- We don't want workflows of different Pull Requests to cancel each other, so we include `github.event.pull_request.number`. The [GitHub docs](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs#example-using-a-fallback-value) show using `github.head_ref` for this purpose, but this doesn't work well with forks: Different users could have the same head branch name in their forks and run CI for their PRs at the same time.
3131

32-
- Sometimes, there is no `pull_request.number`. That's the case for `push` or `workflow_run` events. To ensure non-PR runs are never cancelled, we add a fallback of `github.run_id`. This is a unique value for each workflow run.
32+
- Sometimes, there is no `pull_request.number`. To ensure non-PR runs are never cancelled, we add a fallback of `github.run_id`. This is a unique value for each workflow run.
3333

3434
- Of course, we run multiple workflows at the same time, so we add `github.workflow` to the key. Otherwise workflows would cancel each other.
3535

.github/workflows/build.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
name: Build
22

33
on:
4-
pull_request:
5-
paths:
6-
- .github/workflows/build.yml
7-
pull_request_target:
8-
9-
concurrency:
10-
group: build-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
11-
cancel-in-progress: true
4+
workflow_call:
5+
secrets:
6+
CACHIX_AUTH_TOKEN:
7+
required: true
128

139
permissions: {}
1410

.github/workflows/check.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
name: Check
22

33
on:
4-
pull_request:
5-
paths:
6-
- .github/workflows/check.yml
7-
pull_request_target:
8-
9-
concurrency:
10-
group: check-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
11-
cancel-in-progress: true
4+
workflow_call:
125

136
permissions: {}
147

.github/workflows/eval-aliases.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/eval.yml

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
name: Eval
22

33
on:
4-
pull_request:
5-
paths:
6-
- .github/workflows/eval.yml
7-
- .github/workflows/reviewers.yml # needs eval results from the same event type
8-
pull_request_target:
9-
push:
10-
# Keep this synced with ci/request-reviews/dev-branches.txt
11-
branches:
12-
- master
13-
- staging
14-
- release-*
15-
- staging-*
16-
- haskell-updates
17-
- python-updates
18-
19-
concurrency:
20-
group: eval-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
21-
cancel-in-progress: true
4+
workflow_call:
5+
secrets:
6+
OWNER_APP_PRIVATE_KEY:
7+
required: false
228

239
permissions: {}
2410

@@ -28,7 +14,6 @@ defaults:
2814

2915
jobs:
3016
prepare:
31-
name: Prepare
3217
runs-on: ubuntu-24.04-arm
3318
outputs:
3419
mergedSha: ${{ steps.get-merge-commit.outputs.mergedSha }}
@@ -49,14 +34,14 @@ jobs:
4934
run: |
5035
echo "systems=$(jq -c <ci/supportedSystems.json)" >> "$GITHUB_OUTPUT"
5136
52-
outpaths:
53-
name: Outpaths
37+
eval:
5438
runs-on: ubuntu-24.04-arm
5539
needs: [prepare]
5640
strategy:
5741
fail-fast: false
5842
matrix:
5943
system: ${{ fromJSON(needs.prepare.outputs.systems) }}
44+
name: ${{ matrix.system }}
6045
steps:
6146
- name: Enable swap
6247
run: |
@@ -109,12 +94,12 @@ jobs:
10994
run_id = (await github.rest.actions.listWorkflowRuns({
11095
owner: context.repo.owner,
11196
repo: context.repo.repo,
112-
workflow_id: 'eval.yml',
97+
workflow_id: 'push.yml',
11398
event: 'push',
11499
head_sha: targetSha
115100
})).data.workflow_runs[0].id
116101
} catch {
117-
throw new Error(`Could not find an eval.yml workflow run for ${targetSha}.`)
102+
throw new Error(`Could not find an push.yml workflow run for ${targetSha}.`)
118103
}
119104
120105
core.setOutput('targetRunId', run_id)
@@ -161,9 +146,8 @@ jobs:
161146
path: diff/*
162147

163148
compare:
164-
name: Comparison
165149
runs-on: ubuntu-24.04-arm
166-
needs: [prepare, outpaths]
150+
needs: [prepare, eval]
167151
if: needs.prepare.outputs.targetSha
168152
permissions:
169153
issues: write # needed to create *new* labels
@@ -262,7 +246,32 @@ jobs:
262246
# No dependency on "compare", so that it can start at the same time.
263247
# We only wait for the "comparison" artifact to be available, which makes the start-to-finish time
264248
# for the eval workflow considerably faster.
265-
needs: [prepare, outpaths]
249+
needs: [prepare, eval]
266250
if: needs.prepare.outputs.targetSha
267251
uses: ./.github/workflows/reviewers.yml
268-
secrets: inherit
252+
secrets:
253+
OWNER_APP_PRIVATE_KEY: ${{ secrets.OWNER_APP_PRIVATE_KEY }}
254+
255+
misc:
256+
if: ${{ github.event_name != 'push' }}
257+
runs-on: ubuntu-24.04-arm
258+
steps:
259+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
260+
with:
261+
sparse-checkout: .github/actions
262+
- name: Check if the PR can be merged and checkout the merge commit
263+
uses: ./.github/actions/get-merge-commit
264+
with:
265+
merged-as-untrusted: true
266+
267+
- name: Install Nix
268+
uses: cachix/install-nix-action@17fe5fb4a23ad6cbbe47d6b3f359611ad276644c # v31
269+
with:
270+
extra_nix_config: sandbox = true
271+
272+
- name: Ensure flake outputs on all systems still evaluate
273+
run: nix flake check --all-systems --no-build ./untrusted
274+
275+
- name: Query nixpkgs with aliases enabled to check for basic syntax errors
276+
run: |
277+
time nix-env -I ./untrusted -f ./untrusted -qa '*' --option restrict-eval true --option allow-import-from-derivation false >/dev/null

.github/workflows/labels.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# access to the GitHub API. This means that it should not evaluate user input in
44
# a way that allows code injection.
55

6-
name: "Label PR"
6+
name: Labels
77

88
on:
99
schedule:
@@ -33,8 +33,7 @@ defaults:
3333
shell: bash
3434

3535
jobs:
36-
labels:
37-
name: label-pr
36+
update:
3837
runs-on: ubuntu-24.04-arm
3938
if: github.event_name != 'schedule' || github.repository_owner == 'NixOS'
4039
steps:
@@ -147,7 +146,7 @@ jobs:
147146
148147
const run_id = (await github.rest.actions.listWorkflowRuns({
149148
...context.repo,
150-
workflow_id: 'eval.yml',
149+
workflow_id: 'pr.yml',
151150
event: 'pull_request_target',
152151
// For PR events, the workflow run is still in progress with this job itself.
153152
status: prEventCondition ? 'in_progress' : 'success',

.github/workflows/lint.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
name: Lint
22

33
on:
4-
pull_request:
5-
paths:
6-
- .github/workflows/lint.yml
7-
pull_request_target:
8-
9-
concurrency:
10-
group: lint-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
11-
cancel-in-progress: true
4+
workflow_call:
125

136
permissions: {}
147

.github/workflows/pr.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/build.yml
7+
- .github/workflows/check.yml
8+
- .github/workflows/eval.yml
9+
- .github/workflows/lint.yml
10+
- .github/workflows/pr.yml
11+
- .github/workflows/reviewers.yml # needs eval results from the same event type
12+
pull_request_target:
13+
14+
concurrency:
15+
group: pr-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
16+
cancel-in-progress: true
17+
18+
permissions: {}
19+
20+
jobs:
21+
check:
22+
name: Check
23+
uses: ./.github/workflows/check.yml
24+
permissions:
25+
# cherry-picks
26+
pull-requests: write
27+
28+
lint:
29+
name: Lint
30+
uses: ./.github/workflows/lint.yml
31+
32+
eval:
33+
name: Eval
34+
uses: ./.github/workflows/eval.yml
35+
permissions:
36+
# compare
37+
issues: write
38+
pull-requests: write
39+
statuses: write
40+
secrets:
41+
OWNER_APP_PRIVATE_KEY: ${{ secrets.OWNER_APP_PRIVATE_KEY }}
42+
43+
build:
44+
name: Build
45+
uses: ./.github/workflows/build.yml
46+
secrets:
47+
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

.github/workflows/push.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Push
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/push.yml
7+
# eval is tested via pr.yml
8+
push:
9+
# Keep this synced with ci/request-reviews/dev-branches.txt
10+
branches:
11+
- master
12+
- staging
13+
- release-*
14+
- staging-*
15+
- haskell-updates
16+
- python-updates
17+
18+
permissions: {}
19+
20+
jobs:
21+
eval:
22+
name: Eval
23+
uses: ./.github/workflows/eval.yml
24+
# Those are not actually used on push, but will throw an error if not set.
25+
permissions:
26+
# compare
27+
issues: write
28+
pull-requests: write
29+
statuses: write

.github/workflows/reviewers.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
pull_request_target:
1111
types: [ready_for_review]
1212
workflow_call:
13+
secrets:
14+
OWNER_APP_PRIVATE_KEY:
15+
required: true
1316

1417
concurrency:
1518
group: reviewers-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
@@ -23,7 +26,6 @@ defaults:
2326

2427
jobs:
2528
request:
26-
name: Request
2729
runs-on: ubuntu-24.04-arm
2830
steps:
2931
- name: Check out the PR at the base commit
@@ -63,7 +65,7 @@ jobs:
6365
const run_id = (await github.rest.actions.listWorkflowRuns({
6466
owner: context.repo.owner,
6567
repo: context.repo.repo,
66-
workflow_id: 'eval.yml',
68+
workflow_id: 'pr.yml',
6769
event: context.eventName,
6870
head_sha: context.payload.pull_request.head.sha
6971
})).data.workflow_runs[0].id

0 commit comments

Comments
 (0)