Selaa lähdekoodia

chore: update turbo config

This commit cleans up and updates the turbo config so that:

1. Tests and fixes can run on the [root
   package](https://turbo.build/repo/docs/crafting-your-repository/configuring-tasks#registering-root-tasks),
   e.g. to format or lint any files that don't exist inside a workspace package
2. More config is shared and we don't have as much config scoped to individual
   packages
3. `pnpm install` automatically runs at the right times (i.e. you don't have to
   manually run an install ever)
Connor Prussin 8 kuukautta sitten
vanhempi
sitoutus
8a05757929

+ 1 - 1
.github/workflows/ci-turbo-test.yml

@@ -33,4 +33,4 @@ jobs:
       - name: Cache for Turbo
         uses: rharkor/caching-for-turbo@v1.5
       - name: Test
-        run: pnpm test:ci
+        run: pnpm turbo test

+ 0 - 16
apps/api-reference/turbo.json

@@ -3,27 +3,11 @@
   "extends": ["//"],
   "tasks": {
     "build": {
-      "dependsOn": ["pull:env", "^build"],
-      "outputs": [".next/**", "!.next/cache/**"],
       "env": [
         "WALLETCONNECT_PROJECT_ID",
         "AMPLITUDE_API_KEY",
         "GOOGLE_ANALYTICS_ID"
       ]
-    },
-    "pull:env": {
-      "outputs": [".env.local"],
-      "cache": false
-    },
-    "start:dev": {
-      "dependsOn": ["pull:env"],
-      "persistent": true,
-      "cache": false
-    },
-    "start:prod": {
-      "dependsOn": ["build"],
-      "persistent": true,
-      "cache": false
     }
   }
 }

+ 0 - 19
apps/entropy-debugger/turbo.json

@@ -1,19 +0,0 @@
-{
-  "$schema": "https://turbo.build/schema.json",
-  "extends": ["//"],
-  "tasks": {
-    "build": {
-      "dependsOn": ["^build"],
-      "outputs": [".next/**", "!.next/cache/**"]
-    },
-    "start:dev": {
-      "persistent": true,
-      "cache": false
-    },
-    "start:prod": {
-      "dependsOn": ["build"],
-      "persistent": true,
-      "cache": false
-    }
-  }
-}

+ 4 - 3
apps/hermes/client/js/README.md

