ci: update compare regex #576
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on: | |
# https://github.com/cuties-social/cuties-social-nixfiles/blob/14593a3014c32ce121529009d8d6564e45dd7e99/.github/workflows/build.yml | |
name: Build | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash -euo pipefail {0} | |
concurrency: | |
group: ${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
env: | |
PR_JOB_SUMMARY: pr-job-summary | |
strategy: | |
matrix: | |
machine: | |
- host: framework | |
platform: x86-64-linux | |
runner: ubuntu-24.04 | |
type: nixosConfigurations | |
- host: cm3588 | |
platform: aarch64-linux | |
runner: ubuntu-24.04-arm | |
type: nixosConfigurations | |
- host: nodejs | |
platform: x86-64-linux | |
runner: ubuntu-24.04 | |
type: devShells.x86_64-linux | |
runs-on: ${{ matrix.machine.runner }} | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Free up disk space | |
# Increased disk usage on arm | |
if: matrix.machine.platform == 'x86-64-linux' | |
uses: easimon/maximize-build-space@fc881a613ad2a34aca9c9624518214ebc21dfc0c # v10 | |
with: | |
overprovision-lvm: true | |
remove-android: true | |
remove-codeql: true | |
remove-docker-images: true | |
remove-dotnet: true | |
remove-haskell: true | |
- name: Checkout repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Install Nix | |
uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16 | |
with: | |
source-tag: v0.32.3 | |
- name: Set up GitHub Actions cache | |
uses: DeterminateSystems/magic-nix-cache-action@6221693898146dc97e38ad0e013488a16477a4c4 # v9 | |
- name: Set up public cache | |
uses: cachix/cachix-action@ad2ddac53f961de1989924296a1f236fcfbaa4fc # v15 | |
with: | |
name: tlvince-nixos-config | |
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
- name: Run flake check | |
# All configurations are checked by default, so just run it in one | |
# matrix build | |
if: matrix.machine.host == 'framework' | |
run: | | |
CHECK_OUTPUT="${RUNNER_TEMP}/flake-check-output" | |
nix flake check --no-build | tee "$CHECK_OUTPUT" | |
[[ -s $CHECK_OUTPUT ]] || echo "No issues found by 'nix flake check'." > "$CHECK_OUTPUT" | |
echo -e "## Flake check\n\`\`\`\n$(<$CHECK_OUTPUT)\n\`\`\`" | tee -a "$GITHUB_STEP_SUMMARY" "${RUNNER_TEMP}/${PR_JOB_SUMMARY}" >/dev/null | |
- name: Build | |
run: | | |
OUT_PATH="$(nix build .#${{ matrix.machine.type }}.${{ matrix.machine.host }}${{ matrix.machine.type == 'nixosConfigurations' && '.config.system.build.toplevel' || ''}} --print-out-paths)" | |
echo -e "\x1b[32;1mSuccessfully built .#${{ matrix.machine.type}}.${{ matrix.machine.host }}\x1b[0m" | |
echo -e "## Build ${{ matrix.machine.host }}\n\`$OUT_PATH\`" | tee -a "$GITHUB_STEP_SUMMARY" "${RUNNER_TEMP}/${PR_JOB_SUMMARY}" >/dev/null | |
- name: Diff closures | |
if: github.event_name == 'pull_request' && matrix.machine.type == 'nixosConfigurations' | |
run: | | |
HOST_DRV="nixosConfigurations.${{ matrix.machine.host }}.config.system.build.toplevel" | |
PREV_FLAKE="github:${GITHUB_REPOSITORY}" | |
NEXT_FLAKE="." | |
DIFF_OUTPUT="${RUNNER_TEMP}/nix-store-diff-closures-output" | |
nix store diff-closures "${PREV_FLAKE}#${HOST_DRV}" "${NEXT_FLAKE}#${HOST_DRV}" | tee "$DIFF_OUTPUT" | |
[[ -s "$DIFF_OUTPUT" ]] && sed -i 's/\x1b\[[0-9;]*m//g' "$DIFF_OUTPUT" || echo "No changes found" | tee "$DIFF_OUTPUT" | |
echo -e "## Closures difference\n\`\`\`\n$(<$DIFF_OUTPUT)\n\`\`\`" | tee -a "$GITHUB_STEP_SUMMARY" "${RUNNER_TEMP}/${PR_JOB_SUMMARY}" >/dev/null | |
- name: Add job summary to PR | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
if: github.event_name == 'pull_request' | |
with: | |
script: | | |
const { readFile } = require('node:fs/promises') | |
const comment = require('.github/scripts/comment') | |
const header = '# ${{ matrix.machine.host }}' | |
const body = await readFile('${{ runner.temp }}/${{ env.PR_JOB_SUMMARY }}', { encoding: 'utf8' }) | |
await comment({ github, context, header, body }) |