Browse Source

feat: add nix cache to ci (#949)

* feat: add nix cache to ci

* feat: shared caches
thesimplekid 2 months ago
parent
commit
b48604e02c
2 changed files with 57 additions and 1 deletions
  1. 52 0
      .github/workflows/ci.yml
  2. 5 1
      .github/workflows/nutshell_itest.yml

+ 52 - 0
.github/workflows/ci.yml

@@ -21,8 +21,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "nightly"
       - name: Cargo fmt
         run: |
           nix develop -i -L .#nightly --command bash -c '
@@ -53,8 +57,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "stable"
       - name: Run example
         run: nix develop -i -L .#stable --command cargo r --example ${{ matrix.build-args }}
 
@@ -135,8 +143,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "stable"
       - name: Clippy
         run: nix develop -i -L .#stable --command cargo clippy ${{ matrix.build-args }} -- -D warnings
       - name: Test
@@ -162,8 +174,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "stable"
       - name: Test
         run: nix develop -i -L .#stable --command just itest ${{ matrix.database }}
           
@@ -187,8 +203,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "stable"
       - name: Clippy
         run: nix develop -i -L .#stable --command cargo clippy -- -D warnings
       - name: Test fake auth mint
@@ -212,8 +232,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "stable"
       - name: Test fake mint
         run: nix develop -i -L .#stable --command just test-pure ${{ matrix.database }}
       - name: Test mint
@@ -238,8 +262,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "stable"
       - name: Test
         run: nix develop -i -L .#stable --command just itest-payment-processor ${{matrix.ln}}
 
@@ -274,8 +302,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "msrv"
       - name: Build
         run: nix develop -i -L .#msrv --command cargo build ${{ matrix.build-args }}
 
@@ -302,8 +334,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "stable"
       - name: Build cdk and binding
         run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo build ${{ matrix.build-args }} --target ${{ matrix.target }}
 
@@ -330,8 +366,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "msrv"
       - name: Build cdk wasm
         run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo build ${{ matrix.build-args }} --target ${{ matrix.target }}
 
@@ -351,8 +391,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "stable"
       - name: Start Keycloak with Backup
         run: |
           docker compose -f misc/keycloak/docker-compose-recover.yml up -d
@@ -377,8 +421,12 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "stable"
       - name: Run doc tests
         run: nix develop -i -L .#stable --command cargo test --doc
         
@@ -392,7 +440,11 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
+        with:
+          shared-key: "stable"
       - name: Check docs with strict warnings
         run: nix develop -i -L .#stable --command just docs-strict

+ 5 - 1
.github/workflows/nutshell_itest.yml

@@ -12,6 +12,8 @@ jobs:
         uses: actions/checkout@v4
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
       - name: Test Nutshell
@@ -31,6 +33,8 @@ jobs:
         run: docker pull cashubtc/nutshell:latest
       - name: Install Nix
         uses: DeterminateSystems/nix-installer-action@v17
+      - name: Nix Cache
+        uses: DeterminateSystems/magic-nix-cache-action@main
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2
       - name: Test Nutshell Wallet
@@ -38,4 +42,4 @@ jobs:
           nix develop -i -L .#integration --command just nutshell-wallet-itest
       - name: Show Docker logs if tests fail
         if: failure()
-        run: docker logs nutshell-wallet || true
+        run: docker logs nutshell-wallet || true