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: jobs:
build-artifacts: build-artifacts:
runs-on: ${{ matrix.systems.runner }} runs-on: ${{ matrix.systems.runner }}
env:
CLOSURE_FILE: magic-nix-cache.closure.xz
CLOSURE_KEY: magic-nix-cache-${{ matrix.systems.runner }}-${{ github.sha }}
strategy: strategy:
matrix: matrix:
systems: systems:
@ -30,12 +33,16 @@ jobs:
- uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main - uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build package - 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 - name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.2 uses: actions/upload-artifact@v3.1.2
with: with:
# Artifact name # Artifact name
name: magic-nix-cache-${{ matrix.systems.system }} name: magic-nix-cache-${{ matrix.systems.system }}
path: magic-nix-cache.closure.xz path: ${{ env.CLOSURE_FILE }}
retention-days: 1 retention-days: 1

View file

@ -28,7 +28,3 @@ jobs:
- name: Clippy - name: Clippy
run: nix develop --command cargo 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 name: Integration tests
on: on:
pull_request: workflow_run:
push: workflows: ["Build artifacts"]
branches: [main] types:
- completed
jobs: 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: test-magic-nix-cache-action:
needs: build-closure runs-on: ${{ matrix.systems.runner }}
env:
CLOSURE_FILE: magic-nix-cache-${{ matrix.systems.system }}
strategy: strategy:
matrix: matrix:
runner: systems:
- ubuntu-22.04 - system: X64-Linux
- namespace-profile-default-arm64 runner: ubuntu-22.04
- macos-12 - system: ARM64-Linux
- macos-latest-xlarge runner: namespace-profile-default-arm64
runs-on: ${{ matrix.runner }} - system: X64-macOS
runner: macos-12
- system: ARM64-macOS
runner: macos-latest-xlarge
permissions: permissions:
contents: read contents: read
id-token: write id-token: write
env:
CLOSURE_FILE: magic-nix-cache.${{ matrix.runner }}.closure.xz
CLOSURE_KEY: magic-nix-cache-${{ matrix.runner }}-${{ github.sha }}
steps: steps:
- name: Restore magix-nix-cache closure - name: Download artifact
uses: actions/cache/restore@v4 uses: actions/download-artifact@v3
with: with:
name: ${{ env.CLOSURE_FILE }}
path: ${{ env.CLOSURE_FILE }} path: ${{ env.CLOSURE_FILE }}
key: ${{ env.CLOSURE_KEY }}
fail-on-cache-miss: true
- name: Install Nix - name: Install Nix
uses: DeterminateSystems/nix-installer-action@main uses: DeterminateSystems/nix-installer-action@main