From 01e147381bca8193d3155600edd41a3279372fed Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sat, 18 May 2024 16:21:53 -0300 Subject: [PATCH] Streamline build logic --- .github/workflows/build.yaml | 11 ++++- .github/workflows/checks.yaml | 4 -- .github/workflows/flakehub-cache.yml | 32 ------------- .github/workflows/test.yaml | 70 ++++++++-------------------- 4 files changed, 28 insertions(+), 89 deletions(-) delete mode 100644 .github/workflows/flakehub-cache.yml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0cffe12..a917b3b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,6 +7,9 @@ on: jobs: build-artifacts: runs-on: ${{ matrix.systems.runner }} + env: + CLOSURE_FILE: magic-nix-cache.closure.xz + CLOSURE_KEY: magic-nix-cache-${{ matrix.systems.runner }}-${{ github.sha }} strategy: matrix: systems: @@ -30,12 +33,16 @@ jobs: - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - name: Build package - run: "nix build .# -L --fallback && nix-store --export $(nix-store -qR ./result) | xz -9 > magic-nix-cache.closure.xz" + run: | + # Cache dev shell + nix build .#devShells.${{ matrix.systems.nix-system }} + + nix build .# -L --fallback && nix-store --export $(nix-store -qR ./result) | xz -9 > "${{ env.CLOSURE_FILE }}" - name: Upload a Build Artifact uses: actions/upload-artifact@v3.1.2 with: # Artifact name name: magic-nix-cache-${{ matrix.systems.system }} - path: magic-nix-cache.closure.xz + path: ${{ env.CLOSURE_FILE }} retention-days: 1 diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index a2295da..89acd01 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -28,7 +28,3 @@ jobs: - name: Clippy run: nix develop --command cargo clippy - - build: - uses: ./.github/workflows/build.yaml - secrets: inherit diff --git a/.github/workflows/flakehub-cache.yml b/.github/workflows/flakehub-cache.yml deleted file mode 100644 index c7969de..0000000 --- a/.github/workflows/flakehub-cache.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Push dev shell to FlakeHub Cache - -on: - push: - branches: [main] - -jobs: - push-dev-shell-to-flakehub-cache: - env: - ACTIONS_STEP_DEBUG: true - runs-on: ${{ matrix.systems.runner }} - permissions: - id-token: "write" - contents: "read" - strategy: - matrix: - systems: - - nix-system: "aarch64-darwin" - runner: "macos-latest-xlarge" - - nix-system: "x86_64-darwin" - runner: "macos-12" - - nix-system: "x86_64-linux" - runner: "ubuntu-22.04" - steps: - - uses: actions/checkout@v3 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - with: - use-flakehub: true - - name: Build dev shell for ${{ matrix.systems.nix-system }} on ${{ matrix.systems.runner }} - run: | - nix build .#devShells.${{ matrix.systems.nix-system }}.default diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4dd7d63..aa8887f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,68 +1,36 @@ name: Integration tests on: - pull_request: - push: - branches: [main] + workflow_run: + workflows: ["Build artifacts"] + types: + - completed jobs: - build-closure: - strategy: - matrix: - runner: - - ubuntu-22.04 - - namespace-profile-default-arm64 - - macos-12 - - macos-latest-xlarge - runs-on: ${{ matrix.runner }} - permissions: - contents: read - id-token: write - env: - CLOSURE_FILE: magic-nix-cache.${{ matrix.runner }}.closure.xz - CLOSURE_KEY: magic-nix-cache-${{ matrix.runner }}-${{ github.sha }} - steps: - - uses: actions/checkout@v3 - - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main - - - uses: DeterminateSystems/magic-nix-cache-action@main - - - name: Build package - run: | - nix build .# -L --fallback && \ - nix-store --export $(nix-store -qR ./result) | xz -9 > "${{ env.CLOSURE_FILE }}" - - - name: Cache magix-nix-cache closure - uses: actions/cache/save@v4 - with: - path: ${{ env.CLOSURE_FILE }} - key: ${{ env.CLOSURE_KEY }} - test-magic-nix-cache-action: - needs: build-closure + runs-on: ${{ matrix.systems.runner }} + env: + CLOSURE_FILE: magic-nix-cache-${{ matrix.systems.system }} strategy: matrix: - runner: - - ubuntu-22.04 - - namespace-profile-default-arm64 - - macos-12 - - macos-latest-xlarge - runs-on: ${{ matrix.runner }} + systems: + - system: X64-Linux + runner: ubuntu-22.04 + - system: ARM64-Linux + runner: namespace-profile-default-arm64 + - system: X64-macOS + runner: macos-12 + - system: ARM64-macOS + runner: macos-latest-xlarge permissions: contents: read id-token: write - env: - CLOSURE_FILE: magic-nix-cache.${{ matrix.runner }}.closure.xz - CLOSURE_KEY: magic-nix-cache-${{ matrix.runner }}-${{ github.sha }} steps: - - name: Restore magix-nix-cache closure - uses: actions/cache/restore@v4 + - name: Download artifact + uses: actions/download-artifact@v3 with: + name: ${{ env.CLOSURE_FILE }} path: ${{ env.CLOSURE_FILE }} - key: ${{ env.CLOSURE_KEY }} - fail-on-cache-miss: true - name: Install Nix uses: DeterminateSystems/nix-installer-action@main