@@ -76,11 +76,12 @@ The [HermesClient](./src/examples/HermesClient.ts) example demonstrates both the
 examples above. To run the example:
 
 1. Clone [the Pyth monorepo](https://github.com/pyth-network/pyth-crosschain)
-2. In the root of the monorepo, run `pnpm example:hermes-client -- <args>`. For
-   example, to print BTC and ETH price feeds in the testnet network, run:
+2. In the root of the monorepo, run `pnpm turbo --filter
+   @pythnetwork/hermes-client example -- <args>`. For example, to print BTC and
+   ETH price feeds in the testnet network, run:
 
 ```bash
-pnpm example:hermes-client -- \
+pnpm turbo --filter @pythnetwork/hermes-client example -- \
   --endpoint https://hermes.pyth.network \
   --price-ids \
     0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43 \

+ 4 - 3
apps/hermes/client/js/turbo.json

@@ -3,22 +3,23 @@
   "extends": ["//"],
   "tasks": {
     "build:schemas": {
-      "dependsOn": ["pull:schema"],
+      "dependsOn": ["//#install:modules", "pull:schema"],
       "inputs": ["schema.json"],
       "outputs": ["src/zodSchemas.ts"]
     },
     "build:typescript": {
-      "dependsOn": ["build:schemas", "^build"],
+      "dependsOn": ["//#install:modules", "build:schemas", "^build"],
       "outputs": ["lib/**"]
     },
     "build": {
       "dependsOn": ["build:typescript", "build:schemas"]
     },
     "example": {
-      "dependsOn": ["build"],
+      "dependsOn": ["//#install:modules", "build"],
       "cache": false
     },
     "pull:schema": {
+      "dependsOn": ["//#install:modules"],
       "outputs": ["schema.json"],
       "cache": false
     }

+ 11 - 21
apps/insights/turbo.json

@@ -3,8 +3,6 @@
   "extends": ["//"],
   "tasks": {
     "build": {
-      "dependsOn": ["pull:env", "^build"],
-      "outputs": [".next/**", "!.next/cache/**"],
       "env": [
         "VERCEL_ENV",
         "GOOGLE_ANALYTICS_ID",
@@ -17,36 +15,28 @@
       ]
     },
     "fix:lint": {
-      "dependsOn": ["fix:lint:eslint", "fix:lint:stylelint"],
-      "cache": false
+      "dependsOn": [
+        "//#install:modules",
+        "fix:lint:eslint",
+        "fix:lint:stylelint"
+      ]
     },
     "fix:lint:eslint": {
-      "dependsOn": ["^build"],
+      "dependsOn": ["//#install:modules", "^build"],
       "cache": false
     },
     "fix:lint:stylelint": {
-      "cache": false
-    },
-    "pull:env": {
-      "outputs": [".env.local"],
-      "cache": false
-    },
-    "start:dev": {
-      "dependsOn": ["pull:env"],
-      "persistent": true,
-      "cache": false
-    },
-    "start:prod": {
-      "dependsOn": ["build"],
-      "persistent": true,
+      "dependsOn": ["//#install:modules"],
       "cache": false
     },
     "test:lint": {
       "dependsOn": ["test:lint:eslint", "test:lint:stylelint"]
     },
     "test:lint:eslint": {
-      "dependsOn": ["^build"]
+      "dependsOn": ["//#install:modules", "^build"]
     },
-    "test:lint:stylelint": {}
+    "test:lint:stylelint": {
+      "dependsOn": ["//#install:modules"]
+    }
   }
 }

+ 2 - 14
apps/staking/turbo.json

@@ -3,8 +3,6 @@
   "extends": ["//"],
   "tasks": {
     "build": {
-      "dependsOn": ["pull:env", "^build"],
-      "outputs": [".next/**", "!.next/cache/**"],
       "env": [
         "IP_ALLOWLIST",
         "GOVERNANCE_ONLY_REGIONS",
@@ -17,23 +15,13 @@
         "GOOGLE_ANALYTICS_ID"
       ]
     },
-    "pull:env": {
-      "outputs": [".env.local"],
-      "cache": false
-    },
     "start:dev": {
       "dependsOn": [
+        "//#install:modules",
         "pull:env",
         "@pythnetwork/hermes-client#build",
         "@pythnetwork/solana-utils#build"
-      ],
-      "persistent": true,
-      "cache": false
-    },
-    "start:prod": {
-      "dependsOn": ["build"],
-      "persistent": true,
-      "cache": false
+      ]
     }
   }
 }

+ 3 - 3
flake.nix

@@ -18,7 +18,7 @@
           cli = prev.lib.mkCli "cli" {
             _noAll = true;
 
-            start = "${prev.lib.getExe prev.pnpm} start:dev";
+            start = "${prev.lib.getExe prev.pnpm} turbo start:dev";
 
             test = {
               nix = {
@@ -26,7 +26,7 @@
                 dead-code = "${prev.deadnix}/bin/deadnix --exclude ./node_modules .";
                 format = "${prev.alejandra}/bin/alejandra --exclude ./node_modules --check .";
               };
-              turbo = "${prev.lib.getExe prev.pnpm} test -- --ui stream";
+              turbo = "${prev.lib.getExe prev.pnpm} turbo test -- --ui stream";
             };
 
             fix = {
@@ -35,7 +35,7 @@
                 dead-code = "${prev.deadnix}/bin/deadnix --exclude ./node_modules -e .";
                 format = "${prev.alejandra}/bin/alejandra --exclude ./node_modules .";
               };
-              turbo = "${prev.lib.getExe prev.pnpm} fix -- --ui stream";
+              turbo = "${prev.lib.getExe prev.pnpm} turbo fix -- --ui stream";
             };
           };
         };

+ 1 - 14
governance/xc_admin/packages/xc_admin_frontend/turbo.json

@@ -3,27 +3,14 @@
   "extends": ["//"],
   "tasks": {
     "build": {
-      "dependsOn": ["pull:env", "^build"],
-      "outputs": [".next/**", "!.next/cache/**"],
       "env": [
         "BUILD_STANDALONE",
         "NEXT_PUBLIC_MAINNET_RPC",
         "NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID"
       ]
     },
-    "pull:env": {
-      "outputs": [".env.local"],
-      "cache": false
-    },
     "start:dev": {
-      "dependsOn": ["pull:env", "^build"],
-      "persistent": true,
-      "cache": false
-    },
-    "start:prod": {
-      "dependsOn": ["build"],
-      "persistent": true,
-      "cache": false
+      "dependsOn": ["//#install:modules", "pull:env", "^build"]
     }
   }
 }

+ 0 - 3
lazer/contracts/solana/turbo.json

@@ -2,9 +2,6 @@
   "$schema": "https://turbo.build/schema.json",
   "extends": ["//"],
   "tasks": {
-    "test": {
-      "dependsOn": ["test:format"]
-    },
     "test:anchor": {}
   }
 }

+ 4 - 6
package.json

@@ -8,13 +8,11 @@
   },
   "scripts": {
     "build:ci": "turbo build --filter=!./apps/api-reference --filter=!./apps/insights --filter=!./apps/staking",
-    "example:hermes-client": "pnpm i && turbo example --filter @pythnetwork/hermes-client --ui stream",
-    "fix": "pnpm i && turbo fix",
+    "fix:format": "prettier --write .",
+    "install:modules": "[ $CI ] && true || pnpm install",
     "publish": "lerna publish from-package --no-private --no-git-tag-version --yes",
-    "start:dev": "pnpm i && turbo start:dev",
-    "start:prod": "pnpm i && turbo start:prod",
-    "test": "pnpm i && turbo test",
-    "test:ci": "turbo test"
+    "test:format": "prettier --check .",
+    "turbo": "[ ! -d node_modules ] && pnpm install; turbo"
   },
   "devDependencies": {
     "@cprussin/prettier-config": "^2.2.1",

+ 11 - 9
packages/component-library/turbo.json

@@ -6,26 +6,28 @@
       "outputs": ["storybook-static/**"]
     },
     "fix:lint": {
-      "dependsOn": ["fix:lint:eslint", "fix:lint:stylelint"],
-      "cache": false
+      "dependsOn": [
+        "//#install:modules",
+        "fix:lint:eslint",
+        "fix:lint:stylelint"
+      ]
     },
     "fix:lint:eslint": {
-      "dependsOn": ["^build"],
+      "dependsOn": ["//#install:modules", "^build"],
       "cache": false
     },
     "fix:lint:stylelint": {
-      "cache": false
-    },
-    "start:dev": {
-      "persistent": true,
+      "dependsOn": ["//#install:modules"],
       "cache": false
     },
     "test:lint": {
       "dependsOn": ["test:lint:eslint", "test:lint:stylelint"]
     },
     "test:lint:eslint": {
-      "dependsOn": ["^build"]
+      "dependsOn": ["//#install:modules", "^build"]
     },
-    "test:lint:stylelint": {}
+    "test:lint:stylelint": {
+      "dependsOn": ["//#install:modules"]
+    }
   }
 }

+ 2 - 0
target_chains/ethereum/sdk/solidity/turbo.json

@@ -3,9 +3,11 @@
   "extends": ["//"],
   "tasks": {
     "build:abis": {
+      "dependsOn": ["//#install:modules"],
       "outputs": ["abis/**"]
     },
     "build:bin": {
+      "dependsOn": ["//#install:modules"],
       "outputs": ["build/**"]
     },
     "build": {

+ 100 - 9
turbo.json

@@ -1,10 +1,64 @@
 {
   "$schema": "https://turbo.build/schema.json",
   "globalEnv": ["NODE_ENV"],
+  "globalPassThroughEnv": ["COREPACK_HOME"],
   "ui": "tui",
   "tasks": {
+    "//#fix": {
+      "dependsOn": ["//#fix:lint", "//#fix:format"],
+      "cache": false
+    },
+    "//#fix:format": {
+      "dependsOn": ["//#install:modules", "//#fix:lint"],
+      "cache": false
+    },
+    "//#fix:lint": {
+      "dependsOn": ["//#install:modules", "^build"],
+      "cache": false
+    },
+    "//#install:modules": {
+      "inputs": [
+        "**/package.json",
+        ".npmrc",
+        ".npmignore",
+        "pnpm-workspace.yaml",
+        "!**/.next/**",
+        "!**/dist/**"
+      ],
+      "outputs": ["pnpm-lock.yaml"]
+    },
+    "//#test": {
+      "dependsOn": [
+        "//#test:types",
+        "//#test:unit",
+        "//#test:integration",
+        "//#test:format",
+        "//#test:lint"
+      ]
+    },
+    "//#test:format": {
+      "dependsOn": ["//#install:modules"]
+    },
+    "//#test:lint": {
+      "dependsOn": ["//#install:modules", "^build"]
+    },
+    "//#test:types": {
+      "dependsOn": ["//#install:modules", "^build"]
+    },
+    "//#test:unit": {
+      "dependsOn": ["//#install:modules", "^build"]
+    },
+    "//#test:integration": {
+      "dependsOn": ["//#install:modules", "^build"]
+    },
     "build": {
-      "dependsOn": ["^build", "build:cjs", "build:esm"],
+      "dependsOn": [
+        "//#install:modules",
+        "pull:env",
+        "^build",
+        "build:cjs",
+        "build:esm"
+      ],
       "inputs": [
         "$TURBO_DEFAULT$",
         "!README.md",
@@ -14,12 +68,32 @@
         "!prettier.config.js",
         "!vercel.json"
       ],
-      "outputs": ["dist/**", "lib/**"]
+      "outputs": ["lib/**", "dist/**", ".next/**", "!.next/cache/**"]
     },
     "build:cjs": {
+      "dependsOn": ["//#install:modules"],
+      "inputs": [
+        "$TURBO_DEFAULT$",
+        "!README.md",
+        "!**/*.test.*",
+        "!jest.config.js",
+        "!eslint.config.js",
+        "!prettier.config.js",
+        "!vercel.json"
+      ],
       "outputs": ["dist/cjs/**"]
     },
     "build:esm": {
+      "dependsOn": ["//#install:modules"],
+      "inputs": [
+        "$TURBO_DEFAULT$",
+        "!README.md",
+        "!**/*.test.*",
+        "!jest.config.js",
+        "!eslint.config.js",
+        "!prettier.config.js",
+        "!vercel.json"
+      ],
       "outputs": ["dist/esm/**"]
     },
     "fix": {
@@ -27,11 +101,26 @@
       "cache": false
     },
     "fix:format": {
-      "dependsOn": ["fix:lint"],
+      "dependsOn": ["//#install:modules", "fix:lint"],
       "cache": false
     },
     "fix:lint": {
-      "dependsOn": ["^build"],
+      "dependsOn": ["//#install:modules", "^build"],
+      "cache": false
+    },
+    "pull:env": {
+      "dependsOn": ["//#install:modules"],
+      "outputs": [".env.local"],
+      "cache": false
+    },
+    "start:dev": {
+      "dependsOn": ["//#install:modules", "pull:env"],
+      "persistent": true,
+      "cache": false
+    },
+    "start:prod": {
+      "dependsOn": ["//#install:modules", "build"],
+      "persistent": true,
       "cache": false
     },
     "test": {
@@ -43,18 +132,20 @@
         "test:lint"
       ]
     },
-    "test:format": {},
+    "test:format": {
+      "dependsOn": ["//#install:modules"]
+    },
     "test:lint": {
-      "dependsOn": ["^build"]
+      "dependsOn": ["//#install:modules", "^build"]
     },
     "test:types": {
-      "dependsOn": ["^build"]
+      "dependsOn": ["//#install:modules", "^build"]
     },
     "test:unit": {
-      "dependsOn": ["^build"]
+      "dependsOn": ["//#install:modules", "^build"]
     },
     "test:integration": {
-      "dependsOn": ["^build"]
+      "dependsOn": ["//#install:modules", "^build"]
     }
   }
 }