Split some services to new hosts #3625
Workflow file for this run
This file contains hidden or 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
| name: Build and test flake outputs | |
| on: | |
| pull_request: | |
| push: | |
| branches: [master] | |
| workflow_dispatch: | |
| workflow_call: | |
| permissions: | |
| contents: read | |
| jobs: | |
| generate-matrix: | |
| runs-on: self-hosted | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Generate Matrix | |
| id: set-matrix | |
| # Do not update until https://github.com/workflow/nix-shell-action/issues/364 is fixed. | |
| uses: workflow/nix-shell-action@v4.0.0 | |
| with: | |
| flakes: nixpkgs#jq,nixpkgs#nushell | |
| script: | | |
| SCRIPT_ARGS="--json" | |
| if [[ -n "${{ github.event.before }}" ]]; then | |
| SCRIPT_ARGS+=" --range ${{ github.event.before }}..${{ github.sha }}" | |
| else | |
| SCRIPT_ARGS+=" $(find . -type f | sed 's|^\./||' | grep -v '^\.git/' | tr '\n' ' ')" | |
| fi | |
| CHANGED_HOSTS=$(./flake/ci/detect-affected-outputs.nu nixosConfigurations $SCRIPT_ARGS | jq 'to_entries | map("nixosConfigurations." + .key + ".config.system.build.toplevel")' ) | |
| CHANGED_USERS=$(./flake/ci/detect-affected-outputs.nu homeConfigurations $SCRIPT_ARGS | jq 'to_entries | map("homeConfigurations." + .key + ".activationPackage")' ) | |
| EXTRA_SPACE='["nixmi"]' | |
| NO_BUILD='["nixmi"]' | |
| { | |
| echo 'matrix<<EOF' | |
| jq -n --argjson hosts "$CHANGED_HOSTS" --argjson users "$CHANGED_USERS" \ | |
| --argjson rule_extra_space "$EXTRA_SPACE" \ | |
| --argjson rule_no_build "$NO_BUILD" ' | |
| ($hosts + $users) | map({ | |
| attr: ., | |
| system: "x86_64-linux", | |
| extraSpace: IN($rule_extra_space[]; (. | split(".")[1])), | |
| noBuild: IN($rule_no_build[]; (. | split(".")[1])) | |
| })' 2>/dev/null || echo "[]" | |
| echo EOF | |
| } >> "$GITHUB_OUTPUT" | |
| build-outputs: | |
| needs: generate-matrix | |
| if: needs.generate-matrix.outputs.matrix != '[]' | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.attr }}-${{ matrix.system }} | |
| cancel-in-progress: true | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} | |
| name: Build ${{ matrix.attr }} on ${{ matrix.system }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Free Disk Space | |
| if: ${{ matrix.extraSpace && !env.ACT }} | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| swap-storage: true | |
| tool-cache: true | |
| - name: Create Dir for Mounting more Disk Space ❄ | |
| if: ${{ matrix.extraSpace && !env.ACT }} | |
| run: sudo mkdir /nix | |
| - name: Maximize Disk Space | |
| if: ${{ matrix.extraSpace && !env.ACT }} | |
| uses: easimon/maximize-build-space@v10 | |
| with: | |
| build-mount-path: /nix | |
| remove-dotnet: true | |
| remove-android: true | |
| remove-haskell: true | |
| remove-codeql: true | |
| remove-docker-images: true | |
| temp-reserve-mb: 100 | |
| swap-size-mb: 4096 | |
| root-reserve-mb: 1024 | |
| - name: Ensure correct permissions for /nix | |
| if: ${{ matrix.extraSpace && !env.ACT }} | |
| run: sudo chown -R root:root /nix | |
| - uses: ./.github/actions/setup-nix | |
| with: | |
| arch: ${{ matrix.system }} | |
| TS_OAUTH_CLIENT_ID: ${{ secrets.TS_OAUTH_CLIENT_ID }} | |
| TS_OAUTH_SECRET: ${{ secrets.TS_OAUTH_SECRET }} | |
| ATTIC_ENDPOINT: ${{ secrets.ATTIC_ENDPOINT }} | |
| ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }} | |
| ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }} | |
| - name: Evaluate ${{ matrix.attr }} | |
| env: | |
| _system: ${{ matrix.system }} | |
| run: nix eval --accept-flake-config .#${{ matrix.attr }} | |
| - name: Build ${{ matrix.attr }} | |
| if: ${{ !matrix.noBuild }} | |
| env: | |
| _system: ${{ matrix.system }} | |
| run: nix build --accept-flake-config .#${{ matrix.attr }} |