From 0d8abfacf6db95f5e8bcf16cb2b39819d2f11ef3 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 20 Oct 2026 23:12:57 -0400 Subject: [PATCH] ci: run the debug and release checks in a single job --- .github/workflows/ci.generated.yml | 34 ++++------------------ .github/workflows/ci.ts | 46 ++++++++---------------------- 2 files changed, 18 insertions(+), 62 deletions(-) diff --git a/.github/workflows/ci.generated.yml b/.github/workflows/ci.generated.yml index a9384a4..92fb650 100644 --- a/.github/workflows/ci.generated.yml +++ b/.github/workflows/ci.generated.yml @@ -12,15 +12,8 @@ on: - '*' jobs: build: - name: '${{ matrix.config.kind }} ${{ matrix.config.os }}' - runs-on: '${{ matrix.config.os }}' - strategy: - matrix: - config: - - os: ubuntu-latest - kind: test_release - - os: ubuntu-latest - kind: test_debug + name: build + runs-on: ubuntu-latest env: CARGO_INCREMENTAL: 0 RUST_BACKTRACE: full @@ -28,7 +21,6 @@ jobs: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1 - name: Install wasm32 target - if: matrix.config.kind == 'test_release' run: rustup target add wasm32-unknown-unknown - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 with: @@ -36,45 +28,32 @@ jobs: - uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2 with: deno-version: v2.x - - name: Build debug - if: matrix.config.kind == 'test_debug' - run: cargo build - name: Build release - if: matrix.config.kind == 'test_release' run: cargo build --target wasm32-unknown-unknown --features wasm --release - - name: Test debug - if: matrix.config.kind == 'test_debug' + - name: Test run: cargo test - name: Test tracing - if: matrix.config.kind == 'test_debug' run: cargo test --features tracing - name: Clippy - if: matrix.config.kind == 'test_debug' run: cargo clippy --all-targets -- -D warnings - name: Check formatting - if: matrix.config.kind == 'test_debug' run: cargo fmt --check - - name: Test release - if: matrix.config.kind == 'test_release' - run: cargo test --release - name: Get tag version id: get_tag_version - if: 'matrix.config.kind == ''test_release'' && startsWith(github.ref, ''refs/tags/'')' + if: 'startsWith(github.ref, ''refs/tags/'')' run: 'echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT"' - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 - if: matrix.config.kind == 'test_release' with: node-version: 24.x registry-url: 'https://registry.npmjs.org' - name: Setup and test npm deployment - if: matrix.config.kind == 'test_release' run: |- cd deployment/npm npm install node setup.js npm run test - name: Pre-release - if: 'matrix.config.kind == ''test_release'' && startsWith(github.ref, ''refs/tags/'')' + if: 'startsWith(github.ref, ''refs/tags/'')' run: |- # update config schema to have version sed -i 's/sql\/0.0.0/sql\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json @@ -83,7 +62,7 @@ jobs: # create release notes deno run -A ./scripts/generateReleaseNotes.ts ${{ steps.get_tag_version.outputs.TAG_VERSION }} > ${{ github.workspace }}-CHANGELOG.txt - name: Release - if: 'matrix.config.kind == ''test_release'' && startsWith(github.ref, ''refs/tags/'')' + if: 'startsWith(github.ref, ''refs/tags/'')' env: GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}' run: |- @@ -92,7 +71,6 @@ jobs: target/wasm32-unknown-unknown/release/plugin.wasm \ deployment/schema.json - name: Lint workflow generation - if: matrix.config.kind == 'test_debug' run: |- ./.github/workflows/ci.ts --lint ./.github/workflows/publish_npm.ts --lint diff --git a/.github/workflows/ci.ts b/.github/workflows/ci.ts index da2e5a2..96486b3 100755 --- a/.github/workflows/ci.ts +++ b/.github/workflows/ci.ts @@ -1,36 +1,22 @@ #!/usr/bin/env -S deno run -A -import { conditions, defineMatrix, expr, job, step, workflow } from "jsr:@david/gagen@^0.5.0"; +import { conditions, job, step, workflow } from "jsr:@david/gagen@^0.5.0"; const pluginName = "sql"; const cargoWasmName = `dprint_plugin_${pluginName}`; -const matrix = defineMatrix({ - config: [ - { os: "ubuntu-latest", kind: "test_release" }, - { os: "ubuntu-latest", kind: "test_debug" }, - ], -}); - -const kind = expr("matrix.config.kind"); -const os = expr("matrix.config.os"); - -const isRelease = kind.equals("test_release"); -const isDebug = kind.equals("test_debug"); const isTag = conditions.isTag(); -const isReleaseAndTag = isRelease.and(isTag); const getTagVersion = step({ id: "get_tag_version", name: "Get tag version", - if: isReleaseAndTag, + if: isTag, run: `echo "TAG_VERSION=\${GITHUB_REF/refs\\/tags\\//}" >> "$GITHUB_OUTPUT"`, outputs: ["TAG_VERSION"], }); const buildJob = job("build", { - name: `${kind} ${os}`, - runsOn: os, - strategy: { matrix }, + name: "build", + runsOn: "ubuntu-latest", env: { CARGO_INCREMENTAL: 0, RUST_BACKTRACE: "full", @@ -40,40 +26,34 @@ const buildJob = job("build", { { uses: "dsherret/rust-toolchain-file@v1" }, { name: "Install wasm32 target", - if: isRelease, run: "rustup target add wasm32-unknown-unknown", }, { uses: "Swatinem/rust-cache@v2", with: { "save-if": "${{ github.ref == 'refs/heads/main' }}" }, }, - // deno is needed by the "Lint workflow generation" step (test_debug) - // and by the "Pre-release" step (test_release on tag). Install it - // once at the top of every job to keep the matrix steps simple. + // deno is needed by the "Lint workflow generation" step and, on a tag, + // by the "Pre-release" step { uses: "denoland/setup-deno@v2", with: { "deno-version": "v2.x" }, }, - { name: "Build debug", if: isDebug, run: "cargo build" }, { name: "Build release", - if: isRelease, run: "cargo build --target wasm32-unknown-unknown --features wasm --release", }, - { name: "Test debug", if: isDebug, run: "cargo test" }, - { name: "Test tracing", if: isDebug, run: "cargo test --features tracing" }, - { name: "Clippy", if: isDebug, run: "cargo clippy --all-targets -- -D warnings" }, - { name: "Check formatting", if: isDebug, run: "cargo fmt --check" }, - { name: "Test release", if: isRelease, run: "cargo test --release" }, + { name: "Test", run: "cargo test" }, + { name: "Test tracing", run: "cargo test --features tracing" }, + { name: "Clippy", run: "cargo clippy --all-targets -- -D warnings" }, + { name: "Check formatting", run: "cargo fmt --check" }, getTagVersion, // NPM { uses: "actions/setup-node@v6", - if: isRelease, with: { "node-version": "24.x", "registry-url": "https://registry.npmjs.org", @@ -81,7 +61,6 @@ const buildJob = job("build", { }, { name: "Setup and test npm deployment", - if: isRelease, run: [ "cd deployment/npm", "npm install", @@ -93,7 +72,7 @@ const buildJob = job("build", { // GITHUB RELEASE { name: "Pre-release", - if: isReleaseAndTag, + if: isTag, run: [ "# update config schema to have version", `sed -i 's/${pluginName}\\/0.0.0/${pluginName}\\/${getTagVersion.outputs.TAG_VERSION}/' deployment/schema.json`, @@ -105,7 +84,7 @@ const buildJob = job("build", { }, { name: "Release", - if: isReleaseAndTag, + if: isTag, // gh uploads the assets to a draft and then publishes it, which immutable releases require env: { GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, run: [ @@ -117,7 +96,6 @@ const buildJob = job("build", { }, { name: "Lint workflow generation", - if: isDebug, run: [ "./.github/workflows/ci.ts --lint", "./.github/workflows/publish_npm.ts --lint",