Streamline build logic

This commit is contained in:
Luc Perkins 2024-05-18 16:21:53 -03:00
parent cce0d218c8
commit 01e147381b
No known key found for this signature in database
GPG key ID: 16DB1108FB591835
4 changed files with 28 additions and 89 deletions

View file

@ -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

View file

@ -28,7 +28,3 @@ jobs:
- name: Clippy
run: nix develop --command cargo clippy
build:
uses: ./.github/workflows/build.yaml
secrets: inherit

View file

@ -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

View file

@ -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