diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/deploy.sh similarity index 76% rename from .gitea/workflows/test.yml rename to .gitea/workflows/deploy.sh index e84e158..cd6143f 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/deploy.sh @@ -8,15 +8,13 @@ on: - '*.*.*' jobs: build-deploy-ubuntu: - env: - RUNNER_TOOL_CACHE: /toolcache # Is it a risk to Ouroboros this? # Really want this to be able to run on ubuntu but it is a slow run. runs-on: ubuntu-latest # runs-on: nix-runner steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # Fetch all history for tags - name: Install Nix @@ -58,22 +56,36 @@ jobs: run: | nix develop -c bash scripts/deploy.sh nix-check: - env: - RUNNER_TOOL_CACHE: /toolcache runs-on: nix-runner steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: 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 uses: ryanccn/attic-action@3354ae812cb672e1381be4c7914204c44db53866 with: endpoint: ${{ secrets.ATTIC_ENDPOINT }} cache: ${{ secrets.ATTIC_CACHE }} 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 run: nix build .#act-runner-image - name: Check Nix flake run: nix 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 diff --git a/scripts/populate_cache.sh b/scripts/populate_cache.sh new file mode 100755 index 0000000..3877450 --- /dev/null +++ b/scripts/populate_cache.sh @@ -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