Skip to content

Commit

Permalink
♻️ Refactor workspace and project dependencies (#15)
Browse files Browse the repository at this point in the history
* ♻️ Refactor workspace and project dependencies

* 👷 Update CI/CD workflows

* 👷 Add workdflow to publish ts sdk on release

* 🙈 Ignore yarn error log

* ♻️ Use workspace dependencies for the CLI
  • Loading branch information
GabrielePicco authored Feb 21, 2024
1 parent 4661d15 commit cacbfc1
Show file tree
Hide file tree
Showing 27 changed files with 422 additions and 2,765 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: Publish Bolt Lang
name: Publish Bolt crates
on:
release:
types: [published]
workflow_dispatch:

env:
solana_version: v1.17.0
solana_version: v1.18.1
anchor_version: 0.29.0

jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/cache@v3
- uses: actions/cache@v4
name: cache solana cli
id: cache-solana
with:
Expand All @@ -23,14 +23,15 @@ jobs:
~/.local/share/solana/
key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20

- name: install essentials
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
npm install --global yarn
- name: Cache node dependencies
uses: actions/cache@v3
Expand All @@ -43,7 +44,8 @@ jobs:
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
yarn --frozen-lockfile --network-concurrency 2
- uses: dtolnay/rust-toolchain@stable
- name: install rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

Expand All @@ -62,7 +64,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache rust
uses: Swatinem/rust-cache@v2
- name: Run fmt
Expand All @@ -74,30 +76,38 @@ jobs:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20

- name: Cache node dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Run lint
run: yarn lint

test-and-publish:
test:
needs: [clippy-lint, yarn-lint]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: install rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Cache rust
uses: Swatinem/rust-cache@v2

- uses: actions/checkout@v4

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20

Expand All @@ -111,7 +121,7 @@ jobs:
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
yarn --frozen-lockfile
- uses: actions/cache@v3
- uses: actions/cache@v4
name: cache solana cli
id: cache-solana
with:
Expand All @@ -138,10 +148,21 @@ jobs:
echo ${{ secrets.SYSTEM_FLY }} > target/deploy/system_fly-keypair.json
echo ${{ secrets.SYSTEM_SIMPLE_MOVEMENT }} > target/deploy/system_simple_movement-keypair.json
- name: run build
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
npm i -g @coral-xyz/anchor-cli@${{ env.anchor_version }} ts-mocha typescript
solana-test-validator > /dev/null &
sleep 5
solana airdrop -u l 100 tEsT3eV6RFCWs1BZ7AXTzasHqTtMnMLCB2tjQ42TDXD
anchor build
anchor idl build
anchor deploy
pkill -9 -f solana-test-validator
- name: run tests
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
ls node_modules/.bin
npm i -g @coral-xyz/anchor-cli@${{ env.anchor_version }} ts-mocha typescript
anchor test
Expand All @@ -150,7 +171,10 @@ jobs:
cargo publish --manifest-path=crates/bolt-lang/attribute/account/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/component/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/component-deserialize/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/component-id/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/system/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/system-input/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/bolt-program/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=programs/bolt-system/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=programs/bolt-component/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=programs/world/Cargo.toml --token ${CRATES_TOKEN}
Expand Down
176 changes: 176 additions & 0 deletions .github/workflows/publish-bolt-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: Publish Bolt SDKs
on:
release:
types: [published]
workflow_dispatch:

env:
solana_version: v1.18.1
anchor_version: 0.29.0

jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
name: cache solana cli
id: cache-solana
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}

- uses: actions/setup-node@v4
with:
node-version: 20

- name: install essentials
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
npm install --global yarn
- name: Cache node dependencies
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: install node_modules
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
yarn --frozen-lockfile --network-concurrency 2
- name: install rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Cache rust
uses: Swatinem/rust-cache@v2

- name: install solana
if: steps.cache-solana.outputs.cache-hit != 'true'
run: |
sh -c "$(curl -sSfL https://release.solana.com/${{ env.solana_version }}/install)"
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
solana --version
clippy-lint:
needs: install
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Cache rust
uses: Swatinem/rust-cache@v2
- name: Run fmt
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy -- --deny=warnings

yarn-lint:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: 20

- name: Cache node dependencies
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Run lint
run: yarn lint

test:
needs: [clippy-lint, yarn-lint]
runs-on: ubuntu-latest

