|
| 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 | + tmate: |
| 31 | + description: "Start tmate session after nixpkgs-review" |
| 32 | + required: true |
| 33 | + type: boolean |
| 34 | + default: false |
| 35 | + post-result: |
| 36 | + description: "Post Result" |
| 37 | + required: true |
| 38 | + type: boolean |
| 39 | + default: true |
| 40 | + |
| 41 | +jobs: |
| 42 | + review: |
| 43 | + strategy: |
| 44 | + matrix: |
| 45 | + system: |
| 46 | + - x86_64-linux |
| 47 | + - aarch64-linux |
| 48 | + - x86_64-darwin |
| 49 | + - aarch64-darwin |
| 50 | + exclude: |
| 51 | + - system: ${{ !inputs.x86_64-linux && 'x86_64-linux' || '' }} |
| 52 | + - system: ${{ !inputs.aarch64-linux && 'aarch64-linux' || '' }} |
| 53 | + - system: ${{ !inputs.x86_64-darwin && 'x86_64-darwin' || '' }} |
| 54 | + - system: ${{ !inputs.aarch64-darwin && 'aarch64-darwin' || '' }} |
| 55 | + fail-fast: false |
| 56 | + runs-on: >- |
| 57 | + ${{ (matrix.system == 'x86_64-linux' && 'ubuntu-latest') |
| 58 | + || (matrix.system == 'aarch64-linux' && 'ubuntu-24.04-arm') |
| 59 | + || (matrix.system == 'x86_64-darwin' && 'macos-13') |
| 60 | + || (matrix.system == 'aarch64-darwin' && 'macos-latest') }} |
| 61 | + outputs: |
| 62 | + report_x86_64-linux: ${{ steps.report.outputs.report_x86_64-linux }} |
| 63 | + report_aarch64-linux: ${{ steps.report.outputs.report_aarch64-linux }} |
| 64 | + report_x86_64-darwin: ${{ steps.report.outputs.report_x86_64-darwin }} |
| 65 | + report_aarch64-darwin: ${{ steps.report.outputs.report_aarch64-darwin }} |
| 66 | + steps: |
| 67 | + - name: install nix |
| 68 | + uses: DeterminateSystems/nix-installer-action@v16 |
| 69 | + - name: clone nixpkgs |
| 70 | + uses: actions/checkout@v4 |
| 71 | + with: |
| 72 | + repository: NixOS/nixpkgs |
| 73 | + - name: run nixpkgs-review |
| 74 | + run: nix run .#nixpkgs-review -- pr ${{ inputs.pr }} --no-shell --print-result --build-args="-L" |
| 75 | + env: |
| 76 | + GITHUB_TOKEN: ${{ github.token }} |
| 77 | + - name: start tmate session |
| 78 | + uses: mxschmitt/action-tmate@v3 |
| 79 | + - name: generate report |
| 80 | + id: report |
| 81 | + run: | |
| 82 | + sed=$(nix build --no-link --print-out-paths .#gnused)/bin/sed |
| 83 | + base64=$(nix build --no-link --print-out-paths .#coreutils)/bin/base64 |
| 84 | + echo report_${{ matrix.system }}=$($sed -e '1i\\n---' -e '1,/^---/d' ~/.cache/nixpkgs-review/pr-${{ inputs.pr }}/report.md | $base64 -w0) >> "$GITHUB_OUTPUT" |
| 85 | +
|
| 86 | + report: |
| 87 | + runs-on: ubuntu-latest |
| 88 | + needs: [review] |
| 89 | + outputs: |
| 90 | + report: ${{ steps.report.outputs.report }} |
| 91 | + steps: |
| 92 | + - name: generate report |
| 93 | + id: report |
| 94 | + run: | |
| 95 | + cat << EOF > report.md |
| 96 | + ## \`nixpkgs-review\` result |
| 97 | +
|
| 98 | + Generated using [\`nixpkgs-review\`](https://github.com/Mic92/nixpkgs-review). |
| 99 | +
|
| 100 | + Command: \`nixpkgs-review pr ${{ inputs.pr }}\` |
| 101 | +
|
| 102 | + Logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 103 | + EOF |
| 104 | +
|
| 105 | + echo ${{ needs.review.outputs.report_x86_64-linux }} | base64 -d >> report.md |
| 106 | + echo ${{ needs.review.outputs.report_aarch64-linux }} | base64 -d >> report.md |
| 107 | + echo ${{ needs.review.outputs.report_x86_64-darwin }} | base64 -d >> report.md |
| 108 | + echo ${{ needs.review.outputs.report_aarch64-darwin }} | base64 -d >> report.md |
| 109 | +
|
| 110 | + cat report.md |
| 111 | + echo report=$(base64 -w0 report.md) >> "$GITHUB_OUTPUT" |
| 112 | +
|
| 113 | + post-result: |
| 114 | + runs-on: ubuntu-latest |
| 115 | + needs: [report] |
| 116 | + if: ${{ inputs.post-result }} |
| 117 | + environment: post-result |
| 118 | + steps: |
| 119 | + - name: fetch report |
| 120 | + run: echo ${{ needs.report.outputs.report }} | base64 -d > report.md |
| 121 | + - name: post comment |
| 122 | + run: gh pr -R EloDef/test comment 1 -F report.md |
| 123 | + env: |
| 124 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
0 commit comments