diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index e46df6f..a68e2e7 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -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 @@ -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: diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml index 62bb301..246a3ab 100644 --- a/.github/workflows/go-ci.yml +++ b/.github/workflows/go-ci.yml @@ -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: @@ -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: diff --git a/AGENTS.md b/AGENTS.md index 2a7a5c2..e6b2c21 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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.