Skip to content

Commit

Permalink
feat(ci): cargo dependency cache (#1880)
Browse files Browse the repository at this point in the history
This commit reduces the time needed for CI by caching the downloaded dependencies.

---------

Signed-off-by: ozkanonur <work@onurozkan.dev>
  • Loading branch information
onur-ozkan authored Jun 26, 2023
1 parent 08bfef7 commit 7388372
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/actions/cargo-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Set up cargo cache'
description: 'Sets up the cargo cache for the workflow'
runs:
using: 'composite'
steps:
- name: Checkout repository
uses: actions/checkout@v3

- 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/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
9 changes: 9 additions & 0 deletions .github/workflows/adex-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Start checking code format and lint
run: |
cargo fmt --manifest-path ./mm2src/adex_cli/Cargo.toml --all -- --check
Expand Down Expand Up @@ -62,6 +65,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Start testing
run: |
cargo test --manifest-path ./mm2src/adex_cli/Cargo.toml
Expand Down Expand Up @@ -90,6 +96,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Start building
run: |
cargo build --manifest-path ./mm2src/adex_cli/Cargo.toml
24 changes: 24 additions & 0 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -100,6 +103,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -147,6 +153,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $Env:GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
if (test-path "./MM_VERSION") {
Expand Down Expand Up @@ -196,6 +205,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -257,6 +269,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -305,6 +320,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -366,6 +384,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -429,6 +450,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/fmt-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
sudo apt-get -y install libudev-dev
if: matrix.os == 'ubuntu-latest'

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: fmt check
run: cargo fmt -- --check

Expand All @@ -42,5 +45,8 @@ jobs:
rustup default nightly-2022-10-29
rustup target add wasm32-unknown-unknown
- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: wasm code lint
run: cargo clippy --target wasm32-unknown-unknown -- --D warnings
24 changes: 24 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -92,6 +95,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -133,6 +139,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $Env:GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
if (test-path "./MM_VERSION") {
Expand Down Expand Up @@ -176,6 +185,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -231,6 +243,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -273,6 +288,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -328,6 +346,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down Expand Up @@ -385,6 +406,9 @@ jobs:
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Build
run: |
rm -f ./MM_VERSION
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
rustup toolchain install nightly-2022-10-29 --no-self-update --profile=minimal
rustup default nightly-2022-10-29
- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Test
run: |
# wget -O - https://raw.githubusercontent.com/KomodoPlatform/komodo/master/zcutil/fetch-params-alt.sh | bash
Expand All @@ -47,6 +50,9 @@ jobs:
rustup default nightly-2022-10-29
rustup target add x86_64-apple-darwin
- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Test
run: |
# wget -O - https://raw.githubusercontent.com/KomodoPlatform/komodo/master/zcutil/fetch-params-alt.sh | bash
Expand All @@ -68,6 +74,9 @@ jobs:
rustup toolchain install nightly-2022-10-29 --no-self-update --profile=minimal
rustup default nightly-2022-10-29
- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Test
run: |
# Invoke-WebRequest -Uri https://github.com/KomodoPlatform/komodo/raw/d456be35acd1f8584e1e4f971aea27bd0644d5c5/zcutil/wget64.exe -OutFile \wget64.exe
Expand Down Expand Up @@ -104,6 +113,9 @@ jobs:
rustup toolchain install nightly-2022-10-29 --no-self-update --profile=minimal
rustup default nightly-2022-10-29
- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Test
run: cargo test --test 'mm2_tests_main'

Expand Down Expand Up @@ -145,6 +157,9 @@ jobs:
rustup toolchain install nightly-2022-10-29 --no-self-update --profile=minimal
rustup default nightly-2022-10-29
- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Test
run: cargo test --test 'mm2_tests_main'

Expand All @@ -164,6 +179,9 @@ jobs:
rustup toolchain install nightly-2022-10-29 --no-self-update --profile=minimal
rustup default nightly-2022-10-29
- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Test
run: |
wget -O - https://raw.githubusercontent.com/KomodoPlatform/komodo/master/zcutil/fetch-params-alt.sh | bash
Expand Down Expand Up @@ -197,5 +215,8 @@ jobs:
sudo tar -xzvf geckodriver-v0.32.2-linux64.tar.gz -C /bin
sudo chmod +x /bin/geckodriver
- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Test
run: WASM_BINDGEN_TEST_TIMEOUT=360 GECKODRIVER=/bin/geckodriver wasm-pack test --firefox --headless mm2src/mm2_main

0 comments on commit 7388372

Please sign in to comment.