瀏覽代碼

Pre-scaffold projects in CI for caching purposes

Loris Leiva 1 年之前
父節點
當前提交
2572d3a15e
共有 2 個文件被更改,包括 23 次插入18 次删除
  1. 6 4
      .github/workflows/main.yml
  2. 17 14
      scripts/snapshot.mjs

+ 6 - 4
.github/workflows/main.yml

@@ -41,6 +41,12 @@ jobs:
         with:
           node-version: 18
           cache: "pnpm"
+      - name: Install Solana
+        uses: metaplex-foundation/actions/install-solana@v1
+        with:
+          version: ${{ matrix.solana }}
+      - name: Pre-scaffold projects for caching purposes
+        run: pnpm snapshot --scaffold-only
       - name: Cache cargo crates
         uses: actions/cache@v4
         with:
@@ -54,10 +60,6 @@ jobs:
           key: ${{ runner.os }}-solana@${{ matrix.solana }}-${{ hashFiles('./projects/**/Cargo.lock') }}
           restore-keys: |
             ${{ runner.os }}-solana@${{ matrix.solana }}
-      - name: Install Solana
-        uses: metaplex-foundation/actions/install-solana@v1
-        with:
-          version: ${{ matrix.solana }}
       - name: Install dependencies
         run: pnpm install --frozen-lockfile
       - name: Build and run tests

+ 17 - 14
scripts/snapshot.mjs

@@ -13,6 +13,7 @@ const projects =
       )
     : Object.keys(PROJECTS);
 const runTests = !!argv.test;
+const scaffoldOnly = !!argv['scaffold-only'];
 
 // Resolve paths.
 const bin = path.resolve(__dirname, '../outfile.cjs');
@@ -36,6 +37,8 @@ for (const projectName of projects) {
     () => $`node ${[bin, ...args, '--force', '--default']}`
   );
 
+  if (scaffoldOnly) continue;
+
   // Go inside the created project.
   const projectDirectory = path.resolve(projectsDirectory, projectName);
   cd(projectDirectory);
@@ -67,21 +70,21 @@ for (const projectName of projects) {
     });
   }
 
-  if (runTests) {
-    // Test programs.
-    if ('programs:test' in pkg.scripts) {
-      await executeStep('test programs', async () => {
-        await $`pnpm programs:test`;
-      });
-    }
+  if (!runTests) continue;
 
-    // Test clients.
-    for (const client of CLIENTS) {
-      if (`clients:${client}:test` in pkg.scripts) {
-        await executeStep(`test ${client} clients`, async () => {
-          await $`pnpm clients:${client}:test`;
-        });
-      }
+  // Test programs.
+  if ('programs:test' in pkg.scripts) {
+    await executeStep('test programs', async () => {
+      await $`pnpm programs:test`;
+    });
+  }
+
+  // Test clients.
+  for (const client of CLIENTS) {
+    if (`clients:${client}:test` in pkg.scripts) {
+      await executeStep(`test ${client} clients`, async () => {
+        await $`pnpm clients:${client}:test`;
+      });
     }
   }