ci: Try caching in the nix build
This commit is contained in:
@@ -8,15 +8,13 @@ on:
|
|||||||
- '*.*.*'
|
- '*.*.*'
|
||||||
jobs:
|
jobs:
|
||||||
build-deploy-ubuntu:
|
build-deploy-ubuntu:
|
||||||
env:
|
|
||||||
RUNNER_TOOL_CACHE: /toolcache
|
|
||||||
# Is it a risk to Ouroboros this?
|
# Is it a risk to Ouroboros this?
|
||||||
# Really want this to be able to run on ubuntu but it is a slow run.
|
# Really want this to be able to run on ubuntu but it is a slow run.
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# runs-on: nix-runner
|
# runs-on: nix-runner
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Fetch all history for tags
|
fetch-depth: 0 # Fetch all history for tags
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
@@ -58,22 +56,36 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
nix develop -c bash scripts/deploy.sh
|
nix develop -c bash scripts/deploy.sh
|
||||||
nix-check:
|
nix-check:
|
||||||
env:
|
|
||||||
RUNNER_TOOL_CACHE: /toolcache
|
|
||||||
runs-on: nix-runner
|
runs-on: nix-runner
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Fetch all history for tags
|
fetch-depth: 0 # Fetch all history for tags
|
||||||
|
- name: "Cache Nix store"
|
||||||
|
uses: actions/cache@v4
|
||||||
|
id: nix-cache
|
||||||
|
with:
|
||||||
|
path: /tmp/nixcache
|
||||||
|
key: nix-${{ runner.os }}-nix-builder-image-${{ hashFiles('**/package.json', 'package-lock.json', '**/*.nix', '**/flake.lock', '.npmrc', '.eleventy.js') }}
|
||||||
|
restore-keys: |
|
||||||
|
nix-${{ runner.os }}-nix-builder-image
|
||||||
- name: Setup Attic Cache
|
- name: Setup Attic Cache
|
||||||
uses: ryanccn/attic-action@3354ae812cb672e1381be4c7914204c44db53866
|
uses: ryanccn/attic-action@3354ae812cb672e1381be4c7914204c44db53866
|
||||||
with:
|
with:
|
||||||
endpoint: ${{ secrets.ATTIC_ENDPOINT }}
|
endpoint: ${{ secrets.ATTIC_ENDPOINT }}
|
||||||
cache: ${{ secrets.ATTIC_CACHE }}
|
cache: ${{ secrets.ATTIC_CACHE }}
|
||||||
token: ${{ secrets.ATTIC_TOKEN }}
|
token: ${{ secrets.ATTIC_TOKEN }}
|
||||||
|
- name: "Import Nix store cache"
|
||||||
|
continue-on-error: true
|
||||||
|
# if: "steps.nix-cache.outputs.cache-hit == 'true'"
|
||||||
|
run: bash scripts/restore_cache.sh
|
||||||
- name: Build container
|
- name: Build container
|
||||||
run: nix build .#act-runner-image
|
run: nix build .#act-runner-image
|
||||||
- name: Check Nix flake
|
- name: Check Nix flake
|
||||||
run: nix flake check
|
run: nix flake check
|
||||||
id: flake-check
|
id: flake-check
|
||||||
|
- name: "Export Nix store cache"
|
||||||
|
if: always()
|
||||||
|
# if: "steps.nix-cache.outputs.cache-hit != 'true'"
|
||||||
|
run: bash scripts/populate_cache.sh
|
||||||
38
scripts/populate_cache.sh
Executable file
38
scripts/populate_cache.sh
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuox pipefail
|
||||||
|
|
||||||
|
CACHE_PATH=${CACHE_PATH:-"/tmp/nixcache"}
|
||||||
|
|
||||||
|
banner() {
|
||||||
|
echo "========================================================"
|
||||||
|
echo " $*"
|
||||||
|
echo "========================================================"
|
||||||
|
}
|
||||||
|
|
||||||
|
banner "List what we start with"
|
||||||
|
|
||||||
|
nix-store --query --requisites --include-outputs "$(nix eval .\#devShells.x86_64-linux.default.drvPath --raw)" >dependencies.txt
|
||||||
|
nix-store --query --requisites --include-outputs "$(nix eval .\#packages.x86_64-linux.default.drvPath --raw)" >>dependencies.txt
|
||||||
|
# nix-store --query --requisites --include-outputs "$(nix eval .\#checks.x86_64-linux.formatting.drvPath --raw)" >>dependencies.txt
|
||||||
|
# nix-store --query --requisites --include-outputs "$(nix eval .\#checks.x86_64-linux.test-check.drvPath --raw)" >>dependencies.txt
|
||||||
|
nix-store --query --requisites --include-outputs "$(nix eval .\#formatter.x86_64-linux.drvPath --raw)" >>dependencies.txt
|
||||||
|
|
||||||
|
sort -o dependencies.txt -u dependencies.txt
|
||||||
|
|
||||||
|
banner "list obtained paths to cache"
|
||||||
|
|
||||||
|
wc -l dependencies.txt
|
||||||
|
|
||||||
|
banner "filter out our matches"
|
||||||
|
|
||||||
|
echo "Using filter"
|
||||||
|
cat scripts/populate_cache_exclude_patterns.txt
|
||||||
|
|
||||||
|
grep -vf scripts/populate_cache_exclude_patterns.txt dependencies.txt >filtered_dependencies.txt
|
||||||
|
|
||||||
|
echo "Count our filtered"
|
||||||
|
wc -l filtered_dependencies.txt
|
||||||
|
|
||||||
|
xargs <filtered_dependencies.txt -r nix copy --to "file://${CACHE_PATH}" --no-substitute
|
||||||
|
|
||||||
|
banner "done with populating cache"
|
||||||
0
scripts/populate_cache_exclude_patterns.txt
Normal file
0
scripts/populate_cache_exclude_patterns.txt
Normal file
16
scripts/restore_cache.sh
Normal file
16
scripts/restore_cache.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
CACHE_PATH=${CACHE_PATH:-"/tmp/nixcache"}
|
||||||
|
|
||||||
|
banner() {
|
||||||
|
echo "========================================================"
|
||||||
|
echo " $*"
|
||||||
|
echo "========================================================"
|
||||||
|
}
|
||||||
|
|
||||||
|
# banner "List what we start with"
|
||||||
|
# ls -alh "${CACHE_PATH}"
|
||||||
|
|
||||||
|
banner "Copy time"
|
||||||
|
nix copy --from "file://${CACHE_PATH}" --no-check-sigs --all
|
||||||
Reference in New Issue
Block a user