ci: unify cache keys in actions (#890)

* ci: unify cache keys in actions

* some docs

* because empty strings are false in JS

* update comment

* fix build cache naming
This commit is contained in:
Clement Tsang 2022-11-11 23:45:27 -05:00 committed by GitHub
parent 1960c40a30
commit f41e7cd66d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 22 deletions

View File

@ -19,11 +19,10 @@ on:
type: string
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
BTM_GENERATE: true
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_HUSKY_DONT_INSTALL_HOOKS: true
jobs:
build-binaries:
@ -137,8 +136,18 @@ jobs:
sh rustup.sh --default-toolchain stable -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Enable Rust cache
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # 2.2.0
with:
shared-key: build-cache-${{ matrix.info.target }}
save-if: "false"
- name: Build
uses: ClementTsang/cargo-action@v0.0.3
env:
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
BTM_GENERATE: true
with:
command: build
args: --release --verbose --locked --target=${{ matrix.info.target }} --features deploy
@ -199,8 +208,6 @@ jobs:
build-msi:
name: "Build MSI installer"
runs-on: "windows-2019"
env:
BTM_GENERATE: ""
steps:
- name: Checkout repository
uses: actions/checkout@v3
@ -222,8 +229,18 @@ jobs:
toolchain: stable
target: x86_64-pc-windows-msvc
- name: Enable Rust cache
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # 2.2.0
with:
key: "build-cache-x86_64-pc-windows-msvc"
save-if: "false"
- name: Build MSI file
shell: powershell
env:
BTM_GENERATE: ""
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
run: |
cargo install cargo-wix --version 0.3.1 --locked
cargo wix init
@ -300,8 +317,18 @@ jobs:
toolchain: stable
target: ${{ matrix.info.target }}
- name: Enable Rust cache
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # 2.2.0
with:
shared-key: build-cache-${{ matrix.info.target }}
save-if: "false"
- name: Build
uses: ClementTsang/cargo-action@v0.0.3
env:
BTM_GENERATE: true
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
with:
command: build
args: --release --locked --verbose --features deploy --target ${{ matrix.info.target }}
@ -320,6 +347,10 @@ jobs:
- name: Build Debian release (x86-64)
if: matrix.info.cross == false
env:
BTM_GENERATE: true
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
run: |
cargo install cargo-deb --version 1.38.0 --locked
cargo deb --no-build --target ${{ matrix.info.target }}
@ -327,6 +358,10 @@ jobs:
- name: Build Debian release (ARM)
if: matrix.info.cross == true
env:
BTM_GENERATE: true
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
run: |
docker pull ${{ matrix.info.container }}
docker run -t --rm --mount type=bind,source="$(pwd)",target=/volume ${{ matrix.info.container }} "--variant ${{ matrix.info.dpkg }} --target ${{ matrix.info.target }} --no-build" "/volume"

View File

@ -1,17 +1,18 @@
# Main CI workflow to validate PRs.
# Main CI workflow to validate PRs and branches are correctly formatted
# and pass tests.
#
# CI workflow based on:
# CI workflow was based on a lot of work from other people:
# - https://github.com/heim-rs/heim/blob/master/.github/workflows/ci.yml
# - https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml
# - https://www.reillywood.com/blog/rust-faster-ci/
# - https://matklad.github.io/2021/09/04/fast-rust-builds.html
#
# It should run the following:
# Supported platforms:
# Supported platforms run the following tasks:
# - cargo fmt
# - cargo test
# - cargo clippy after (apparently faster to do so)
# - cargo test (built/test in separate steps)
# - cargo clippy (apparently faster to do it after the build/test)
#
# Unsupported platforms:
# Unsupported platforms run the following tasks:
# - cargo check
name: ci
@ -24,6 +25,7 @@ on:
- master
env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_HUSKY_DONT_INSTALL_HOOKS: true
@ -85,10 +87,10 @@ jobs:
target: ${{ matrix.info.target }}
- name: Enable Rust cache
uses: Swatinem/rust-cache@22c9328bcba27aa81a32b1bef27c7e3c78052531 # 2.0.1
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # 2.2.0
if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork
with:
key: ${{ matrix.info.target }}
shared-key: build-cache-${{ matrix.info.target }}
- name: Check cargo fmt
run: cargo fmt --all -- --check
@ -228,10 +230,10 @@ jobs:
target: ${{ matrix.info.target }}
- name: Enable Rust cache
uses: Swatinem/rust-cache@22c9328bcba27aa81a32b1bef27c7e3c78052531 # 2.0.1
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # 2.2.0
if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork
with:
key: ${{ matrix.info.target }}
shared-key: build-cache-${{ matrix.info.target }}
- name: Check
uses: ClementTsang/cargo-action@v0.0.3

View File

@ -1,4 +1,5 @@
# Code coverage generation via cargo-llvm-cov, which is then uploaded to codecov.
# Code coverage generation via cargo-llvm-cov, which is then uploaded to Codecov.
# Codecov will report back via a comment if run on a PR.
name: codecov
@ -43,8 +44,7 @@ jobs:
toolchain: stable
- name: Enable Rust cache
uses: Swatinem/rust-cache@22c9328bcba27aa81a32b1bef27c7e3c78052531 # 2.0.1
if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # 2.2.0
- name: Install cargo-llvm-cov
run: |

View File

@ -24,7 +24,7 @@ If you want to directly contribute documentation changes or code, follow this! T
3. Make any documentation changes if necessary - if you add a new feature, it'll probably need documentation changes.
4. Commit and create a pull request to merge into the `master` branch. **Please follow the pull request template**.
5. Ask/wait for a maintainer to review your pull request.
- Check if tests pass. These consist of clippy lints, rustfmt checks, and basic tests.
- Check if the CI workflow passes. These consist of clippy lints, rustfmt checks, and basic tests.
- If changes are suggested or any comments are made, they should probably be addressed.
6. Once it looks good, it'll be merged! Note that _generally_, PRs are squashed, though feel free to ask otherwise if that isn't preferable.

View File

@ -28,6 +28,6 @@ The expected workflow for a pull request is:
3. Make any documentation changes if necessary - if you add a new feature, it'll probably need documentation changes. See [here](./documentation.md) for tips on documentation.
4. Commit and create a pull request to merge into the `master` branch. **Please follow the pull request template**.
5. Ask/wait for a maintainer to review your pull request.
- Check if tests pass. These consist of clippy lints, rustfmt checks, and basic tests.
- Check if the CI workflow passes. These consist of clippy lints, rustfmt checks, and basic tests.
- If changes are suggested or any comments are made, they should probably be addressed.
6. Once it looks good, it'll be merged! Note that _generally_, PRs are squashed, though feel free to ask otherwise if that isn't preferable.