Skip to content

Commit

Permalink
Merge pull request #8 from artichoke/lopopolo/only-cache-rust-if-lock…
Browse files Browse the repository at this point in the history
…file-present

Only enable Rust artifact caching when a `Cargo.lock` is present
  • Loading branch information
lopopolo authored Nov 1, 2022
2 parents b625e1b + c6ba54e commit dba16fd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions build-and-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,16 @@ runs:
shell: bash
run: cargo +${{ inputs.toolchain }} version --verbose

- name: Check if Cargo.lock is present
shell: bash
id: lockfile
run: |
if [[ -f Cargo.lock ]]; then
echo "present=true" >> $GITHUB_OUTPUT
else
echo "present=false" >> $GITHUB_OUTPUT
fi
- name: Setup Rust caching
uses: Swatinem/rust-cache@v1
if: steps.lockfile.outputs.present == 'true'
17 changes: 17 additions & 0 deletions check-minimal-versions/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
name: "Minimal Versions Toolchain"
description: "Setup stable and nightly Rust toolchains for running cargo check with -Zminimal-versions"

inputs:
toolchain:
description: "Rustup toolchain"
required: true
default: "stable"

runs:
using: "composite"
steps:
Expand Down Expand Up @@ -62,5 +68,16 @@ runs:
shell: bash
run: cargo +nightly fmt --version --verbose

- name: Check if Cargo.lock is present
shell: bash
id: lockfile
run: |
if [[ -f Cargo.lock ]]; then
echo "present=true" >> $GITHUB_OUTPUT
else
echo "present=false" >> $GITHUB_OUTPUT
fi
- name: Setup Rust caching
uses: Swatinem/rust-cache@v1
if: steps.lockfile.outputs.present == 'true'
11 changes: 11 additions & 0 deletions lint-and-format/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,16 @@ runs:
shell: bash
run: cargo +nightly fmt --version --verbose

- name: Check if Cargo.lock is present
shell: bash
id: lockfile
run: |
if [[ -f Cargo.lock ]]; then
echo "present=true" >> $GITHUB_OUTPUT
else
echo "present=false" >> $GITHUB_OUTPUT
fi
- name: Setup Rust caching
uses: Swatinem/rust-cache@v1
if: steps.lockfile.outputs.present == 'true'

0 comments on commit dba16fd

Please sign in to comment.