├── LICENSE ├── README.md └── action.yml /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023 The Meta-DAO 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Anchor Test 2 | 3 | A fast, easy, and secure action for testing [Anchor](https://www.anchor-lang.com/) projects. Completes in ~1 minute. 4 | 5 | ## Usage 6 | 7 | ### Example workflow 8 | 9 | Here's an example workflow: 10 | 11 | ```yaml 12 | name: example-workflow 13 | on: [push] 14 | jobs: 15 | run-anchor-test: 16 | runs-on: ubuntu-22.04 17 | steps: 18 | - uses: actions/checkout@v3 19 | - uses: metadaoproject/anchor-test@v2.2 20 | ``` 21 | 22 | This will use the default versions of Anchor, Node.js, and the Solana CLI tools, which are 0.27.0, 16.15.1, and 1.15.2 respectively. 23 | 24 | ### Configuring versions 25 | 26 | You can also configure these versions like so: 27 | 28 | ```yaml 29 | steps: 30 | - uses: actions/checkout@v3 31 | - uses: metadaoproject/anchor-test@v2.2 32 | with: 33 | anchor-version: '0.29.0' 34 | solana-cli-version: '1.18.26' 35 | node-version: '16.15.1' 36 | ``` 37 | 38 | ### Cargo Features 39 | 40 | You can pass in features to cargo via `anchor test` by using the `features` input: 41 | 42 | ```yaml 43 | steps: 44 | - uses: actions/checkout@v3 45 | - uses: metadaoproject/anchor-test@v2.2 46 | with: 47 | anchor-version: '0.29.0' 48 | solana-cli-version: '1.18.26' 49 | node-version: '16.15.1' 50 | features: 'my-feature' 51 | ``` 52 | 53 | This defaults to 'default'. 54 | 55 | ## License 56 | 57 | The scripts and documentation in this project are released under the [MIT License](LICENSE). 58 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Anchor Test' 2 | description: 'An "anchor test" action that runs in ~1 minute.' 3 | branding: 4 | icon: anchor 5 | color: blue 6 | inputs: 7 | node-version: 8 | description: 'Version of node.js to use' 9 | required: false 10 | default: '20.11.0' # LTS 11 | solana-cli-version: 12 | description: 'Version of Solana CLI to use' 13 | required: false 14 | default: '1.17.16' # stable 15 | anchor-version: 16 | description: 'Version of Anchor to use' 17 | required: false 18 | default: '0.29.0' # latest 19 | features: 20 | description: 'Features to pass to cargo' 21 | required: false 22 | default: 'default' 23 | runs: 24 | using: 'composite' 25 | steps: 26 | - uses: metadaoproject/setup-anchor@v3.2 27 | with: 28 | node-version: ${{ inputs.node-version }} 29 | solana-cli-version: ${{ inputs.solana-cli-version }} 30 | anchor-version: ${{ inputs.anchor-version }} 31 | - name: Cache node_modules 32 | uses: actions/cache@v4 33 | with: 34 | path: ./node_modules/ 35 | key: node-modules-${{ runner.os }}-build-${{ inputs.node-version }} 36 | - name: Install node_modules 37 | run: yarn 38 | shell: bash 39 | - name: Create keypair 40 | run: solana-keygen new --no-bip39-passphrase 41 | shell: bash 42 | - name: Make Anchor.toml compatible with runner 43 | run: sed -i 's:/user/:/runner/:' Anchor.toml 44 | shell: bash 45 | - name: Install Cargo toolchain 46 | uses: actions-rs/toolchain@v1 47 | with: 48 | toolchain: stable 49 | profile: minimal 50 | components: rustc 51 | - name: Cache Cargo dependencies 52 | uses: Swatinem/rust-cache@v2 53 | - name: Run tests 54 | run: anchor test -- --features ${{ inputs.features }} 55 | shell: bash 56 | --------------------------------------------------------------------------------