From fbf12bcb817e2e40eee2072282e2279177ce9a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Zwoli=C5=84ski?= Date: Tue, 15 Aug 2023 15:10:48 +0200 Subject: [PATCH] chore: initial CI setup (#30) --- .cargo/config.toml | 3 -- .github/workflows/ci.yml | 75 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml 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..e90ae02 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,75 @@ +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 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: Install nextest + uses: taiki-e/install-action@nextest + + - name: Set up dfx + uses: aviate-labs/setup-dfx@v0.2.6 + with: + dfx-version: 0.14.3 + + - name: Build wasm + run: cargo build --release + + - name: Run tests + run: | + dfx identity new gh_action --storage-mode plaintext + dfx identity use gh_action + dfx start --background --artificial-delay 5 --clean + cargo nextest run --target x86_64-unknown-linux-gnu