From bb9eefe82d90c7c9f44738b941d67073cef7f1ca Mon Sep 17 00:00:00 2001 From: Lars Lubkoll <11710767+lubkoll@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:51:24 +0000 Subject: [PATCH 1/3] [CI] Add cachepot -- part2: use cache --- .github/workflows/all_checks_osmosis.yml | 12 ++++++++---- .github/workflows/cargo_build_cache.yml | 9 ++++++--- .github/workflows/rust_basic.yml | 22 +++++++++++++++------- .github/workflows/test_tube.yml | 4 ++++ 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/.github/workflows/all_checks_osmosis.yml b/.github/workflows/all_checks_osmosis.yml index 38f1c798f..b4b501107 100644 --- a/.github/workflows/all_checks_osmosis.yml +++ b/.github/workflows/all_checks_osmosis.yml @@ -3,6 +3,10 @@ name: Test Tube (osmosis) on: workflow_call: inputs: + unittest: + required: false + default: false + type: boolean proptest: required: false default: false @@ -26,7 +30,7 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable - 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 system prune --all --force - name: Restore dependencies id: restore-cache uses: actions/cache/restore@v4 @@ -36,7 +40,7 @@ jobs: ~/.cargo ~/go ~/target - key: ${{ runner.os }}-cache-osmosis-${{github.sha}} + key: ${{ runner.os }}-cache-osmosis-${{ github.sha }} restore-keys: ${{ runner.os }}-cache-osmosis - name: Update PATH run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH @@ -75,7 +79,7 @@ jobs: PROPTEST_CASES: 10 working-directory: smart-contracts/osmosis/contracts/cl-vault - name: Store dependencies - if: ${{ (inputs.store_deps) && (steps.restore-cache.outputs.cache-hit == false) }}$ + if: ${{ (inputs.store_deps == 'true') && (steps.restore-cache.outputs.cache-hit == 'false') }}$ uses: actions/cache/save@v4 with: path: | @@ -83,5 +87,5 @@ jobs: ~/.cargo ~/go ~/target - key: ${{ runner.os }}-cache-osmosis-${{github.sha}} + key: ${{ runner.os }}-cache-osmosis-${{ github.sha }} diff --git a/.github/workflows/cargo_build_cache.yml b/.github/workflows/cargo_build_cache.yml index 1921ab46b..1d1b107cc 100644 --- a/.github/workflows/cargo_build_cache.yml +++ b/.github/workflows/cargo_build_cache.yml @@ -7,6 +7,9 @@ on: required: true type: string +env: + CARGO_TARGET_DIR: ~/target + jobs: store-build-cache: runs-on: ubuntu-latest @@ -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 }} @@ -39,5 +42,5 @@ jobs: ~/.cache/cachepot ~/.cargo ~/go - smart-contracts/${{ inputs.workspace }}/**/target + ~/target key: ${{ runner.os }}-cargo-${{ inputs.workspace }}-${{github.sha}} diff --git a/.github/workflows/rust_basic.yml b/.github/workflows/rust_basic.yml index 2e5549cdc..758ec050c 100644 --- a/.github/workflows/rust_basic.yml +++ b/.github/workflows/rust_basic.yml @@ -14,6 +14,10 @@ on: default: true type: boolean +env: + RUSTC_WRAPPER: cachepot + CARGO_TARGET_DIR: ~/target + jobs: checks: runs-on: ubuntu-latest @@ -23,21 +27,25 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable - name: Restore dependencies + id: restore-cache uses: actions/cache/restore@v4 with: path: | + ~/.cache/cachepot ~/.cargo ~/go - smart-contracts/${{ inputs.workspace }}/**/target - key: ${{ runner.os }}-cargo-${{ inputs.workspace }}-$GITHUB_SHA - restore-keys: ${{ runner.os }}-cargo-${{ inputs.workspace }} + ~/target + key: ${{ runner.os }}-cache-osmosis-${{ github.sha }} + restore-keys: ${{ runner.os }}-cache-osmosis + - 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 }} diff --git a/.github/workflows/test_tube.yml b/.github/workflows/test_tube.yml index 2cb68d52c..b94245b19 100644 --- a/.github/workflows/test_tube.yml +++ b/.github/workflows/test_tube.yml @@ -24,5 +24,9 @@ jobs: 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' From 2ae865bc579945cd143c1883ce4781ca45a20bca Mon Sep 17 00:00:00 2001 From: Lars Lubkoll <11710767+lubkoll@users.noreply.github.com> Date: Mon, 26 Aug 2024 08:56:42 +0000 Subject: [PATCH 2/3] Do not use cache for unit-tests --- .github/workflows/rust_basic.yml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/.github/workflows/rust_basic.yml b/.github/workflows/rust_basic.yml index 758ec050c..b1fc2fd4d 100644 --- a/.github/workflows/rust_basic.yml +++ b/.github/workflows/rust_basic.yml @@ -14,10 +14,6 @@ on: default: true type: boolean -env: - RUSTC_WRAPPER: cachepot - CARGO_TARGET_DIR: ~/target - jobs: checks: runs-on: ubuntu-latest @@ -26,21 +22,8 @@ jobs: uses: actions/checkout@v3 - name: Install Rust uses: dtolnay/rust-toolchain@stable - - name: Restore dependencies - id: restore-cache - uses: actions/cache/restore@v4 - with: - path: | - ~/.cache/cachepot - ~/.cargo - ~/go - ~/target - key: ${{ runner.os }}-cache-osmosis-${{ github.sha }} - restore-keys: ${{ runner.os }}-cache-osmosis - - name: Update PATH - run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH - name: Rust lint - run: cargo clippy --features test-tube --all-targets -- -D warnings + run: cargo clippy --all-targets -- -D warnings working-directory: smart-contracts/${{ inputs.workspace }} - name: Rust format check run: cargo fmt --all -- --check From c9e8efb08bd33c5278136ef1bf994a5910c23e58 Mon Sep 17 00:00:00 2001 From: Lars Lubkoll <11710767+lubkoll@users.noreply.github.com> Date: Mon, 26 Aug 2024 09:14:36 +0000 Subject: [PATCH 3/3] Improve if condition for storing cache --- .github/workflows/all_checks_osmosis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/all_checks_osmosis.yml b/.github/workflows/all_checks_osmosis.yml index b4b501107..02d860e5b 100644 --- a/.github/workflows/all_checks_osmosis.yml +++ b/.github/workflows/all_checks_osmosis.yml @@ -79,7 +79,7 @@ jobs: PROPTEST_CASES: 10 working-directory: smart-contracts/osmosis/contracts/cl-vault - name: Store dependencies - if: ${{ (inputs.store_deps == 'true') && (steps.restore-cache.outputs.cache-hit == 'false') }}$ + if: inputs.store_deps && !(steps.restore-cache.outputs.cache-hit == 'false') uses: actions/cache/save@v4 with: path: |