From c0bdf963ef9a6979ba4e2ca2df20779a22bc1f75 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 3 Sep 2026 19:05:38 +0200 Subject: [PATCH 1/2] move SDK into symlink, drop force from installation path --- CLAUDE.md | 2 +- README.md | 32 ++++++++------------------------ package.json | 2 +- rebuild.sh | 2 +- scripts/README.md | 15 +++------------ yarn.lock | 12 +++--------- 6 files changed, 17 insertions(+), 48 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 13a1b7caf..86ec6b110 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -298,7 +298,7 @@ External programs required for tests. These are pre-compiled `.so` files in `tes **"blockstore error"**: `rm -rf .anchor/test-ledger test-ledger` -**Module resolution errors**: `cd sdk && yarn build-local && cd .. && yarn install --force` +**Module resolution errors**: `cd sdk && yarn build-local` (the root `node_modules` entry is a symlink to `sdk/`, so no root reinstall is needed) **Tests timeout**: Increase `startup_wait` in `Anchor.toml` diff --git a/README.md b/README.md index d14e0bcc3..3aee5b7cf 100644 --- a/README.md +++ b/README.md @@ -125,38 +125,23 @@ Reload your shell configuration: source ~/.zshrc # or source ~/.bash_profile ``` -#### 7. Install Dependencies +#### 7. Build Programs and Install Dependencies -Install root project dependencies: +Build all programs, install and build the SDK, install the root dependencies, and lint in one step: ```bash -yarn install +./rebuild.sh ``` -Install SDK dependencies and build: +Re-run `./rebuild.sh` after changing program or SDK code so tests run against your latest changes. -```bash -cd sdk -yarn install -yarn build-local -cd .. -``` - -#### 8. Build Programs - -Build all Solana programs: - -```bash -anchor build -``` - -Or build a specific program: +To build a single program on its own: ```bash -anchor build -p programs +anchor build -p futarchy ``` -#### 9. Run Tests +#### 8. Run Tests Run all tests: @@ -184,13 +169,12 @@ Then run `anchor test` again. #### "Cannot find module" errors -If you see module resolution errors, rebuild the SDK: +If you see module resolution errors, rebuild the SDK. The root `node_modules` entry for `@metadaoproject/programs` is a symlink to `sdk/`, so no root reinstall is needed: ```bash cd sdk yarn build-local cd .. -yarn install --force ``` #### Tests timeout or validator doesn't start diff --git a/package.json b/package.json index 6a7dd00b9..72d7b887a 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@inquirer/prompts": "7.9.0", "@ledgerhq/hw-app-solana": "7.10.4", "@ledgerhq/hw-transport-node-hid": "6.33.4", - "@metadaoproject/programs": "./sdk", + "@metadaoproject/programs": "link:./sdk", "@metaplex-foundation/mpl-token-metadata": "3.4.0", "@metaplex-foundation/umi": "0.9.2", "@metaplex-foundation/umi-bundle-defaults": "0.9.2", diff --git a/rebuild.sh b/rebuild.sh index 953ae8e22..d4c4daab7 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -6,6 +6,6 @@ cd sdk yarn install yarn build-local cd .. -yarn install --force +yarn install yarn lint:fix echo "✅ rebuild complete" \ No newline at end of file diff --git a/scripts/README.md b/scripts/README.md index 325a5bf71..b9bf77a65 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -4,22 +4,13 @@ A collection of scripts to interact with various parts of the futarchy protocol ## Setup -It's best to use these scripts with the latest build of the SDK. - -To do this, run the following commands, starting in the root dir of the repository: +The scripts import `@metadaoproject/programs` from the root `node_modules`, where it is a symlink to `sdk/`, so they always run against your local SDK build. No linking is needed. From the root of the repository: ```sh -cd sdk # Move into the repository dir - -yarn -yarn build -yarn link - -cd .. # Move back into the root dir -yarn link @metadaoproject/futarchy # Link to your local build of the futarchy sdk +./rebuild.sh ``` -Afterwards, you can run the scripts as you see fit. +This builds the programs, installs and builds the SDK, and installs the root dependencies. See [Development Setup](../README.md#development-setup) in the main README for toolchain prerequisites. If the programs are already built and you only changed SDK code, `cd sdk && yarn build-local` is enough. ## Launchpad diff --git a/yarn.lock b/yarn.lock index 56dad3081..7a0c3f06d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -933,15 +933,9 @@ resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-6.17.0.tgz#370840b915a0b44fc867fc4e6afc68d26a2055dd" integrity sha512-yra33g5q/AU7+PwAws+GaVpQGUuxnDREjVBnviJjcaJLVKuLzI4pnj8Bd3nY3fypM5k1yZEYKEXfUuGFUjP2+w== -"@metadaoproject/programs@./sdk": - version "0.1.1-alpha.0" - dependencies: - "@coral-xyz/anchor" "0.29.0" - "@noble/hashes" "1.8.0" - "@solana/spl-token" "0.3.11" - "@solana/web3.js" "1.98.4" - "@sqds/multisig" "2.1.4" - bn.js "5.2.2" +"@metadaoproject/programs@link:./sdk": + version "0.0.0" + uid "" "@metaplex-foundation/beet-solana@0.4.0": version "0.4.0" From b89f005419f03f357b2748b300fbda08a9483e88 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 3 Sep 2026 20:08:05 +0200 Subject: [PATCH 2/2] fix repo guard --- .github/workflows/repo-guard.yml | 42 ++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/.github/workflows/repo-guard.yml b/.github/workflows/repo-guard.yml index ce1069a0d..464d1e753 100644 --- a/.github/workflows/repo-guard.yml +++ b/.github/workflows/repo-guard.yml @@ -40,11 +40,7 @@ jobs: node-version: '20.18.0' cache: 'yarn' - - name: Verify root yarn.lock is up to date - id: yarn_root - continue-on-error: true - run: yarn install --frozen-lockfile --ignore-scripts --non-interactive - + # sdk first: the root install links `link:./sdk` and needs sdk/node_modules to exist. - name: Verify sdk yarn.lock is up to date id: yarn_sdk continue-on-error: true @@ -52,6 +48,12 @@ jobs: cd sdk yarn install --frozen-lockfile --ignore-scripts --non-interactive + - name: Verify root yarn.lock is up to date + id: yarn_root + continue-on-error: true + if: steps.yarn_sdk.outcome == 'success' + run: yarn install --frozen-lockfile --ignore-scripts --non-interactive + - name: Run repository guard checks id: guard continue-on-error: true @@ -83,24 +85,26 @@ jobs: echo " - Out of sync with the workspace manifests. Run \`cargo update --workspace\` (or rebuild) and commit the updated \`Cargo.lock\`." fi - if [ "$YARN_ROOT_OUTCOME" = "success" ]; then - echo "- yarn.lock (root): pass" - else - echo "- yarn.lock (root): fail" - echo " - Root \`yarn.lock\` is out of date. Run \`yarn install\` at the repo root and commit the result." - fi - if [ "$YARN_SDK_OUTCOME" = "success" ]; then echo "- yarn.lock (sdk): pass" else echo "- yarn.lock (sdk): fail" - echo " - \`sdk/yarn.lock\` is out of date. Run \`yarn install\` in \`sdk/\` and commit the result." + echo " - \`yarn install --frozen-lockfile\` failed in \`sdk/\`. Usually \`sdk/yarn.lock\` is out of date: run \`yarn install\` in \`sdk/\` and commit the result. See the step log for the actual error." + fi + + if [ "$YARN_ROOT_OUTCOME" = "success" ]; then + echo "- yarn.lock (root): pass" + elif [ "$YARN_ROOT_OUTCOME" = "skipped" ]; then + echo "- yarn.lock (root): skipped (sdk install failed - fix that first)" + else + echo "- yarn.lock (root): fail" + echo " - \`yarn install --frozen-lockfile\` failed at the repo root. Usually the root \`yarn.lock\` is out of date: run \`yarn install\` at the repo root and commit the result. See the step log for the actual error." fi if [ "$GUARD_OUTCOME" = "success" ]; then echo "- Repo guard: pass" elif [ "$GUARD_OUTCOME" = "skipped" ]; then - echo "- Repo guard: skipped (root yarn install failed - fix that first)" + echo "- Repo guard: skipped (yarn install failed - fix that first)" else if [ "$EMERGENCY_BYPASS" = "true" ]; then echo "- Repo guard: bypassed with \`emergency-override\`" @@ -161,11 +165,13 @@ jobs: if [ "$CARGO_OUTCOME" != "success" ]; then failed+=("Cargo.lock out of sync - run \`cargo update --workspace\` (or rebuild) and commit") fi - if [ "$YARN_ROOT_OUTCOME" != "success" ]; then - failed+=("root yarn.lock out of date - run \`yarn install\` at repo root and commit") - fi if [ "$YARN_SDK_OUTCOME" != "success" ]; then - failed+=("sdk yarn.lock out of date - run \`yarn install\` in \`sdk/\` and commit") + failed+=("sdk yarn install failed - usually \`sdk/yarn.lock\` is out of date: run \`yarn install\` in \`sdk/\` and commit") + fi + if [ "$YARN_ROOT_OUTCOME" = "skipped" ]; then + failed+=("root yarn.lock check skipped - fix the sdk install first") + elif [ "$YARN_ROOT_OUTCOME" != "success" ]; then + failed+=("root yarn install failed - usually root \`yarn.lock\` is out of date: run \`yarn install\` at repo root and commit") fi # The guard itself (exact-version, age, action-pinning, toolchain