Skip to content

Commit 421bca8

Browse files
committed
init
0 parents  commit 421bca8

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

.github/workflows/review.yml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: review
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
pr:
7+
description: "Pull Request Number"
8+
required: true
9+
type: number
10+
x86_64-linux:
11+
description: "Run on x86_64-linux"
12+
required: true
13+
type: boolean
14+
default: true
15+
aarch64-linux:
16+
description: "Run on aarch64-linux"
17+
required: true
18+
type: boolean
19+
default: true
20+
x86_64-darwin:
21+
description: "Run on x86_64-darwin"
22+
required: true
23+
type: boolean
24+
default: true
25+
aarch64-darwin:
26+
description: "Run on aarch64-darwin"
27+
required: true
28+
type: boolean
29+
default: true
30+
post-result:
31+
description: "Post Result"
32+
required: true
33+
type: boolean
34+
default: true
35+
36+
jobs:
37+
review:
38+
strategy:
39+
matrix:
40+
system:
41+
- x86_64-linux
42+
- aarch64-linux
43+
- x86_64-darwin
44+
- aarch64-darwin
45+
exclude:
46+
- system: ${{ !inputs.x86_64-linux && 'x86_64-linux' || '' }}
47+
- system: ${{ !inputs.aarch64-linux && 'aarch64-linux' || '' }}
48+
- system: ${{ !inputs.x86_64-darwin && 'x86_64-darwin' || '' }}
49+
- system: ${{ !inputs.aarch64-darwin && 'aarch64-darwin' || '' }}
50+
fail-fast: false
51+
runs-on: >-
52+
${{ (matrix.system == 'x86_64-linux' && 'ubuntu-latest')
53+
|| (matrix.system == 'aarch64-linux' && 'ubuntu-24.04-arm')
54+
|| (matrix.system == 'x86_64-darwin' && 'macos-13')
55+
|| (matrix.system == 'aarch64-darwin' && 'macos-latest') }}
56+
outputs:
57+
report_x86_64-linux: ${{ steps.report.outputs.report_x86_64-linux }}
58+
report_aarch64-linux: ${{ steps.report.outputs.report_aarch64-linux }}
59+
report_x86_64-darwin: ${{ steps.report.outputs.report_x86_64-darwin }}
60+
report_aarch64-darwin: ${{ steps.report.outputs.report_aarch64-darwin }}
61+
steps:
62+
- name: install nix
63+
uses: DeterminateSystems/nix-installer-action@v16
64+
- name: clone nixpkgs
65+
uses: actions/checkout@v4
66+
with:
67+
repository: NixOS/nixpkgs
68+
- name: run nixpkgs-review
69+
run: nix run .#nixpkgs-review -- pr ${{ inputs.pr }} --no-shell --print-result --build-args="-L"
70+
env:
71+
GITHUB_TOKEN: ${{ github.token }}
72+
- name: generate report
73+
id: report
74+
run: |
75+
sed=$(nix build --no-link --print-out-paths nixpkgs#gnused)/bin/sed
76+
base64=$(nix build --no-link --print-out-paths nixpkgs#coreutils)/bin/base64
77+
echo report_${{ matrix.system }}=$($sed -e '1i\\n---' -e '1,/^---/d' ~/.cache/nixpkgs-review/pr-${{ inputs.pr }}/report.md | $base64 -w0) >> "$GITHUB_OUTPUT"
78+
79+
report:
80+
runs-on: ubuntu-latest
81+
needs: [review]
82+
outputs:
83+
report: ${{ steps.report.outputs.report }}
84+
steps:
85+
- name: generate report
86+
id: report
87+
run: |
88+
cat << EOF > report.md
89+
## \`nixpkgs-review\` result
90+
91+
Generated using [\`nixpkgs-review\`](https://github.com/Mic92/nixpkgs-review).
92+
93+
Command: \`nixpkgs-review pr ${{ inputs.pr }}\`
94+
95+
Logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
96+
EOF
97+
98+
echo ${{ needs.review.outputs.report_x86_64-linux }} | base64 -d >> report.md
99+
echo ${{ needs.review.outputs.report_aarch64-linux }} | base64 -d >> report.md
100+
echo ${{ needs.review.outputs.report_x86_64-darwin }} | base64 -d >> report.md
101+
echo ${{ needs.review.outputs.report_aarch64-darwin }} | base64 -d >> report.md
102+
103+
cat report.md
104+
echo report=$(base64 -w0 report.md) >> "$GITHUB_OUTPUT"
105+
106+
post-result:
107+
runs-on: ubuntu-latest
108+
needs: [report]
109+
if: ${{ inputs.post-result }}
110+
environment: post-result
111+
steps:
112+
- name: fetch report
113+
run: echo ${{ needs.report.outputs.report }} | base64 -d > report.md
114+
- name: post comment
115+
run: gh pr -R EloDef/test comment 1 -F report.md
116+
env:
117+
GH_TOKEN: ${{ secrets.GH_TOKEN }}

0 commit comments

Comments
 (0)