Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions .github/workflows/repo-guard.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: Repository Guard

on:
Expand Down Expand Up @@ -40,18 +40,20 @@
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
run: |
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
Expand Down Expand Up @@ -83,24 +85,26 @@
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\`"
Expand Down Expand Up @@ -161,11 +165,13 @@
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
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
32 changes: 8 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ cd sdk
yarn install
yarn build-local
cd ..
yarn install --force
yarn install
yarn lint:fix
echo "✅ rebuild complete"
15 changes: 3 additions & 12 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 3 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading