Skip to content

Commit

Permalink
Upload mac ARM build artifacts to cachix (#96)
Browse files Browse the repository at this point in the history
For the Mac Arm self-hosted runners, cachix is already installed.
Instead of using the cachix-install action, which uses bash to execute
commands, we add our own scripts that use zsh to do upload the build
artifacts to cachix after building.
  • Loading branch information
sdankel authored Aug 16, 2023
1 parent 33afadc commit 1c2e8ed
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ jobs:
strategy:
fail-fast: false
matrix:
package: [fuel, fuel-beta-1, fuel-beta-2, fuel-beta-3, fuel-beta-4-rc, fuel-nightly, sway-vim]
package:
[
fuel,
fuel-beta-1,
fuel-beta-2,
fuel-beta-3,
fuel-beta-4-rc,
fuel-nightly,
sway-vim,
]
os: [ubuntu-latest, macos-latest, macos-arm]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
# Since the self-hosted runners already have nix and cachix installed, we skip these steps.
- if: matrix.os != 'macos-arm'
uses: cachix/install-nix-action@v22
with:
Expand All @@ -42,7 +52,15 @@ jobs:
with:
name: fuellabs
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
# Copy the nix store to a tmp directory for later comparison.
- if: matrix.os == 'macos-arm'
run: ./script/list-nix-store.sh > /tmp/store-path-pre-build
- run: nix build --print-build-logs --no-update-lock-file .#${{ matrix.package }}
# Since we skipped the cachix action, we must manually update the cachix cache.
- if: matrix.os == 'macos-arm'
env:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
run: ./script/cachix-push-paths.sh

nix-develop:
needs: nix-build
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/refresh-manifests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "refresh-manifests"
name: 'refresh-manifests'

on:
schedule:
Expand Down Expand Up @@ -36,7 +36,15 @@ jobs:
strategy:
fail-fast: false
matrix:
package: [fuel, fuel-beta-1, fuel-beta-2, fuel-beta-3, fuel-beta-4-rc, fuel-nightly]
package:
[
fuel,
fuel-beta-1,
fuel-beta-2,
fuel-beta-3,
fuel-beta-4-rc,
fuel-nightly,
]
os: [ubuntu-latest, macos-latest, macos-arm]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -48,6 +56,7 @@ jobs:
path: manifests/
- name: stage manifests for nix build
run: git add -v manifests
# Since the self-hosted runners already have nix and cachix installed, we skip these steps.
- if: matrix.os != 'macos-arm'
uses: cachix/install-nix-action@v22
with:
Expand All @@ -57,7 +66,15 @@ jobs:
with:
name: fuellabs
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
# Copy the nix store to a tmp directory for later comparison.
- if: matrix.os == 'macos-arm'
run: ./script/list-nix-store.sh > /tmp/store-path-pre-build
- run: nix build --print-build-logs --no-update-lock-file .#${{ matrix.package }}
# Since we skipped the cachix action, we must manually update the cachix cache.
- if: matrix.os == 'macos-arm'
env:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
run: ./script/cachix-push-paths.sh

download-manifests-and-commit:
needs: [refresh-and-upload-manifests, download-manifests-and-nix-build]
Expand Down
8 changes: 8 additions & 0 deletions script/cachix-push-paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env zsh
set -euo pipefail

# Based on https://github.com/cachix/cachix-action/blob/master/dist/main/push-paths.sh

pathsToPush=$(comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh))

echo "$pathsToPush" | cachix push "fuellabs"
29 changes: 29 additions & 0 deletions script/list-nix-store.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env zsh
# Small utility to replace `nix path-info --all`
set -euo pipefail

# Borrowed from https://github.com/cachix/cachix-action/blob/master/dist/main/list-nix-store.sh

for file in /nix/store/*; do
case "$file" in
*.drv)
# Avoid .drv as they are not generally useful
continue
;;
*.drv.chroot)
# Avoid .drv.chroot as they are not generally useful
continue
;;
*.check)
# Skip .check file produced by --keep-failed
continue
;;
*.lock)
# Skip .lock files
continue
;;
*)
echo "$file"
;;
esac
done

0 comments on commit 1c2e8ed

Please sign in to comment.