Valentin Madrid 2 years ago
parent
commit
c0d5ed6922
1 changed files with 27 additions and 10 deletions
  1. 27 10
      .github/workflows/anchor.yml

+ 27 - 10
.github/workflows/anchor.yml

@@ -10,8 +10,34 @@ env:
   CARGO_TERM_COLOR: always
 
 jobs:
+  setup:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v3
+
+      - name: Cache cargo registry
+        uses: actions/cache@v2
+        with:
+          path: ~/.cargo/registry
+          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
+
+      - name: Cache target
+        uses: actions/cache@v2
+        with:
+          path: target
+          key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
+
+      - name: Install dependencies
+        run: |
+          sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
+          echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
+          cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
+          avm install latest
+          avm use latest
+
   build:
-    name: Build
+    needs: setup
     runs-on: ubuntu-latest
     strategy:
       matrix:
@@ -40,7 +66,6 @@ jobs:
             "tokens/token-2022/basics/anchor",
             "tokens/transfer-tokens/anchor",
           ]
-
     steps:
       - name: Checkout code
         uses: actions/checkout@v3
@@ -57,14 +82,6 @@ jobs:
           path: target
           key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
 
-      - name: Install dependencies
-        run: |
-          sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
-          echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
-          cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
-          avm install latest
-          avm use latest
-
       - name: Build program
         working-directory: ${{ matrix.dir }}
         run: anchor build