diff --git a/.github/cue/preload-cache.cue b/.github/cue/preload-cache.cue new file mode 100644 index 0000000..7a39544 --- /dev/null +++ b/.github/cue/preload-cache.cue @@ -0,0 +1,73 @@ +package workflows + +preloadCache: { + name: "preload-cache" + + on: { + push: { + branches: [defaultBranch] + paths: [ + "**/Cargo.lock", + "**/Cargo.toml", + ".github/workflows/rust.yml", + ] + } + + // Run every Monday at 7:45am UTC to cover any upstream Rust stable release. + schedule: [{cron: "45 7 * * 1"}] + + // Allow manually running this workflow. + workflow_dispatch: null + } + + concurrency: { + group: "${{ github.workflow }}-${{ github.ref }}" + "cancel-in-progress": true + } + + env: { + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: "always" + RUST_BACKTRACE: 1 + RUSTFLAGS: "-D warnings" + } + + jobs: { + check_stable: { + name: "check / stable" + defaults: run: shell: "bash" + strategy: { + "fail-fast": false + matrix: platform: [ + "macos-latest", + "ubuntu-latest", + "windows-latest", + ] + } + "runs-on": "${{ matrix.platform }}" + steps: [ + _#checkoutCode, + _#installRust, + _#cacheRust, + _#cargoCheck, + ] + } + + // Minimum Supported Rust Version + check_msrv: { + name: "check / msrv" + "runs-on": defaultRunner + steps: [ + _#checkoutCode, + { + name: "Get MSRV from package metadata" + id: "msrv" + run: "awk -F '\"' '/rust-version/{ print \"version=\" $2 }' Cargo.toml >> $GITHUB_OUTPUT" + }, + _#installRust & {with: toolchain: "${{ steps.msrv.outputs.version }}"}, + _#cacheRust, + _#cargoCheck, + ] + } + } +} diff --git a/.github/cue/workflows.cue b/.github/cue/workflows.cue index 1567441..84fc37c 100644 --- a/.github/cue/workflows.cue +++ b/.github/cue/workflows.cue @@ -12,6 +12,7 @@ workflows: [...{ workflows: [ {workflow: githubActions}, {workflow: githubPages}, + {workflow: preloadCache}, {workflow: rust}, {workflow: wordsmith}, ] diff --git a/.github/workflows/preload-cache.yml b/.github/workflows/preload-cache.yml new file mode 100644 index 0000000..abfff03 --- /dev/null +++ b/.github/workflows/preload-cache.yml @@ -0,0 +1,70 @@ +# This file is generated by .github/cue/ci_tool.cue; DO NOT EDIT! + +name: preload-cache +"on": + push: + branches: + - main + paths: + - '**/Cargo.lock' + - '**/Cargo.toml' + - .github/workflows/rust.yml + schedule: + - cron: 45 7 * * 1 + workflow_dispatch: null +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +env: + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + RUSTFLAGS: -D warnings +jobs: + check_stable: + name: check / stable + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + platform: + - macos-latest + - ubuntu-latest + - windows-latest + runs-on: ${{ matrix.platform }} + steps: + - name: Checkout source code + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - name: Install stable Rust toolchain + uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d + with: + toolchain: stable + components: clippy,rustfmt + - name: Cache dependencies + uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f + with: + shared-key: workflow + - name: Check packages and dependencies for errors + run: cargo check --locked + check_msrv: + name: check / msrv + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - name: Get MSRV from package metadata + id: msrv + run: awk -F '"' '/rust-version/{ print "version=" $2 }' Cargo.toml >> $GITHUB_OUTPUT + - name: Install ${{ steps.msrv.outputs.version }} Rust toolchain + uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d + with: + toolchain: ${{ steps.msrv.outputs.version }} + components: clippy,rustfmt + - name: Cache dependencies + uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f + with: + shared-key: workflow + - name: Check packages and dependencies for errors + run: cargo check --locked