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 type: string
env: env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
BTM_GENERATE: true CARGO_INCREMENTAL: 0
COMPLETION_DIR: "target/tmp/bottom/completion/" CARGO_PROFILE_DEV_DEBUG: 0
MANPAGE_DIR: "target/tmp/bottom/manpage/" CARGO_HUSKY_DONT_INSTALL_HOOKS: true
jobs: jobs:
build-binaries: build-binaries:
@ -137,8 +136,18 @@ jobs:
sh rustup.sh --default-toolchain stable -y sh rustup.sh --default-toolchain stable -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH 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 - name: Build
uses: ClementTsang/cargo-action@v0.0.3 uses: ClementTsang/cargo-action@v0.0.3
env:
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
BTM_GENERATE: true
with: with:
command: build command: build
args: --release --verbose --locked --target=${{ matrix.info.target }} --features deploy args: --release --verbose --locked --target=${{ matrix.info.target }} --features deploy
@ -199,8 +208,6 @@ jobs:
build-msi: build-msi:
name: "Build MSI installer" name: "Build MSI installer"
runs-on: "windows-2019" runs-on: "windows-2019"
env:
BTM_GENERATE: ""
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -222,8 +229,18 @@ jobs:
toolchain: stable toolchain: stable
target: x86_64-pc-windows-msvc 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 - name: Build MSI file
shell: powershell shell: powershell
env:
BTM_GENERATE: ""
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
run: | run: |
cargo install cargo-wix --version 0.3.1 --locked cargo install cargo-wix --version 0.3.1 --locked
cargo wix init cargo wix init
@ -300,8 +317,18 @@ jobs:
toolchain: stable toolchain: stable
target: ${{ matrix.info.target }} 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 - name: Build
uses: ClementTsang/cargo-action@v0.0.3 uses: ClementTsang/cargo-action@v0.0.3
env:
BTM_GENERATE: true
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
with: with:
command: build command: build
args: --release --locked --verbose --features deploy --target ${{ matrix.info.target }} args: --release --locked --verbose --features deploy --target ${{ matrix.info.target }}
@ -320,6 +347,10 @@ jobs:
- name: Build Debian release (x86-64) - name: Build Debian release (x86-64)
if: matrix.info.cross == false if: matrix.info.cross == false
env:
BTM_GENERATE: true
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
run: | run: |
cargo install cargo-deb --version 1.38.0 --locked cargo install cargo-deb --version 1.38.0 --locked
cargo deb --no-build --target ${{ matrix.info.target }} cargo deb --no-build --target ${{ matrix.info.target }}
@ -327,6 +358,10 @@ jobs:
- name: Build Debian release (ARM) - name: Build Debian release (ARM)
if: matrix.info.cross == true if: matrix.info.cross == true
env:
BTM_GENERATE: true
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
run: | run: |
docker pull ${{ matrix.info.container }} 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" 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/heim-rs/heim/blob/master/.github/workflows/ci.yml
# - https://github.com/BurntSushi/ripgrep/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://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 run the following tasks:
# Supported platforms:
# - cargo fmt # - cargo fmt
# - cargo test # - cargo test (built/test in separate steps)
# - cargo clippy after (apparently faster to do so) # - cargo clippy (apparently faster to do it after the build/test)
# #
# Unsupported platforms: # Unsupported platforms run the following tasks:
# - cargo check # - cargo check
name: ci name: ci
@ -24,6 +25,7 @@ on:
- master - master
env: env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0 CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0 CARGO_PROFILE_DEV_DEBUG: 0
CARGO_HUSKY_DONT_INSTALL_HOOKS: true CARGO_HUSKY_DONT_INSTALL_HOOKS: true
@ -85,10 +87,10 @@ jobs:
target: ${{ matrix.info.target }} target: ${{ matrix.info.target }}
- name: Enable Rust cache - 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 if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork
with: with:
key: ${{ matrix.info.target }} shared-key: build-cache-${{ matrix.info.target }}
- name: Check cargo fmt - name: Check cargo fmt
run: cargo fmt --all -- --check run: cargo fmt --all -- --check
@ -228,10 +230,10 @@ jobs:
target: ${{ matrix.info.target }} target: ${{ matrix.info.target }}
- name: Enable Rust cache - 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 if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork
with: with:
key: ${{ matrix.info.target }} shared-key: build-cache-${{ matrix.info.target }}
- name: Check - name: Check
uses: ClementTsang/cargo-action@v0.0.3 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 name: codecov
@ -43,8 +44,7 @@ jobs:
toolchain: stable toolchain: stable
- name: Enable Rust cache - 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
- name: Install cargo-llvm-cov - name: Install cargo-llvm-cov
run: | 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. 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**. 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. 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. - 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. 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. 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**. 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. 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. - 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. 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.