From a81fc2a29048dad1930bd0e6a70ded82724772b0 Mon Sep 17 00:00:00 2001 From: Nils Goroll Date: Tue, 17 Feb 2026 02:41:40 +0100 Subject: [PATCH] chore: move backend-checks CI checks to Makefile: `make pr-go` (#11053) This is to have a simple and consistent make target for developers to locally run the checks which the CI will also run. The goal is to avoid wasting review cycles on CI failures. To have a single source of truth, the CI is adjusted to call the same make target. Additional checks should no longer be added to the CI workflow, but rather to the makefile. The pull request template is adjusted to remind of running this make target. CI output is improved by using a simple bash script which uses sed to add `##[group]` tags to "make --debug=b" output and filter out messages which usually do not contribute to understanding. While this approach has limits and depends on the specific debug output format of GNU make, it avoids adjusting the makefile itself for additional CI beautification, contributing to maintainability. - no tests needed (this is purely a build change) - docs: hint added to PR template - no release notes needed Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11053 Reviewed-by: Michael Kriese Reviewed-by: Gusted Co-authored-by: Nils Goroll Co-committed-by: Nils Goroll --- .forgejo/pull_request_template.md | 11 ++++++++++- .forgejo/workflows/testing.yml | 6 ++++-- Makefile | 5 +++++ tools/cimake.sh | 19 +++++++++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100755 tools/cimake.sh diff --git a/.forgejo/pull_request_template.md b/.forgejo/pull_request_template.md index a0f74ae31d..44c28e333e 100644 --- a/.forgejo/pull_request_template.md +++ b/.forgejo/pull_request_template.md @@ -12,11 +12,20 @@ labels: The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). -### Tests +### Tests for Go changes + +(can be removed for JavaScript changes) - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. +- I ran... + - [ ] `make pr-go` before pushing + +### Tests for JavaScript changes + +(can be removed for Go changes) + - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 709ab71e18..f9cce74258 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -24,8 +24,10 @@ jobs: EOF - uses: https://data.forgejo.org/actions/checkout@v6 - uses: ./.forgejo/workflows-composite/setup-env - - run: su forgejo -c 'make deps-backend deps-tools' - - run: su forgejo -c 'make --always-make -j$(nproc) lint-backend tidy-check swagger-check lint-swagger fmt-check swagger-validate' # ensure the "go-licenses" make target runs + # DO NOT add checks here, but rather in the makefile + - run: su forgejo -c './tools/cimake.sh pr-go' + # this will re-run the backend target also contained in pr-go, but + # a re-build is insignificant - uses: ./.forgejo/workflows-composite/build-backend frontend-checks: if: vars.ROLE == 'forgejo-coding' || vars.ROLE == 'forgejo-testing' diff --git a/Makefile b/Makefile index aa96922bf5..99670829bb 100644 --- a/Makefile +++ b/Makefile @@ -520,6 +520,11 @@ security-check: tsc: node_modules npx tsc --noEmit +# target for PRs to be pushed. Mandatory to succeed in CI +.PHONY: pr-go +pr-go: deps-backend deps-tools lint-backend tidy-check swagger-check lint-swagger fmt-check swagger-validate + TAGS=bindata $(MAKE) backend + ### # Development and testing targets ### diff --git a/tools/cimake.sh b/tools/cimake.sh new file mode 100755 index 0000000000..438745e32e --- /dev/null +++ b/tools/cimake.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# GNU make wrapper for invocation from ci to generate grouping of output + +# pipefail: fail if make fails, because sed will not +set -euo pipefail + +script=' + /^ *Prerequisite .* is newer than target /d; + /^ * File .* does not exist/d; + /^ *Must remake target/ s:^ *Must remake target:\#\#[group]:; + /^ *Successfully remade target/ s:^ *Successfully remade target file:\#\#[endgroup]:; + ' + +echo 'NOTICE: This is post-processed make output with some messages suppressed' +echo + +# -O is important to not mix up output for parallel makes +exec make --debug=b -O -j$(nproc) "$@" 2>&1 | sed -u -e "${script}"