steps:
- name: install rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Cache rust
uses: Swatinem/rust-cache@v2

- uses: actions/checkout@v4

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: 20

- name: Cache node dependencies
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: install node_modules
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
yarn --frozen-lockfile
- uses: actions/cache@v4
name: cache solana cli
id: cache-solana
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}

- name: setup solana
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
solana --version
solana-keygen new --silent --no-bip39-passphrase
- name: Set deployments keys
run: |
mkdir -p target/deploy
echo ${{ secrets.WORLD }} > target/deploy/world-keypair.json
echo ${{ secrets.BOLT_COMPONENT }} > target/deploy/bolt_component-keypair.json
echo ${{ secrets.BOLT_SYSTEM }} > target/deploy/bolt_system-keypair.json
echo ${{ secrets.COMPONENT_POSITION }} > target/deploy/component_position-keypair.json
echo ${{ secrets.COMPONENT_VELOCITY }} > target/deploy/component_velocity-keypair.json
echo ${{ secrets.SYSTEM_APPLY_VELOCITY }} > target/deploy/system_apply_velocity-keypair.json
echo ${{ secrets.SYSTEM_FLY }} > target/deploy/system_fly-keypair.json
echo ${{ secrets.SYSTEM_SIMPLE_MOVEMENT }} > target/deploy/system_simple_movement-keypair.json
- name: run build
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
npm i -g @coral-xyz/anchor-cli@${{ env.anchor_version }} ts-mocha typescript
solana-test-validator > /dev/null &
sleep 5
solana airdrop -u l 100 tEsT3eV6RFCWs1BZ7AXTzasHqTtMnMLCB2tjQ42TDXD
anchor build
anchor idl build
anchor deploy
pkill -9 -f solana-test-validator
- name: run tests
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
npm i -g @coral-xyz/anchor-cli@${{ env.anchor_version }} ts-mocha typescript
anchor test
- name: npm publish
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
cd clients/bolt-sdk/ && yarn build && yarn lint:fix && cd ../../ && yarn lint:fix
cd clients/bolt-sdk/ && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 0 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Run Bolt Tests
on:
push:
pull_request:

env:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target
**/*.rs.bk
node_modules
clients/sdk/node_modules
test-ledger
clients/bolt-sdk/yarn-error.log
.yarn
**/test-ledger

Expand All @@ -16,3 +16,4 @@ tests/examples/target
tests/examples/node_modules
tests/examples/.yarn


34 changes: 34 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,44 @@ members = [
"crates/*",
]

[workspace.package]
version = "0.0.1"
authors = ["Magicblock Labs <dev@magicblock.gg>"]
repository = "https://github.com/magicblock-labs/bolt"
homepage = "https://www.magicblock.gg/"
license = "MIT"
edition = "2021"

[workspace.dependencies]
bolt-attribute-bolt-program = { path = "crates/bolt-lang/attribute/bolt-program", version = "=0.0.1" }
bolt-attribute-bolt-component = { path = "crates/bolt-lang/attribute/component", version = "=0.0.1" }
bolt-attribute-bolt-system = { path = "crates/bolt-lang/attribute/system", version = "=0.0.1"}
bolt-attribute-bolt-system-input = { path = "crates/bolt-lang/attribute/system-input", version = "=0.0.1" }
bolt-attribute-bolt-component-deserialize = { path = "crates/bolt-lang/attribute/component-deserialize", version = "=0.0.1" }
bolt-attribute-bolt-component-id = { path = "crates/bolt-lang/attribute/component-id", version = "=0.0.1" }
world = { path = "programs/world", features = ["cpi"], version = "=0.0.1"}
bolt-system = { path = "programs/bolt-system", features = ["cpi"], version = "=0.0.1"}

## External crates
anchor-lang = "0.29.0"
solana-security-txt = "1.1.1"
tuple-conv = "1.0.1"
syn = { version = "1.0.60", features = ["full"] }
quote = "1.0"
proc-macro2 = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
anyhow = "1.0.32"
heck = "0.4.0"
clap = { version = "4.2.4", features = ["derive"] }
# TODO: Remove once https://github.com/solana-labs/solana/issues/33504 is resolved.
ahash = "=0.8.6"

[profile.release]
overflow-checks = true
lto = "fat"
codegen-units = 1

[profile.release.build-override]
opt-level = 3
incremental = false
Expand Down
Loading

0 comments on commit cacbfc1

Please sign in to comment.