From c50978b961f0f84474eb4736267634b912c34589 Mon Sep 17 00:00:00 2001 From: Gabriel Simmer Date: Tue, 15 Aug 2023 23:31:33 +0100 Subject: [PATCH] Caching --- .gitea/workflows/test-build.yml | 64 +++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/test-build.yml b/.gitea/workflows/test-build.yml index 6a51495..729d633 100644 --- a/.gitea/workflows/test-build.yml +++ b/.gitea/workflows/test-build.yml @@ -9,7 +9,15 @@ jobs: runs-on: debian-latest steps: - name: Install prerequisites - run: apt update && apt install -y sudo + run: apt update && apt install -y sudo zstd + + - name: "Cache Nix store" + uses: actions/cache@v3.0.8 + id: nix-cache + with: + path: /tmp/nixcache + key: "dref-cache-v1" + - name: Install Nix uses: https://github.com/cachix/install-nix-action@v22 with: @@ -17,20 +25,37 @@ jobs: nix_path: nixpkgs=channel:nixos-23.05 - name: Remove access_tokens run: sed -i '/^access-tokens/d' /etc/nix/nix.conf + + - name: "Import Nix store cache" + if: "steps.nix-cache.outputs.cache-hit == 'true'" + run: "nix-store --import < /tmp/nixcache" + - name: Check out repository - uses: https://github.com/RouxAntoine/checkout@v3.5.4 + uses: actions/checkout@v3.5.3 with: ref: trunk - name: Check codebase run: nix flake check -L + - name: "Export Nix store cache" + if: "steps.nix-cache.outputs.cache-hit != 'true'" + run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache" + docker-build: needs: nix-flake-check runs-on: debian-latest steps: - name: Install prerequisites - run: apt update && apt install -y sudo + run: apt update && apt install -y sudo zstd + + - name: "Cache Nix store" + uses: actions/cache@v3.0.8 + id: nix-cache + with: + path: /tmp/nixcache + key: "dref-cache-v1" + - name: Install Nix uses: https://github.com/cachix/install-nix-action@v22 with: @@ -38,8 +63,13 @@ jobs: nix_path: nixpkgs=channel:nixos-23.05 - name: Remove access_tokens run: sed -i '/^access-tokens/d' /etc/nix/nix.conf + + - name: "Import Nix store cache" + if: "steps.nix-cache.outputs.cache-hit == 'true'" + run: "nix-store --import < /tmp/nixcache" + - name: Check out repository - uses: https://github.com/RouxAntoine/checkout@v3.5.4 + uses: actions/checkout@v3.5.3 with: ref: trunk - name: Build image @@ -50,12 +80,25 @@ jobs: wget https://raw.githubusercontent.com/containers/skopeo/main/default-policy.json && mkdir /etc/containers && mv default-policy.json /etc/containers/policy.json skopeo copy docker-archive:result docker://icr.gmem.ca/dref:latest + - name: "Export Nix store cache" + if: "steps.nix-cache.outputs.cache-hit != 'true'" + run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache" + + arm-docker-build: needs: nix-flake-check runs-on: debian-latest-arm steps: - name: Install prerequisites - run: apt update && apt install -y sudo + run: apt update && apt install -y sudo zstd + + - name: "Cache Nix store" + uses: actions/cache@v3.0.8 + id: nix-cache + with: + path: /tmp/nixcache + key: "dref-cache-arm-v1" + - name: Install Nix uses: https://github.com/cachix/install-nix-action@v22 with: @@ -63,8 +106,13 @@ jobs: nix_path: nixpkgs=channel:nixos-23.05 - name: Remove access_tokens run: sed -i '/^access-tokens/d' /etc/nix/nix.conf + + - name: "Import Nix store cache" + if: "steps.nix-cache.outputs.cache-hit == 'true'" + run: "nix-store --import < /tmp/nixcache" + - name: Check out repository - uses: https://github.com/RouxAntoine/checkout@v3.5.4 + uses: actions/checkout@v3.5.3 with: ref: trunk - name: Build image @@ -74,3 +122,7 @@ jobs: nix-env -i skopeo -f '' wget https://raw.githubusercontent.com/containers/skopeo/main/default-policy.json && mkdir /etc/containers && mv default-policy.json /etc/containers/policy.json skopeo copy docker-archive:result docker://icr.gmem.ca/dref:arm + + - name: "Export Nix store cache" + if: "steps.nix-cache.outputs.cache-hit != 'true'" + run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"