From 0f8f5ac68a1c1ec4e3d185cb4a8e4f5fd59906c5 Mon Sep 17 00:00:00 2001 From: febo Date: Thu, 31 Oct 2024 22:28:34 +0000 Subject: [PATCH] Replace interface build for test --- .github/actions/setup/action.yml | 8 +++++++- .github/workflows/main.yml | 4 ++-- Cargo.toml | 2 +- package.json | 2 +- scripts/ci/set-env.mjs | 1 + scripts/interface/{build.mjs => test.mjs} | 4 ++-- 6 files changed, 14 insertions(+), 7 deletions(-) rename scripts/interface/{build.mjs => test.mjs} (71%) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 6e5c3fe..cda743f 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -11,7 +11,7 @@ inputs: description: The key to cache local cargo dependencies. Skips local cargo caching if not provided. required: false toolchain: - description: Rust toolchain to install. Comma-separated string of [`build`, `format`, `lint`]. + description: Rust toolchain to install. Comma-separated string of [`build`, `format`, `lint`, `test`]. required: false solana: description: Install Solana if `true`. Defaults to `false`. @@ -57,6 +57,12 @@ runs: toolchain: ${{ env.TOOLCHAIN_LINT }} components: clippy + - name: Install Rust 'test' Toolchain + if: ${{ contains(inputs.toolchain, 'test') }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.TOOLCHAIN_TEST }} + - name: Install Solana if: ${{ inputs.solana == 'true' }} uses: solana-program/actions/install-solana@v1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 85d0732..deaa938 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -58,7 +58,7 @@ jobs: - name: Lint Interface run: pnpm interface:lint - build_interface: + test_interface: name: Build Interface runs-on: ubuntu-latest needs: format_and_lint_interface @@ -69,7 +69,7 @@ jobs: - name: Setup Environment uses: ./.github/actions/setup with: - toolchain: build + toolchain: test cargo-cache-key: cargo-interface solana: true diff --git a/Cargo.toml b/Cargo.toml index efb7b72..d2168d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,6 @@ solana = "edge" # Specify Rust toolchains for rustfmt, clippy, and build. # Any unprovided toolchains default to stable. [workspace.metadata.toolchains] -build = "nightly" format = "nightly" lint = "nightly" +test = "nightly" diff --git a/package.json b/package.json index 65b62fa..8dfd4e7 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,9 @@ "clients:rust:lint": "zx ./scripts/client/lint-rust.mjs", "clients:rust:publish": "zx ./scripts/client/publish-rust.mjs", "clients:rust:test": "zx ./scripts/client/test-rust.mjs", - "interface:build": "zx ./scripts/interface/build.mjs", "interface:format": "zx ./scripts/interface/format.mjs", "interface:lint": "zx ./scripts/interface/lint.mjs", + "interface:test": "zx ./scripts/interface/test.mjs", "template:upgrade": "zx ./scripts/upgrade-template.mjs" }, "devDependencies": { diff --git a/scripts/ci/set-env.mjs b/scripts/ci/set-env.mjs index a9e13dd..76dd029 100644 --- a/scripts/ci/set-env.mjs +++ b/scripts/ci/set-env.mjs @@ -5,3 +5,4 @@ await $`echo "SOLANA_VERSION=${getSolanaVersion()}" >> $GITHUB_ENV`; await $`echo "TOOLCHAIN_BUILD=${getToolchain('build')}" >> $GITHUB_ENV`; await $`echo "TOOLCHAIN_FORMAT=${getToolchain('format')}" >> $GITHUB_ENV`; await $`echo "TOOLCHAIN_LINT=${getToolchain('lint')}" >> $GITHUB_ENV`; +await $`echo "TOOLCHAIN_TEST=${getToolchain('test')}" >> $GITHUB_ENV`; diff --git a/scripts/interface/build.mjs b/scripts/interface/test.mjs similarity index 71% rename from scripts/interface/build.mjs rename to scripts/interface/test.mjs index 8128a72..3d9aeeb 100644 --- a/scripts/interface/build.mjs +++ b/scripts/interface/test.mjs @@ -9,8 +9,8 @@ import { // Configure additional arguments here, e.g.: // ['--arg1', '--arg2', ...cliArguments()] const buildArgs = cliArguments(); -const toolchain = getToolchainArgument('build'); +const toolchain = getToolchainArgument('test'); const manifestPath = path.join(workingDirectory, 'interface', 'Cargo.toml'); // Build the programs. -await $`cargo ${toolchain} build --all-features --manifest-path ${manifestPath} ${buildArgs}`; +await $`cargo ${toolchain} test --all-features --manifest-path ${manifestPath} ${buildArgs}`;