Skip to content
Merged
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
34 changes: 34 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ on:
required: false
default: true
description: 'Run Go linter and unit tests prior to Docker build'
node-version:
description: >-
Set up Node.js (e.g. '24') before the Go checks, for a pre-build-command
that needs it. Empty: no Node.
type: string
required: false
default: ''
node-cache-dependency-path:
description: "Lockfile for the npm cache (e.g. web/package-lock.json). Empty: no cache."
type: string
required: false
default: ''
pre-build-command:
description: >-
Command run after checkout, before lint and tests: for code the Go build
needs but that isn't committed, e.g. a web UI it embeds (make web).
Empty: nothing.
type: string
required: false
default: ''
go-version:
type: string
required: false
Expand Down Expand Up @@ -80,6 +100,20 @@ jobs:
go-version: ${{ inputs.go-version }}
cache: true

- name: Set up Node.js
if: inputs.node-version != ''
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.node-cache-dependency-path != '' && 'npm' || '' }}
cache-dependency-path: ${{ inputs.node-cache-dependency-path }}

- name: Pre-build
if: inputs.pre-build-command != ''
env:
PRE_BUILD_COMMAND: ${{ inputs.pre-build-command }}
run: bash -euo pipefail -c "$PRE_BUILD_COMMAND"

- name: Run Linters
uses: golangci/golangci-lint-action@v9
with:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ on:
required: false
# renovate: datasource=github-releases depName=golangci/golangci-lint
default: 'v2.15.0'
node-version:
description: >-
Set up Node.js (e.g. '24') before the Go checks, for a pre-build-command
that needs it. Empty: no Node.
type: string
required: false
default: ''
node-cache-dependency-path:
description: "Lockfile for the npm cache (e.g. web/package-lock.json). Empty: no cache."
type: string
required: false
default: ''
pre-build-command:
description: >-
Command run after checkout, before lint and tests: for code the Go build
needs but that isn't committed, e.g. a web UI it embeds (make web).
Empty: nothing.
type: string
required: false
default: ''

jobs:
quality:
Expand All @@ -33,6 +53,20 @@ jobs:
go-version: ${{ inputs.go-version }}
cache: true

- name: Set up Node.js
if: inputs.node-version != ''
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.node-cache-dependency-path != '' && 'npm' || '' }}
cache-dependency-path: ${{ inputs.node-cache-dependency-path }}

- name: Pre-build
if: inputs.pre-build-command != ''
env:
PRE_BUILD_COMMAND: ${{ inputs.pre-build-command }}
run: bash -euo pipefail -c "$PRE_BUILD_COMMAND"

- name: Run Linters
uses: golangci/golangci-lint-action@v9
with:
Expand Down
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ All repositories in `divmora` should call the centralized reusable workflows hos
- **Enable for a repo:** install the app on it, add it to both secrets' repository access, and make sure its caller passes `secrets: inherit`. Without both secrets, the workflow falls back to `GITHUB_TOKEN` (release PRs then need the admin bypass to merge in CLA repos).
- `divmora-release[bot]` is on the CLA allowlist.

### `go-ci.yml` and `docker-publish.yml`: a build step before the Go checks

A repo whose Go build needs files that aren't committed (for example a web UI the binary embeds with `go:embed`) passes `node-version` (with `node-cache-dependency-path` for the npm cache) and `pre-build-command`, e.g. `node-version: '24'`, `node-cache-dependency-path: web/package-lock.json`, `pre-build-command: make web`. They run after Go is set up, before lint and tests, in `go-ci.yml` and in `docker-publish.yml`'s quality job. All three default to empty: nothing changes for other repos.

### `go-ci.yml`: pinned golangci-lint

`go-ci.yml` installs a **pinned** golangci-lint release (input `golangci-lint-version`, default set in the workflow), never `latest`. A floating `latest` lets an upstream release break every Go repo's CI with no code change.
Expand Down