From de0f66d58dcc1386f5b7b21826722c774e1fa139 Mon Sep 17 00:00:00 2001 From: Daniel Raniz Raneland Date: Wed, 14 Dec 2022 08:20:49 +0100 Subject: [PATCH 1/4] Add caching to CI pipeline --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4155493..720e4c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,16 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo - uses: actions-rs/toolchain@v1 with: toolchain: 1.59.0 @@ -41,6 +51,16 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo - uses: actions-rs/toolchain@v1 with: toolchain: 1.59.0 @@ -61,6 +81,16 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo - uses: actions-rs/toolchain@v1 with: toolchain: 1.59.0 @@ -79,6 +109,16 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo - uses: actions-rs/toolchain@v1 with: toolchain: 1.59.0 @@ -99,6 +139,16 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -121,6 +171,16 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo - uses: actions-rs/toolchain@v1 with: toolchain: 1.59.0 From 62c89229bcc137713706a7fe66d506c4d9cc6b49 Mon Sep 17 00:00:00 2001 From: Daniel Raniz Raneland Date: Wed, 14 Dec 2022 08:38:55 +0100 Subject: [PATCH 2/4] Add cache cleaning if cache wasn't hit --- .github/workflows/ci.yml | 62 +++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 720e4c4..6f5ba53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,15 +13,16 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/cache@v3 + id: cargo-cache with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-cargo + ${{ runner.os }}-cargo-dependencies - uses: actions-rs/toolchain@v1 with: toolchain: 1.59.0 @@ -40,6 +41,11 @@ jobs: with: command: test args: --all --verbose --exclude rage --all-features + - name: Autoclean the cache + if: steps.cargo-cache.outputs.cache-hit != 'true' + run: + cargo install --no-default-features --features ci-autoclean cargo-cache + cargo-cache build: name: Build target ${{ matrix.target }} @@ -52,15 +58,16 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/cache@v3 + id: cargo-cache with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-cargo + ${{ runner.os }}-cargo-dependencies - uses: actions-rs/toolchain@v1 with: toolchain: 1.59.0 @@ -74,6 +81,11 @@ jobs: - name: Build for target working-directory: ./age run: cargo build --verbose --no-default-features --target ${{ matrix.target }} + - name: Autoclean the cache + if: steps.cargo-cache.outputs.cache-hit != 'true' + run: + cargo install --no-default-features --features ci-autoclean cargo-cache + cargo-cache bitrot: name: Bitrot @@ -82,15 +94,16 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/cache@v3 + id: cargo-cache with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-cargo + ${{ runner.os }}-cargo-dependencies - uses: actions-rs/toolchain@v1 with: toolchain: 1.59.0 @@ -102,6 +115,11 @@ jobs: with: command: check args: --tests --examples --benches --all-features + - name: Autoclean the cache + if: steps.cargo-cache.outputs.cache-hit != 'true' + run: + cargo install --no-default-features --features ci-autoclean cargo-cache + cargo-cache clippy: name: Clippy (1.59.0) @@ -110,15 +128,16 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/cache@v3 + id: cargo-cache with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-cargo + ${{ runner.os }}-cargo-dependencies - uses: actions-rs/toolchain@v1 with: toolchain: 1.59.0 @@ -132,6 +151,11 @@ jobs: name: Clippy (1.59.0) token: ${{ secrets.GITHUB_TOKEN }} args: --all-features --all-targets -- -D warnings + - name: Autoclean the cache + if: steps.cargo-cache.outputs.cache-hit != 'true' + run: + cargo install --no-default-features --features ci-autoclean cargo-cache + cargo-cache codecov: name: Code coverage @@ -140,15 +164,16 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/cache@v3 + id: cargo-cache with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-cargo + ${{ runner.os }}-cargo-dependencies - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -164,6 +189,11 @@ jobs: uses: codecov/codecov-action@v3.1.1 with: fail_ci_if_error: true + - name: Autoclean the cache + if: steps.cargo-cache.outputs.cache-hit != 'true' + run: + cargo install --no-default-features --features ci-autoclean cargo-cache + cargo-cache doc-links: name: Intra-doc links @@ -172,15 +202,15 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/cache@v3 + id: cargo-cache with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo + key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }} + ${{ runner.os }}-cargo-dependencies - uses: actions-rs/toolchain@v1 with: toolchain: 1.59.0 @@ -197,6 +227,12 @@ jobs: with: command: doc args: --all --exclude rage --all-features --document-private-items + - name: Autoclean the cache + if: steps.cargo-cache.outputs.cache-hit != 'true' + run: + cargo install --no-default-features --features ci-autoclean cargo-cache + cargo-cache + fmt: name: Rustfmt From 5161fc8fe65a9c924ecf3a6322f45a7d4dc8c831 Mon Sep 17 00:00:00 2001 From: Daniel Raniz Raneland Date: Wed, 14 Dec 2022 08:53:11 +0100 Subject: [PATCH 3/4] Disable uploading code coverage report --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f5ba53..4db373e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -185,10 +185,10 @@ jobs: with: version: '0.19.1' args: --workspace --release --all-features --timeout 180 --out Xml - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3.1.1 - with: - fail_ci_if_error: true +# - name: Upload coverage to Codecov +# uses: codecov/codecov-action@v3.1.1 +# with: +# fail_ci_if_error: true - name: Autoclean the cache if: steps.cargo-cache.outputs.cache-hit != 'true' run: From 803ff5e1af157fa8a6205a9b607f18c36e7ab284 Mon Sep 17 00:00:00 2001 From: Daniel Raniz Raneland Date: Wed, 14 Dec 2022 11:33:07 +0100 Subject: [PATCH 4/4] Cache installation of cargo-vet --- .github/workflows/audits.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/audits.yml b/.github/workflows/audits.yml index db1d6fc..063dc01 100644 --- a/.github/workflows/audits.yml +++ b/.github/workflows/audits.yml @@ -11,6 +11,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: actions/cache@v3 + id: cargo-cache + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + key: ${{ runner.os }}-cargo-vet - uses: actions-rs/toolchain@v1 with: