Skip to content

Commit

Permalink
[CI] Add cachepot -- part2: use cache
Browse files Browse the repository at this point in the history
  • Loading branch information
lubkoll committed Aug 23, 2024
1 parent 88802b1 commit cb2030c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 55 deletions.
80 changes: 42 additions & 38 deletions .github/workflows/all_checks_osmosis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Test Tube (osmosis)
on:
workflow_call:
inputs:
unittest:
required: false
default: false
type: boolean
proptest:
required: false
default: false
Expand All @@ -25,20 +29,21 @@ jobs:
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Disk Usage
run: df -h
- name: Cleanup runner
run: sudo rm -rf /usr/local/share/boost && sudo rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && sudo rm -rf /opt/hostedtoolcache/CodeQL && sudo docker image prune --all --force
run: sudo rm -rf /usr/local/share/boost && sudo rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && sudo rm -rf /opt/hostedtoolcache/CodeQL && sudo docker prune --force
- name: Disk Usage
run: df -h
- name: Restore dependencies
id: restore-cache
uses: actions/cache/restore@v4
with:
path: |
~/.cache/cachepot
~/.cargo
~/go
~/target
key: ${{ runner.os }}-cargo-osmosis-${{github.sha}}
restore-keys: ${{ runner.os }}-cargo-osmosis
- name: Update PATH and RUSTC_WRAPPER
key: mykey
- name: Update PATH
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install cachepot
run: test -e $HOME/.cargo/bin/cachepot && echo "cachepot found -- skipping install" || cargo install --git https://github.com/paritytech/cachepot
Expand All @@ -47,41 +52,40 @@ jobs:
- name: Rust lint
run: cargo clippy --features test-tube --all-targets -- -D warnings
working-directory: smart-contracts/osmosis
- name: Unit tests
run: cargo unit-test
working-directory: smart-contracts/osmosis
- name: Build merkle-incentives
run: cargo test-tube-build
working-directory: smart-contracts/osmosis/contracts/merkle-incentives
- name: Test merkle-incentives
run: cargo test-tube
working-directory: smart-contracts/osmosis/contracts/merkle-incentives
- name: Build dex-router-osmosis
run: cargo test-tube-build
working-directory: smart-contracts/osmosis/contracts/dex-router-osmosis
- name: Test dex-router-osmosis
run: cargo test-tube
working-directory: smart-contracts/osmosis/contracts/dex-router-osmosis
- name: Build cl-vault
run: cargo test-tube-build
working-directory: smart-contracts/osmosis/contracts/cl-vault
- name: Test cl-vault
run: cargo test-tube
working-directory: smart-contracts/osmosis/contracts/cl-vault
- if: inputs.proptest
name: Run prop-test
run: cargo prop-test
env:
PROPTEST_CASES: 10
working-directory: smart-contracts/osmosis/contracts/cl-vault
- name: Store dependencies
if: inputs.store_deps
# - if: inputs.unittest
# name: Unit tests
# run: cargo unit-test
# working-directory: smart-contracts/osmosis
# - name: Build merkle-incentives
# run: cargo test-tube-build
# working-directory: smart-contracts/osmosis/contracts/merkle-incentives
# - name: Test merkle-incentives
# run: cargo test-tube
# working-directory: smart-contracts/osmosis/contracts/merkle-incentives
# - name: Build dex-router-osmosis
# run: cargo test-tube-build
# working-directory: smart-contracts/osmosis/contracts/dex-router-osmosis
# - name: Test dex-router-osmosis
# run: cargo test-tube
# working-directory: smart-contracts/osmosis/contracts/dex-router-osmosis
# - name: Build cl-vault
# run: cargo test-tube-build
# working-directory: smart-contracts/osmosis/contracts/cl-vault
# - name: Test cl-vault
# run: cargo test-tube
# working-directory: smart-contracts/osmosis/contracts/cl-vault
# - if: inputs.proptest
# name: Run prop-test
# run: cargo prop-test
# env:
# PROPTEST_CASES: 10
# working-directory: smart-contracts/osmosis/contracts/cl-vault
- if: inputs.store_deps
name: Store dependencies
uses: actions/cache/save@v4
with:
path: |
~/.cache/cachepot
~/.cargo
~/go
~/target
key: ${{ runner.os }}-cargo-osmosis-${{github.sha}}
key: mykey

9 changes: 6 additions & 3 deletions .github/workflows/cargo_build_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
required: true
type: string

env:
CARGO_TARGET_DIR: ~/target

jobs:
store-build-cache:
runs-on: ubuntu-latest
Expand All @@ -22,11 +25,11 @@ jobs:
~/.cache/cachepot
~/.cargo
~/go
smart-contracts/${{ inputs.workspace }}/**/target
~/target
key: ${{ runner.os }}-cargo-${{ inputs.workspace }}-${{github.sha}}
restore-keys: ${{ runner.os }}-cargo-${{ inputs.workspace }}
- name: Install cachepot
run: test -e $HOME/.cargo/bin/cachepot && echo "cachepot found -- skipping install" || cargo install --git https://github.com/paritytech/cachepot
run: test -e ~/.cargo/bin/cachepot && echo "cachepot found -- skipping install" || cargo install --git https://github.com/paritytech/cachepot
- name: Rust check
run: cargo check --all-targets --features test-tube
working-directory: smart-contracts/${{ inputs.workspace }}
Expand All @@ -39,5 +42,5 @@ jobs:
~/.cache/cachepot
~/.cargo
~/go
smart-contracts/${{ inputs.workspace }}/**/target
~/target
key: ${{ runner.os }}-cargo-${{ inputs.workspace }}-${{github.sha}}
19 changes: 12 additions & 7 deletions .github/workflows/rust_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
default: true
type: boolean

env:
RUSTC_WRAPPER: cachepot
CARGO_TARGET_DIR: ~/target

jobs:
checks:
runs-on: ubuntu-latest
Expand All @@ -28,16 +32,17 @@ jobs:
path: |
~/.cargo
~/go
smart-contracts/${{ inputs.workspace }}/**/target
key: ${{ runner.os }}-cargo-${{ inputs.workspace }}-$GITHUB_SHA
restore-keys: ${{ runner.os }}-cargo-${{ inputs.workspace }}
key: mykey
# fail-on-cache-miss: true
- name: Update PATH
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Rust lint
run: cargo lint
working-directory: smart-contracts/${{ inputs.workspace }}/${{ inputs.target }}
run: cargo clippy --features test-tube --all-targets -- -D warnings
working-directory: smart-contracts/${{ inputs.workspace }}
- name: Rust format check
run: cargo fmt --all -- --check
working-directory: smart-contracts/${{ inputs.workspace }}/${{ inputs.target }}
- name: Run unit-tests
if: inputs.unit_tests
- if: inputs.unit_tests
name: Run unit-tests
run: cargo unit-test
working-directory: smart-contracts/${{ inputs.workspace }}/${{ inputs.target }}
18 changes: 11 additions & 7 deletions .github/workflows/test_tube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ on:
- '.github/workflows/test_tube.yml'
- '.github/workflows/all_checks_osmosis.yml'
push:
branches:
- main
paths:
- 'smart-contracts/osmosis/**/Cargo.toml'
- 'smart-contracts/osmosis/**.rs'
- '.github/workflows/test_tube.yml'
- '.github/workflows/all_checks_osmosis.yml'
# branches:
# - main
# paths:
# - 'smart-contracts/osmosis/**/Cargo.toml'
# - 'smart-contracts/osmosis/**.rs'
# - '.github/workflows/test_tube.yml'
# - '.github/workflows/all_checks_osmosis.yml'
workflow_dispatch:

jobs:
post-merge:
uses: ./.github/workflows/all_checks_osmosis.yml
if: github.event_name == 'push'
with:
unittest: true
proptest: true
store_deps: true
# pre-commit:
# uses: ./.github/workflows/all_checks_osmosis.yml
# if: github.event_name == 'pull_request'

0 comments on commit cb2030c

Please sign in to comment.