From b144472e924f2c61d29ab7d77d7b52f6ec817421 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Thu, 12 Nov 2026 08:41:46 +0800 Subject: [PATCH] CI: run the spec check in the CI tools image, pin actions and toolchains, add lint and Renovate --- .github/workflows/check.yml | 79 +++++++++++++++++++++++-------------- .github/workflows/lint.yml | 24 +++++++++++ renovate.json | 4 ++ 3 files changed, 78 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 renovate.json diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index d1ac8da..e6ad40d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -5,52 +5,73 @@ on: branches: [main] pull_request: +permissions: + contents: read + +# A newer push to the same pull request supersedes this run; a branch's runs +# queue instead. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +# Container jobs default to `sh`; the steps are bash. +defaults: + run: + shell: bash + jobs: # Every file matches its spec, and the generated schemas match the specs. + # In the org's CI tools image, which has cue (v0.17.1) and jq; harden-runner + # is for VM jobs. specs: name: specs - runs-on: ubuntu-latest - env: - # Keep in step with cue.mod/module.cue. - CUE_VERSION: v0.17.1 + runs-on: ubuntu-24.04 + timeout-minutes: 15 + container: ghcr.io/comlineproject/ci-tools@sha256:b9301f9caf3e47f0b839de85efda178f698a55daf7fc387b463adeec93ecd433 steps: - - uses: actions/checkout@v4 - # The release download fails now and then (GitHub answering 504), so - # cue is cached per version, and fetched with retries only on a miss. - - name: Cache cue - id: cue-cache - uses: actions/cache@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - path: ~/.local/cue - key: cue-${{ env.CUE_VERSION }}-linux-amd64 - - name: Install cue - if: steps.cue-cache.outputs.cache-hit != 'true' - # To a file, not piped into tar: a retry would append to a half-read - # stream. + persist-credentials: false + # The image's cue is the version the module declares: a bump of one + # without the other fails here. + - name: cue is the version cue.mod/module.cue declares run: | - mkdir -p ~/.local/cue - curl -fsSL --retry 5 --retry-all-errors --retry-delay 5 -o cue.tar.gz \ - "https://github.com/cue-lang/cue/releases/download/$CUE_VERSION/cue_${CUE_VERSION}_linux_amd64.tar.gz" - tar -xzf cue.tar.gz -C ~/.local/cue cue - rm cue.tar.gz - - run: echo "$HOME/.local/cue" >> "$GITHUB_PATH" + declared=$(sed -n 's/^[[:space:]]*version: "\(.*\)"$/\1/p' cue.mod/module.cue) + [ -n "$declared" ] + cue version | grep -Fx "cue version $declared" - run: specs/check.sh --check - name: VERSION is a spec version run: grep -Eqx '[0-9]+\.[0-9]+' VERSION # The comline-catalog crate (rust/): its tests, its minimum Rust, and a # no_std build. specs/check.sh above keeps its generated data current. + # Not in the image: it has neither clippy, nor the wasm target, nor the + # minimum Rust, so the exact toolchains come from dtolnay/rust-toolchain. rust: name: rust crate - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 15 defaults: run: + shell: bash working-directory: rust steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable 1.82.0 --profile minimal --component clippy - - run: rustup target add wasm32-unknown-unknown --toolchain stable - - run: cargo +stable test - - run: cargo +stable clippy --all-targets -- -D warnings + - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + # The crate's minimum supported Rust (`rust-version` in Cargo.toml). + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1 + with: + toolchain: 1.82.0 + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1 + with: + toolchain: 1.99.1 + components: clippy + targets: wasm32-unknown-unknown + - run: cargo +1.99.1 test + - run: cargo +1.99.1 clippy --all-targets -- -D warnings - run: cargo +1.82.0 check - - run: cargo +stable build --target wasm32-unknown-unknown + - run: cargo +1.99.1 build --target wasm32-unknown-unknown diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..398fc15 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,24 @@ +name: Lint + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +# Not `lint-...`: the reusable workflow's own group is that, and groups are +# case-insensitive, so the same name would make the call wait on itself. +concurrency: + group: ci-lint-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + lint: + name: lint + permissions: + contents: read + uses: ComlineProject/.github/.github/workflows/lint.yml@797d473553d7f2fc50895bb2573acb83ac63c7cb # main, no release tag yet + with: + renovate-config: renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..f8b00a1 --- /dev/null +++ b/renovate.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["github>ComlineProject/.github:renovate-config"] +}