From 6bde7bc58ca133392facde9f023281389e44fa89 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 30 May 2024 08:49:39 +0000 Subject: [PATCH] version 0.2.8 snapshot --- .github/actions/setup/action.yml | 39 ++++++ .github/workflows/main.yml | 200 +++++++++++++++++++++++++++++++ Cargo.lock | 30 ++--- package.json | 2 + scripts/client/lint-js.mjs | 9 ++ scripts/client/lint-rust.mjs | 7 ++ 6 files changed, 272 insertions(+), 15 deletions(-) create mode 100644 .github/actions/setup/action.yml create mode 100644 .github/workflows/main.yml create mode 100755 scripts/client/lint-js.mjs create mode 100755 scripts/client/lint-rust.mjs diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..0d67960 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,39 @@ +name: Setup environment + +inputs: + anchor: + description: The Anchor version to install + cache: + description: Enable caching + default: "true" + node: + description: The Node.js version to install + required: true + solana: + description: The Solana version to install + +runs: + using: "composite" + steps: + - name: Setup pnpm + uses: pnpm/action-setup@v3 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node }} + cache: "pnpm" + - name: Install dependencies + run: pnpm install --frozen-lockfile + shell: bash + - name: Install Solana + if: ${{ inputs.solana != '' }} + uses: metaplex-foundation/actions/install-solana@v1 + with: + version: ${{ inputs.solana }} + cache: ${{ inputs.cache }} + - name: Install Anchor + if: ${{ inputs.anchor != '' }} + uses: metaplex-foundation/actions/install-anchor-cli@v1 + with: + version: ${{ inputs.anchor }} + cache: ${{ inputs.cache }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..01b74d8 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,200 @@ +name: Main + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + NODE_VERSION: 18 + SOLANA_VERSION: 1.18.12 + ANCHOR_VERSION: 0.30.0 + CARGO_CACHE: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + +jobs: + build_programs: + name: Build programs + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v4 + - name: Setup environment + uses: ./.github/actions/setup + with: + node: ${{ env.NODE_VERSION }} + solana: ${{ env.SOLANA_VERSION }} + anchor: ${{ env.ANCHOR_VERSION }} + - name: Cache cargo dependencies + uses: actions/cache@v4 + with: + path: ${{ env.CARGO_CACHE }} + key: ${{ runner.os }}-cargo-programs-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-programs + - name: Build programs + run: pnpm programs:build + - name: Upload program builds + uses: actions/upload-artifact@v4 + with: + name: program-builds + path: ./target/deploy/*.so + if-no-files-found: error + - name: Save all builds for clients + uses: actions/cache/save@v4 + with: + path: ./**/*.so + key: ${{ runner.os }}-builds-${{ github.sha }} + + test_programs: + name: Test programs + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v4 + - name: Setup environment + uses: ./.github/actions/setup + with: + node: ${{ env.NODE_VERSION }} + solana: ${{ env.SOLANA_VERSION }} + anchor: ${{ env.ANCHOR_VERSION }} + - name: Cache test cargo dependencies + uses: actions/cache@v4 + with: + path: ${{ env.CARGO_CACHE }} + key: ${{ runner.os }}-cargo-program-tests-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-program-tests + ${{ runner.os }}-cargo-programs-${{ hashFiles('**/Cargo.lock') }} + ${{ runner.os }}-cargo-programs + - name: Test programs + run: pnpm programs:test + + generate_idls: + name: Check IDL generation + needs: build_programs + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v4 + - name: Setup environment + uses: ./.github/actions/setup + with: + node: ${{ env.NODE_VERSION }} + solana: ${{ env.SOLANA_VERSION }} + anchor: ${{ env.ANCHOR_VERSION }} + - name: Cache cargo dependencies + uses: actions/cache@v4 + with: + path: ${{ env.CARGO_CACHE }} + key: ${{ runner.os }}-cargo-programs-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-programs + - name: Cache local cargo dependencies + uses: actions/cache@v4 + with: + path: | + .cargo/bin/ + .cargo/registry/index/ + .cargo/registry/cache/ + .cargo/git/db/ + key: ${{ runner.os }}-cargo-local-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-local + - name: Generate IDLs + run: pnpm generate:idls + - name: Ensure working directory is clean + run: test -z "$(git status --porcelain)" + + generate_clients: + name: Check client generation + needs: build_programs + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v4 + - name: Setup environment + uses: ./.github/actions/setup + with: + node: ${{ env.NODE_VERSION }} + solana: ${{ env.SOLANA_VERSION }} + - name: Generate clients + run: pnpm generate:clients + - name: Ensure working directory is clean + run: test -z "$(git status --porcelain)" + + test_js: + name: Test JS client + needs: build_programs + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v4 + - name: Setup environment + uses: ./.github/actions/setup + with: + node: ${{ env.NODE_VERSION }} + solana: ${{ env.SOLANA_VERSION }} + - name: Restore all builds + uses: actions/cache/restore@v4 + with: + path: ./**/*.so + key: ${{ runner.os }}-builds-${{ github.sha }} + - name: Test JS client + run: pnpm clients:js:test + + lint_js: + name: Lint JS client + needs: build_programs + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v4 + - name: Setup environment + uses: ./.github/actions/setup + with: + node: ${{ env.NODE_VERSION }} + - name: Lint JS client + run: pnpm clients:js:lint + + test_rust: + name: Test Rust client + needs: build_programs + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v4 + - name: Setup environment + uses: ./.github/actions/setup + with: + node: ${{ env.NODE_VERSION }} + solana: ${{ env.SOLANA_VERSION }} + - name: Cache Rust client dependencies + uses: actions/cache@v4 + with: + path: ${{ env.CARGO_CACHE }} + key: ${{ runner.os }}-cargo-rust-client-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-rust-client + - name: Restore all builds + uses: actions/cache/restore@v4 + with: + path: ./**/*.so + key: ${{ runner.os }}-builds-${{ github.sha }} + - name: Test Rust client + run: pnpm clients:rust:test + + lint_rust: + name: Lint Rust client + needs: build_programs + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v4 + - name: Setup environment + uses: ./.github/actions/setup + with: + node: ${{ env.NODE_VERSION }} + - name: Lint Rust client + run: pnpm clients:rust:lint diff --git a/Cargo.lock b/Cargo.lock index 5046844..a930f16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -523,9 +523,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c90a406b4495d129f00461241616194cb8a032c8d1c53c657f0961d5f8e0498" +checksum = "cd066d0b4ef8ecb03a55319dc13aa6910616d0f44008a045bb1835af830abff5" dependencies = [ "brotli", "flate2", @@ -574,9 +574,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" dependencies = [ "addr2line", "cc", @@ -866,9 +866,9 @@ dependencies = [ [[package]] name = "bytemuck_derive" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "369cfaf2a5bed5d8f8202073b2e093c9f508251de1551a0deb4253e4c7d80909" +checksum = "1ee891b04274a59bd38b412188e24b849617b2e45a0fd8d057deb63e7403761b" dependencies = [ "proc-macro2", "quote", @@ -1744,9 +1744,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "goblin" @@ -2608,9 +2608,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.32.2" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" dependencies = [ "memchr", ] @@ -5607,7 +5607,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.8", + "winnow 0.6.9", ] [[package]] @@ -6139,9 +6139,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6" dependencies = [ "memchr", ] diff --git a/package.json b/package.json index e875049..6396d82 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,9 @@ "validator:start": "zx ./scripts/start-validator.mjs", "validator:restart": "pnpm validator:start --restart", "validator:stop": "zx ./scripts/stop-validator.mjs", + "clients:js:lint": "zx ./scripts/client/lint-js.mjs", "clients:js:test": "zx ./scripts/client/test-js.mjs", + "clients:rust:lint": "zx ./scripts/client/lint-rust.mjs", "clients:rust:test": "zx ./scripts/client/test-rust.mjs" }, "devDependencies": { diff --git a/scripts/client/lint-js.mjs b/scripts/client/lint-js.mjs new file mode 100755 index 0000000..ae5678d --- /dev/null +++ b/scripts/client/lint-js.mjs @@ -0,0 +1,9 @@ +#!/usr/bin/env zx +import 'zx/globals'; +import { workingDirectory } from '../utils.mjs'; + +// Check the client using ESLint and Prettier. +cd(path.join(workingDirectory, 'clients', 'js')); +await $`pnpm install`; +await $`pnpm lint`; +await $`pnpm format`; diff --git a/scripts/client/lint-rust.mjs b/scripts/client/lint-rust.mjs new file mode 100755 index 0000000..2aa0860 --- /dev/null +++ b/scripts/client/lint-rust.mjs @@ -0,0 +1,7 @@ +#!/usr/bin/env zx +import 'zx/globals'; +import { workingDirectory } from '../utils.mjs'; + +// Check the client using Clippy. +cd(path.join(workingDirectory, 'clients', 'rust')); +await $`cargo clippy ${argv._}`;