diff --git a/.cargo/config.toml b/.cargo/config.toml index eb8f5ff..f4e8c00 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,2 @@ [build] target = "wasm32-unknown-unknown" - -[test] -target = "x86_64-unknown-linux-gnu" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5a9f703 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,76 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Run format + run: cargo fmt -- --check + + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Set up cargo cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: + cargo-${{ hashFiles('**/Cargo.lock') }} + cargo- + + - name: Run clippy + run: cargo clippy --all -- -D warnings + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Set up dfx + uses: aviate-labs/setup-dfx@v0.2.6 + with: + dfx-version: 0.14.3 + + - name: Set up cargo cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: + cargo-${{ hashFiles('**/Cargo.lock') }} + cargo- + + - name: Build wasm + run: cargo build --release + + - name: Run tests + env: + # generated with: + # dfx identity new gh_action --storage-mode plaintext + # dfx identity export gh_action + DFX_IDENTITY_PEM=${{ secrets.GH_ACTION_IDENTITY_PEM }} + run: | + dfx identity use gh_action + dfx start --background --artificial-delay 5 --clean + cargo test --target x86_64-unknown-linux-gnu