Skip to content

Commit

Permalink
MP-1712. Improve ci/cd. (#134)
Browse files Browse the repository at this point in the history
* MP-1712. Improve ci/cd.

* Improve schema generation. Fix cargo make tasks naming.

* Bump osmosis deps.

* Use 0.16 deps to be compatible.

* Ignore correct files from coverage.

* Use cache for deps in github pipelines.
  • Loading branch information
piobab authored Dec 12, 2022
1 parent d658457 commit 1462b65
Show file tree
Hide file tree
Showing 12 changed files with 310 additions and 362 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Artifacts

on:
push:
branches:
- master
- main
pull_request:

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always

jobs:
artifacts:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
profile: minimal
override: true

# selecting a toolchain should happen before the plugin, as the cache uses the current rustc version as its cache key
- name: Cache dependencies
uses: Swatinem/rust-cache@v2

- name: Install cargo make
uses: davidB/rust-cargo-make@v1

- name: Compile contracts to wasm
run: cargo make rust-optimizer
50 changes: 50 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Coverage

on:
push:
branches:
- master
- main
pull_request:

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
# Directory with wasm files used by `tests`
ARTIFACTS_DIR_PATH: 'target/wasm32-unknown-unknown/release'

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
profile: minimal
override: true
components: llvm-tools-preview

# selecting a toolchain should happen before the plugin, as the cache uses the current rustc version as its cache key
- name: Cache dependencies
uses: Swatinem/rust-cache@v2

- name: Install cargo make
uses: davidB/rust-cargo-make@v1

# artifacts used by tests
- name: Compile workspace
run: cargo make build

- name: Run test coverage
run: cargo make coverage-lcov

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/coverage/lcov.info
87 changes: 30 additions & 57 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,52 @@
on: push

name: Main

on:
push:
branches:
- master
- main
pull_request:

env:
# Directory with wasm files used by `tests`
ARTIFACTS_DIR_PATH: 'target/wasm32-unknown-unknown/release'
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always

jobs:

test:
name: Test Suite
check:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0' # required by osmosis-testing

- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install stable toolchain
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
components: llvm-tools-preview
override: true

- name: Install cargo make
uses: davidB/rust-cargo-make@v1

- name: Compile workspace
run: cargo make build

- name: Run tests
run: cargo make test

# FIXME: enable when testing directories work as expected
#- name: Run test coverage
# run: cargo make coverage

#- name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3.1.1
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: false
# files: target/lcov.info

lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0' # required by osmosis-testing

- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
profile: minimal
override: true

# selecting a toolchain should happen before the plugin, as the cache uses the current rustc version as its cache key
- name: Cache dependencies
uses: Swatinem/rust-cache@v2

- name: Install cargo make
uses: davidB/rust-cargo-make@v1

- name: Check formatting
- name: Format
run: cargo make fmt

- name: Clippy check
- name: Clippy
run: cargo make clippy

# fails if schemas changes not committed
- name: Check schemas up-to-date
run: |
cargo make generate-all-schemas
git diff --exit-code schemas
- name: Audit dependencies
run: |
cargo install --locked cargo-audit
cargo make audit
Loading

0 comments on commit 1462b65

Please sign in to comment.