-
Notifications
You must be signed in to change notification settings - Fork 20
146 lines (137 loc) · 5.03 KB
/
review.yml
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
143
144
145
146
name: review
run-name: "review #${{ inputs.pr }}"
on:
workflow_dispatch:
inputs:
pr:
description: "Pull Request Number"
required: true
type: string
x86_64-linux:
description: "Run on x86_64-linux"
required: true
type: boolean
default: true
aarch64-linux:
description: "Run on aarch64-linux"
required: true
type: boolean
default: true
x86_64-darwin:
description: "Run on x86_64-darwin"
required: true
type: boolean
default: true
aarch64-darwin:
description: "Run on aarch64-darwin"
required: true
type: boolean
default: true
upstream-eval-timeout:
description: "How long to wait for upstream eval (in seconds)"
required: true
type: number
default: 900
tmate:
description: "Start tmate session after nixpkgs-review"
required: true
type: boolean
default: false
post-result:
description: "Post Result"
required: true
type: boolean
default: true
jobs:
review:
strategy:
matrix:
system:
- x86_64-linux
- aarch64-linux
- x86_64-darwin
- aarch64-darwin
exclude:
- system: ${{ !inputs.x86_64-linux && 'x86_64-linux' || '' }}
- system: ${{ !inputs.aarch64-linux && 'aarch64-linux' || '' }}
- system: ${{ !inputs.x86_64-darwin && 'x86_64-darwin' || '' }}
- system: ${{ !inputs.aarch64-darwin && 'aarch64-darwin' || '' }}
runs-on: >-
${{ (matrix.system == 'x86_64-linux' && 'ubuntu-latest')
|| (matrix.system == 'aarch64-linux' && 'ubuntu-24.04-arm')
|| (matrix.system == 'x86_64-darwin' && 'macos-13')
|| (matrix.system == 'aarch64-darwin' && 'macos-latest') }}
outputs:
report_x86_64-linux: ${{ steps.report.outputs.report_x86_64-linux }}
report_aarch64-linux: ${{ steps.report.outputs.report_aarch64-linux }}
report_x86_64-darwin: ${{ steps.report.outputs.report_x86_64-darwin }}
report_aarch64-darwin: ${{ steps.report.outputs.report_aarch64-darwin }}
steps:
- name: install nix
uses: DeterminateSystems/nix-installer-action@v16
- name: clone nixpkgs
uses: actions/checkout@v4
with:
repository: NixOS/nixpkgs
- name: wait for upstream eval
if: ${{ inputs.upstream-eval-timeout > 0 }}
env:
GH_TOKEN: ${{ github.token }}
run: |
start=$(date +%s)
timeout=${{ inputs.upstream-eval-timeout }}
timeout=${timeout%.*}
while [[ $(( $(date +%s) - $start )) -lt $timeout ]]; do
status=$(gh pr -R nixos/nixpkgs checks ${{ inputs.pr }} --json 'state,name,workflow' -q '.[]|select(.name=="Process" and .workflow=="Eval")|.state')
if [[ -z "$status" ]]; then echo "Failed to find eval check"
else echo "Eval status: ${status}"; fi
if [[ "$status" = "SUCCESS" ]]; then break; fi
sleep 10
done
- name: run nixpkgs-review
run: nix run .#nixpkgs-review -- pr ${{ inputs.pr }} --no-shell --no-headers --print-result --build-args="-L" || true
env:
GITHUB_TOKEN: ${{ github.token }}
- name: start tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ inputs.tmate }}
- name: generate report
id: report
run: |
base64=$(nix build --no-link --print-out-paths .#coreutils)/bin/base64
report=~/.cache/nixpkgs-review/pr-${{ inputs.pr }}/report.md
cat $report
echo report_${{ matrix.system }}=$($base64 -w0 $report) >> "$GITHUB_OUTPUT"
report:
runs-on: ubuntu-latest
needs: [review]
outputs:
report: ${{ steps.report.outputs.report }}
steps:
- name: generate report
id: report
run: |
cat << EOF > report.md
## \`nixpkgs-review\` result
Generated using [\`nixpkgs-review\`](https://github.com/Mic92/nixpkgs-review).
Command: \`nixpkgs-review pr ${{ inputs.pr }}\`
Logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
EOF
echo ${{ needs.review.outputs.report_x86_64-linux }} | base64 -d >> report.md
echo ${{ needs.review.outputs.report_aarch64-linux }} | base64 -d >> report.md
echo ${{ needs.review.outputs.report_x86_64-darwin }} | base64 -d >> report.md
echo ${{ needs.review.outputs.report_aarch64-darwin }} | base64 -d >> report.md
cat report.md
echo report=$(base64 -w0 report.md) >> "$GITHUB_OUTPUT"
post-result:
runs-on: ubuntu-latest
needs: [report]
if: ${{ inputs.post-result }}
environment: post-result
steps:
- name: fetch report
run: echo ${{ needs.report.outputs.report }} | base64 -d > report.md
- name: post comment
run: gh pr -R NixOS/nixpkgs comment ${{ inputs.pr }} -F report.md
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}