From 03bcdadaa9a3434f070d3be37243023c7fa48125 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 17 Jun 2026 18:05:12 -0700 Subject: [PATCH] Lint on all OSs --- .github/workflows/ci.yml | 38 ++-------------------------- Herebyfile.mjs | 54 +++++++++++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed8ffbc41ab..a3a2b86b559 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -198,32 +198,7 @@ jobs: path: testdata/baselines/local lint: - strategy: - fail-fast: ${{ github.event_name == 'merge_group' }} - matrix: - config: - - os: ubuntu-latest - main: true - - os: windows-latest - skip: ${{ github.event_name == 'merge_group' }} - # Skip macOS; we do not have any build tag'd files that require checking. - # - os: macos-latest - # skip: ${{ github.event_name == 'merge_group' }} - - os: ubuntu-latest - name: 'noembed' - noembed: true - skip: ${{ github.event_name == 'merge_group' }} - exclude: - - config: - skip: true - - name: lint (${{ matrix.config.name || matrix.config.os }}) - - runs-on: ${{ matrix.config.os }} - - env: - TSGO_HEREBY_NOEMBED: ${{ (matrix.config.noembed && 'true') || 'false' }} - + runs-on: ubuntu-latest steps: - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 with: @@ -235,18 +210,9 @@ jobs: - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - uses: ./.github/actions/setup-go - # Avoid duplicate PR annotations. - - if: ${{ ! matrix.config.main }} - name: Disable PR annotations - run: | - echo "::remove-matcher owner=eslint-compact::" - echo "::remove-matcher owner=eslint-stylish::" - echo "::remove-matcher owner=tsc::" - echo "::remove-matcher owner=go::" - - run: npm ci - - run: npx hereby lint + - run: npx hereby lint:all-os format: runs-on: ubuntu-slim diff --git a/Herebyfile.mjs b/Herebyfile.mjs index 389811acd40..7b27e1f14bb 100644 --- a/Herebyfile.mjs +++ b/Herebyfile.mjs @@ -846,21 +846,63 @@ export const lint = task({ run: runLint, }); +export const lintAllOS = task({ + name: "lint:all-os", + description: "Runs golangci-lint for each GOOS variant used by this repository.", + run: runLintAllOS, +}); + +const lintTargets = [ + { name: "linux", env: { GOOS: "linux" } }, + { name: "windows", env: { GOOS: "windows" } }, + { name: "darwin", env: { GOOS: "darwin" } }, + { name: "freebsd", env: { GOOS: "freebsd" } }, + { name: "openbsd", env: { GOOS: "openbsd" } }, + { name: "netbsd", env: { GOOS: "netbsd" } }, + { name: "dragonfly", env: { GOOS: "dragonfly" } }, + { name: "solaris", env: { GOOS: "solaris" } }, + { name: "linux (noembed)", env: { GOOS: "linux" }, buildTags: ["noembed"] }, +]; + async function runLint() { await buildCustomLinter(); + const resolvedCustomLinterPath = path.resolve(customLinterPath); + await runCustomLint(resolvedCustomLinterPath); + console.log("Linting _tools"); + await runCustomLint(resolvedCustomLinterPath, { cwd: "./_tools" }); +} + +async function runLintAllOS() { + await buildCustomLinter(); + + const resolvedCustomLinterPath = path.resolve(customLinterPath); + for (const target of lintTargets) { + console.log(`Linting ${target.name}`); + await runCustomLint(resolvedCustomLinterPath, target); + } + console.log("Linting _tools"); + await runCustomLint(resolvedCustomLinterPath, { cwd: "./_tools" }); +} + +/** + * @param {string} resolvedCustomLinterPath + * @param {object} [opts] + * @param {string} [opts.cwd] + * @param {Record} [opts.env] + * @param {string[]} [opts.buildTags] + */ +async function runCustomLint(resolvedCustomLinterPath, opts = {}) { const lintArgs = ["run"]; - if (defaultGoBuildTags.length) { - lintArgs.push("--build-tags", defaultGoBuildTags.join(",")); + const buildTags = opts.buildTags ?? defaultGoBuildTags; + if (buildTags.length) { + lintArgs.push("--build-tags", buildTags.join(",")); } if (options.fix) { lintArgs.push("--fix"); } - const resolvedCustomLinterPath = path.resolve(customLinterPath); - await $`${resolvedCustomLinterPath} ${lintArgs}`; - console.log("Linting _tools"); - await $({ cwd: "./_tools" })`${resolvedCustomLinterPath} ${lintArgs}`; + await $({ cwd: opts.cwd, env: opts.env })`${resolvedCustomLinterPath} ${lintArgs}`; } export const installTools = task({