Merge pull request #47 from SG60/renovate/tokio-tracing-monorepo #131
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
workflow_dispatch: | |
# Automatically cancel in-progress actions on the same branch | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} | |
cancel-in-progress: true | |
env: | |
# get correct commit sha for pull requests as well | |
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
- rust: aarch64-unknown-linux-musl | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: rui314/setup-mold@85c79d00377f0d32cdbae595a46de6f7c2fa6599 # v1 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target.rust }} | |
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
with: | |
cache-all-crates: "true" | |
cache-on-failure: "true" | |
# nix dev shell setup | |
# the nix community cache action needs to use this nix installer | |
- uses: nixbuild/nix-quick-install-action@5bb6a3b3abe66fd09bbf250dce8ada94f856a703 # v30 | |
with: | |
nix_conf: | | |
keep-env-derivations = true | |
keep-outputs = true | |
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16 | |
with: { name: "nix-community" } | |
- name: Restore and save Nix store | |
uses: nix-community/cache-nix-action@135667ec418502fa5a3598af6fb9eb733888ce6a # v6.1.3 | |
with: | |
# restore and save a cache using this key | |
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} | |
# if there's no cache hit, restore a cache by this prefix | |
restore-prefixes-first-match: nix-${{ runner.os }}- | |
# collect garbage until the Nix store size (in bytes) is at most this number | |
# before trying to save a new cache | |
# 1G = 1073741824 | |
gc-max-store-size-linux: 1G | |
# do purge caches | |
purge: true | |
# purge all versions of the cache | |
purge-prefixes: nix-${{ runner.os }}- | |
# created more than this number of seconds ago | |
purge-created: 0 | |
# or, last accessed more than this number of seconds ago | |
# relative to the start of the `Post Restore and save Nix store` phase | |
purge-last-accessed: 0 | |
# except any version with the key that is the same as the `primary-key` | |
purge-primary-key: never | |
- name: test | |
run: nix develop -c cargo test --locked | |
- name: build | |
env: | |
TARGET_CC: clang | |
run: nix develop .#${{ matrix.target.rust }} -c cargo build --target ${{ matrix.target.rust }} --release --locked |