Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 2 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
54 changes: 48 additions & 6 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>} [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({
Expand Down