test: add tests for contract migrations #117
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://github.com/actions-rs/example/blob/master/.github/workflows/quickstart.yml | |
on: | |
push: | |
pull_request: | |
types: [opened] | |
name: Unit tests + lints | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
test: | |
name: Unit Tests | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Set github url and credentials | |
run: | | |
/usr/bin/git config --global --add url."https://${{ secrets.ACCESS_TOKEN }}:x-oauth-basic@github".insteadOf ssh://git@github | |
/usr/bin/git config --global --add url."https://${{ secrets.ACCESS_TOKEN }}:x-oauth-basic@github".insteadOf https://github | |
/usr/bin/git config --global --add url."https://${{ secrets.ACCESS_TOKEN }}:x-oauth-basic@github".insteadOf git@github | |
- name: Checkout sources | |
uses: actions/checkout@v2 | |
- name: Install nightly toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: 1.74.0 | |
target: wasm32-unknown-unknown | |
override: true | |
components: llvm-tools-preview | |
- name: Set up cargo cache | |
uses: actions/cache@v3 | |
continue-on-error: false | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: ${{ runner.os }}-cargo- | |
- name: Check if cw-optimize is installed | |
run: | | |
cargo cw-optimizoor --version || cargo install cw-optimizoor | |
- name: Compile contracts | |
run: | | |
cargo cw-optimizoor | |
- name: Run tests | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
toolchain: 1.74.0 | |
args: --locked --tests | |
env: | |
LLVM_PROFILE_FILE: "swap-converter-%p-%m.profraw" | |
RUSTFLAGS: "-Cinstrument-coverage" | |
RUST_BACKTRACE: 1 | |
- name: Generate HTML coverage info | |
run: | | |
curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - | |
./grcov . -s . --binary-path ./target/debug/ -t html --ignore-not-existing -o ./target/debug/coverage/ \ | |
--ignore target/debug/build/* | |
# ./grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/debug/lcov.info --ignore *_test.rs | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: "./target/debug/coverage/" | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |
lints: | |
name: Lints | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v2 | |
- name: Install stable toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: 1.74.0 | |
override: true | |
components: rustfmt, clippy | |
- name: Set up cargo cache | |
uses: actions/cache@v3 | |
continue-on-error: false | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: ${{ runner.os }}-cargo- | |
- name: Set github url and credentials | |
run: | | |
/usr/bin/git config --global --add url."https://${{ secrets.ACCESS_TOKEN }}:x-oauth-basic@github".insteadOf ssh://git@github | |
/usr/bin/git config --global --add url."https://${{ secrets.ACCESS_TOKEN }}:x-oauth-basic@github".insteadOf https://github | |
/usr/bin/git config --global --add url."https://${{ secrets.ACCESS_TOKEN }}:x-oauth-basic@github".insteadOf git@github | |
- name: Run cargo fmt | |
uses: actions-rs/cargo@v1 | |
with: | |
toolchain: 1.74.0 | |
command: fmt | |
args: --all -- --check | |
- name: Run cargo clippy | |
uses: actions-rs/cargo@v1 | |
with: | |
toolchain: 1.74.0 | |
command: clippy | |
args: --tests -- -D warnings |