Skip to content

Commit

Permalink
Merge pull request #11 from metaplex-foundation/chore/update-version
Browse files Browse the repository at this point in the history
Updating CI and bumping to 1.17
  • Loading branch information
blockiosaurus authored Feb 7, 2024
2 parents bb24ea0 + 98db386 commit 2e4199f
Show file tree
Hide file tree
Showing 26 changed files with 10,501 additions and 2,407 deletions.
6 changes: 4 additions & 2 deletions .github/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
CARGO_TERM_COLOR=always
NODE_VERSION=16.x
PROGRAMS=["system-extras", "token-extras"]
RUST_VERSION=1.65.0
SOLANA_VERSION=1.14.13
RUST_VERSION=1.70.0
SOLANA_VERSION=1.17.20
COMMIT_USER_NAME=github-actions
COMMIT_USER_EMAIL=[email protected]
4 changes: 3 additions & 1 deletion .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ programs: &programs

client_common: &client_common
- *programs
- ".github/workflows/test-js.yml"
- ".github/workflows/test-js-client.yml"
- ".github/workflows/main.yml"
- ".github/file-filters.yml"
- ".github/.env"
- "configs/shank.cjs"
- "configs/kinobi.cjs"

Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/build-programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ on:
inputs:
rust:
description: Rust version
default: 1.65.0
default: 1.70.0
required: true
type: string
solana:
description: Solana version
default: 1.13.6
default: 1.17.20
required: true
type: string

Expand Down Expand Up @@ -50,17 +50,16 @@ jobs:
uses: metaplex-foundation/actions/cache-programs@v1

- name: Build programs
shell: bash
working-directory: configs/scripts/program
run: ./build.sh
env:
PROGRAMS: ${{ env.PROGRAMS }}
run: |
for program in $(echo $PROGRAMS | jq -c '.[]' | sed 's/"//g'); do
(cd ./programs/$program; cargo build-bpf)
done

- name: Upload program builds
uses: actions/upload-artifact@v3
with:
name: program-builds
# First wildcard ensures exported paths are consistently under the programs folder.
path: ./program*/**/target/deploy/*.so
path: ./program*/.bin/*.so
if-no-files-found: error
39 changes: 23 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
any: ${{ steps.changes.outputs.any }}
programs: ${{ steps.changes.outputs.programs }}
program_matrix: ${{ steps.program_matrix.outputs.matrix }}
js_client: ${{ steps.changes.outputs.js_client }}
steps:
- name: Git checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -59,17 +60,31 @@ jobs:
if: ${{ needs.changes.outputs.any == 'true' }}
needs: build_programs
runs-on: ubuntu-latest
outputs:
js_changed: ${{ steps.changes.outputs.js_client }}
permissions:
contents: write
steps:
- name: Git checkout
uses: actions/checkout@v3

- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV

- name: Install Linux Build Deps
run: sudo apt-get update && sudo apt-get install -y pkg-config build-essential libudev-dev

- name: Install Rust
uses: metaplex-foundation/actions/install-rust@v1
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Install Solana
uses: metaplex-foundation/actions/install-solana@v1
with:
version: ${{ env.SOLANA_VERSION }}
cache: ${{ env.CACHE }}

- name: Cache program dependencies
if: env.CACHE == 'true'
uses: metaplex-foundation/actions/cache-programs@v1

- name: Install Node.js
uses: metaplex-foundation/actions/install-node-with-pnpm@v1
with:
Expand All @@ -84,20 +99,12 @@ jobs:
- name: Generate IDLs and clients
run: pnpm generate

- name: Commit generated clients
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update generated clients

- name: Detect client changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: .github/file-filters.yml
- name: Ensure working directory is clean
run: test -z "$(git status --porcelain)"

test_js:
if: needs.generate_clients.outputs.js_changed == 'true'
if: needs.changes.outputs.js_client == 'true'
name: JS Client
needs: generate_clients
uses: ./.github/workflows/test-js.yml
uses: ./.github/workflows/test-js-client.yml
secrets: inherit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy JS Client
name: Publish JS Client

on:
workflow_dispatch:
Expand Down Expand Up @@ -39,11 +39,11 @@ jobs:
test_js:
name: JS client
needs: build_programs
uses: ./.github/workflows/test-js.yml
uses: ./.github/workflows/test-js-client.yml
secrets: inherit

deploy_js:
name: JS client / Deploy
publish_js:
name: JS client / Publish
runs-on: ubuntu-latest
needs: test_js
permissions:
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
deploy_js_docs:
name: JS client / Deploy docs
runs-on: ubuntu-latest
needs: deploy_js
needs: publish_js
environment:
name: js-client-documentation
url: ${{ steps.deploy.outputs.url }}
Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions .github/workflows/test-programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path ./programs/${{ matrix.program }}/Cargo.toml -- --check
args: --all --manifest-path ./programs/${{ matrix.program }}/Cargo.toml -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
Expand All @@ -54,5 +54,8 @@ jobs:
args: --all-targets --all-features --no-deps --manifest-path ./programs/${{ matrix.program }}/Cargo.toml

- name: Run tests
working-directory: ./programs/${{ matrix.program }}
run: cargo test-bpf
shell: bash
working-directory: configs/scripts/program
run: RUST_LOG=error ./test.sh
env:
PROGRAM: ${{ matrix.program }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ test-ledger
dist
.amman
.crates
.bin
13 changes: 12 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ You will then have access to the following commands.

- `programs:build` - Build all programs and fetch all dependant programs.
- `programs:test` - Test all programs.
- `programs:debug` - Test all programs with logs enabled.
- `programs:clean` - Clean all built and fetched programs.
- `clients:js:test` - Run the JS client tests.
- `pnpm generate` - Shortcut for `pnpm generate:idls && pnpm generate:clients`.
- `pnpm generate:idls` - Generate IDLs for all programs, as configured in the `configs/shank.cjs` file.
- `pnpm generate:clients` - Generate clients using Kinobi, as configured in the `configs/kinobi.cjs` file.
- `pnpm generate` - Shortcut for `pnpm generate:idls && pnpm generate:clients`.
- `pnpm validator` - Start a local validator using Amman, as configured in the `configs/validator.cjs` file.
- `pnpm validator:debug` - Start a local validator using Amman with logs enabled, as configured in the `configs/validator.cjs` file.
- `pnpm validator:stop` - Stop the local validator.
- `pnpm validator:logs` - Show the logs of the local validator.

Expand All @@ -28,6 +31,14 @@ Each client has its own README with instructions on how to get started. You can

- [JavaScript client](./clients/js/README.md)

In order to generate the clients, run the following command.

```sh
pnpm generate
```

You will need to run `pnpm generate` to re-generate the clients when something changes in the program(s).

## Setting up CI/CD using GitHub actions

Most of the CI/CD should already be set up for you and the `.github/.env` file can be used to tweak the variables of the workflows.
Expand Down
Loading

0 comments on commit 2e4199f

Please sign in to comment.