diff --git a/.github/actions/anchor-test/action.yml b/.github/actions/anchor-test/action.yml new file mode 100644 index 00000000..fe2f8b98 --- /dev/null +++ b/.github/actions/anchor-test/action.yml @@ -0,0 +1,55 @@ +name: 'Anchor Test' +description: 'An "anchor test" action that runs in ~1 minute.' +branding: + icon: anchor + color: blue +inputs: + node-version: + description: 'Version of node.js to use' + required: false + default: '20.11.0' # LTS + solana-cli-version: + description: 'Version of Solana CLI to use' + required: false + default: '1.17.16' # stable + anchor-version: + description: 'Version of Anchor to use' + required: false + default: '0.29.0' # latest + features: + description: 'Features to pass to cargo' + required: false + default: 'default' +runs: + using: 'composite' + steps: + - uses: metadaoproject/setup-anchor@aeeb5505f3fd3d52a1080d14863c6aa428c9fdf9 # v3.4 + with: + node-version: ${{ inputs.node-version }} + solana-cli-version: ${{ inputs.solana-cli-version }} + anchor-version: ${{ inputs.anchor-version }} + - name: Cache node_modules + uses: actions/cache@v4 + with: + path: ./node_modules/ + key: node-modules-${{ runner.os }}-build-${{ inputs.node-version }}-${{ hashFiles('yarn.lock') }} + - name: Install node_modules + run: yarn + shell: bash + - name: Create keypair + run: solana-keygen new --no-bip39-passphrase + shell: bash + - name: Make Anchor.toml compatible with runner + run: sed -i 's:/user/:/runner/:' Anchor.toml + shell: bash + - name: Install Cargo toolchain + uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 + with: + toolchain: stable + profile: minimal + components: rustc + - name: Cache Cargo dependencies + uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 + - name: Run tests + run: anchor test -- --features ${{ inputs.features }} + shell: bash diff --git a/.github/repo-guard.toml b/.github/repo-guard.toml index 35c5ae1b..2b27009c 100644 --- a/.github/repo-guard.toml +++ b/.github/repo-guard.toml @@ -72,7 +72,10 @@ package_min_age_days = 14 [actions.sha_allowlist] "metadaoproject/anchor-test" = ["876dde6990e0a3d22e1cf1c702b4e4c64aa47d15"] # v2.3 "metadaoproject/anchor-verifiable-build" = ["6d8fc1999ea4b7ff701e8b166903b398741e1c50"] # v0.4 -"metadaoproject/setup-anchor" = ["7d1e9699eb18c33ba5f32f6a9952f0e90515996a"] # v3.2 +"metadaoproject/setup-anchor" = [ + "7d1e9699eb18c33ba5f32f6a9952f0e90515996a", # v3.2 + "aeeb5505f3fd3d52a1080d14863c6aa428c9fdf9", # v3.4 +] "nick-fields/retry" = [ "ce71cc2ab81d554ebbe88c79ab5975992d79ba08", # v3 "14672906e672a08bd6eeb15720e9ed3ce869cdd4", # v2 @@ -82,6 +85,8 @@ package_min_age_days = 14 "EndBug/add-and-commit" = ["a94899bca583c204427a224a7af87c02f9b325d5"] # v9.1.4 "peter-evans/find-comment" = ["3eae4d37986fb5a8592848f6a574fdf654e61f9e"] # v3 "peter-evans/create-or-update-comment" = ["71345be0265236311c031f5c7866368bd1eff043"] # v4 +"actions-rs/toolchain" = ["16499b5e05bf2e26879000db0c1d13f7e13fa3af"] # v1.0.7 +"Swatinem/rust-cache" = ["6323deb102c322ba6fcbdcafc7e3dddab59af2b6"] # v2.9.2 [sensitive_diff] # Files where any change should be surfaced for security review even if no diff --git a/.github/workflows/anchor-test.yaml b/.github/workflows/anchor-test.yaml index 5c10b713..032b316f 100644 --- a/.github/workflows/anchor-test.yaml +++ b/.github/workflows/anchor-test.yaml @@ -37,7 +37,7 @@ jobs: cd sdk yarn build - - uses: metadaoproject/anchor-test@876dde6990e0a3d22e1cf1c702b4e4c64aa47d15 # v2.3 + - uses: ./.github/actions/anchor-test with: anchor-version: '0.29.0' solana-cli-version: '1.17.31'