Skip to content

Commit

Permalink
[CI] Invoke unit-tests only for changed contracts (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
lubkoll authored Jul 18, 2024
1 parent 7ae691c commit d0dfd52
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 44 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/cl_vault.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test cl vault

on:
pull_request:
branches:
- main
paths:
- 'smart-contracts/contracts/cl-vault/**'
push:
branches:
- main
workflow_dispatch:

jobs:
unit-test:
uses: ./.github/workflows/rust_basic.yml
with:
contract: 'cl-vault'
18 changes: 18 additions & 0 deletions .github/workflows/dex_router_osmosis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test dex router (osmosis)

on:
pull_request:
branches:
- main
paths:
- 'smart-contracts/contracts/dex-router-osmosis/**'
push:
branches:
- main
workflow_dispatch:

jobs:
unit-test:
uses: ./.github/workflows/rust_basic.yml
with:
contract: 'dex-router-osmosis'
25 changes: 1 addition & 24 deletions .github/workflows/lint.yml → .github/workflows/lint_go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,4 @@ jobs:
run: go version
- name: Go lint
if: env.GIT_DIFF
run: make lint
lint-rust:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Get git diff
uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.rs
Makefile
- name: Install Rust
if: env.GIT_DIFF
uses: dtolnay/rust-toolchain@stable
- name: Show versions
if: env.GIT_DIFF
run: rustc -V && cargo -V
- name: Rust lint
if: env.GIT_DIFF
run: cd smart-contracts && RUSTFLAGS="-Dwarnings" cargo clippy --workspace -- -D warnings --A deprecated
- name: Rust format check
if: env.GIT_DIFF
run: cd smart-contracts && cargo fmt --all -- --check
run: make lint
18 changes: 18 additions & 0 deletions .github/workflows/lst_adapter_osmosis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test lst adapter (osmosis)

on:
pull_request:
branches:
- main
paths:
- 'smart-contracts/contracts/lst-adapter-osmosis/**'
push:
branches:
- main
workflow_dispatch:

jobs:
unit-test:
uses: ./.github/workflows/rust_basic.yml
with:
contract: 'lst-adapter-osmosis'
18 changes: 18 additions & 0 deletions .github/workflows/lst_dex_adapter_osmosis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test lst dex adapter (osmosis)

on:
pull_request:
branches:
- main
paths:
- 'smart-contracts/contracts/lst-dex-adapter-osmosis/**'
push:
branches:
- main
workflow_dispatch:

jobs:
unit-test:
uses: ./.github/workflows/rust_basic.yml
with:
contract: 'lst-dex-adapter-osmosis'
18 changes: 18 additions & 0 deletions .github/workflows/range_middleware.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test range middleware

on:
pull_request:
branches:
- main
paths:
- 'smart-contracts/contracts/range-middleware/**'
push:
branches:
- main
workflow_dispatch:

jobs:
unit-test:
uses: ./.github/workflows/rust_basic.yml
with:
contract: 'range-middleware'
46 changes: 46 additions & 0 deletions .github/workflows/rust_basic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Unit Test (rust)

on:
workflow_call:
inputs:
contract:
required: true
type: string

jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Get git diff
uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.rs
**/Cargo.toml
- name: Install Rust
if: env.GIT_DIFF
uses: dtolnay/rust-toolchain@stable
- name: Restore dependencies
if: env.GIT_DIFF
uses: actions/cache@v4
with:
path: |
~/.cargo
~/go
**/target
key: ${{ runner.os }}-cargo-$${{ hashFiles('smart-contracts/Cargo.toml') }}
restore-keys: ${{ runner.os }}-cargo
- name: Rust lint
if: env.GIT_DIFF
run: RUSTFLAGS="-Dwarnings" cargo clippy --workspace -- -D warnings --A deprecated
working-directory: smart-contracts/contracts/${{ inputs.contract }}
- name: Rust format check
if: env.GIT_DIFF
run: cargo fmt --all -- --check
working-directory: smart-contracts/contracts/${{ inputs.contract }}
- name: Run unit-tests
if: env.GIT_DIFF
run: cargo unit-test
working-directory: smart-contracts/contracts/${{ inputs.contract }}
21 changes: 1 addition & 20 deletions .github/workflows/test.yml → .github/workflows/test_go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,4 @@ jobs:
run: make test-cover
- name: Code coverage report
if: env.GIT_DIFF
uses: codecov/[email protected]
test-rust:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Get git diff
uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.rs
- name: Install Rust
if: env.GIT_DIFF
uses: dtolnay/rust-toolchain@stable
- name: Install just via cargo
if: env.GIT_DIFF
run: cargo install just
- name: Run unit-tests
if: env.GIT_DIFF
run: cd smart-contracts && cargo test --lib
uses: codecov/[email protected]
18 changes: 18 additions & 0 deletions .github/workflows/token_burner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test token burner

on:
pull_request:
branches:
- main
paths:
- 'smart-contracts/contracts/token-burner/**'
push:
branches:
- main
workflow_dispatch:

jobs:
unit-test:
uses: ./.github/workflows/rust_basic.yml
with:
contract: 'token-burner'

0 comments on commit d0dfd52

Please sign in to comment.