From 66317827ea6ad51df347e6c5f3da4579c0acdc35 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sat, 18 May 2024 17:21:03 -0300 Subject: [PATCH] Some final cleanup --- .github/workflows/build.yaml | 28 ++++++++++++++------------- .github/workflows/check-and-test.yaml | 20 +++++++++---------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3f3b885..32403b5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,9 +7,12 @@ on: jobs: build-artifacts: runs-on: ${{ matrix.systems.runner }} + permissions: + contents: read + id-token: write env: - CLOSURE_NAME: magic-nix-cache-${{ matrix.systems.system }} - ARCHIVE: magic-nix-cache.closure.xz + ARTIFACT_KEY: magic-nix-cache-${{ matrix.systems.system }} + ARCHIVE_NAME: magic-nix-cache.closure.xz strategy: matrix: systems: @@ -25,27 +28,26 @@ jobs: - nix-system: aarch64-darwin system: ARM64-macOS runner: macos-latest-xlarge - permissions: - contents: read - id-token: write steps: - uses: actions/checkout@v3 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Install Nix on ${{ matrix.systems.system }} + uses: DeterminateSystems/nix-installer-action@main + - name: Magic Nix Cache + uses: DeterminateSystems/magic-nix-cache-action@main - - name: Build and cache dev shell + - name: Build and cache dev shell for ${{ matrix.systems.nix-system }} run: | nix build ".#devShells.${{ matrix.systems.nix-system }}.default" - - name: Build package and create closure + - name: Build package and create closure for ${{ matrix.systems.system }} run: | nix build .# -L --fallback && \ - nix-store --export $(nix-store -qR ./result) | xz -9 > "${{ env.ARCHIVE }}" + nix-store --export $(nix-store -qR ./result) | xz -9 > "${{ env.ARCHIVE_NAME }}" - - name: Upload a Build Artifact + - name: Upload magic-nix-cache closure for ${{ matrix.systems.system }} uses: actions/upload-artifact@v3.1.2 with: # Artifact name - name: ${{ env.CLOSURE_NAME }} - path: ${{ env.ARCHIVE }} + name: ${{ env.ARTIFACT_KEY }} + path: ${{ env.ARCHIVE_NAME }} retention-days: 1 diff --git a/.github/workflows/check-and-test.yaml b/.github/workflows/check-and-test.yaml index 3a5bb6f..d1a2ad0 100644 --- a/.github/workflows/check-and-test.yaml +++ b/.github/workflows/check-and-test.yaml @@ -41,9 +41,8 @@ jobs: runs-on: ${{ matrix.systems.runner }} needs: build env: - CLOSURE_NAME: magic-nix-cache-${{ matrix.systems.system }} - CLOSURE_PATH: magic-nix-cache - ARCHIVE: magic-nix-cache.closure.xz + ARTIFACT_KEY: magic-nix-cache-${{ matrix.systems.system }} + ARCHIVE_NAME: magic-nix-cache.closure.xz strategy: matrix: systems: @@ -59,25 +58,26 @@ jobs: contents: read id-token: write steps: - - name: Download artifact + - name: Download closure for ${{ matrix.systems.system }} uses: actions/download-artifact@v3 with: - name: ${{ env.CLOSURE_NAME }} - path: ${{ env.CLOSURE_PATH }} + name: ${{ env.ARTIFACT_KEY }} + path: ${{ env.ARTIFACT_KEY }} - - name: Install Nix + - name: Install Nix on ${{ matrix.systems.system }} uses: DeterminateSystems/nix-installer-action@main - - name: Extract + - name: Extract closure for ${{ matrix.systems.system }} id: extract run: | - ARTIFACT="${{ env.CLOSURE_PATH }}/${{ env.ARCHIVE }}" + ARTIFACT="${{ env.ARTIFACT_KEY }}/${{ env.ARCHIVE_NAME }}" OUTPUT=$(cat ${ARTIFACT} | xz -d | nix-store --import) MNC_BIN_PATH=$(echo "${OUTPUT}" | tail -n 1) MAGIC_NIX_CACHE="${MNC_BIN_PATH}/bin/magic-nix-cache" echo "mnc-path=${MAGIC_NIX_CACHE}" >> "$GITHUB_OUTPUT" - - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Test magic-nix-cache-action@main on ${{ matrix.systems.runner }} + uses: DeterminateSystems/magic-nix-cache-action@main with: source-binary: "${{ steps.extract.outputs.mnc-path }}"