build: move backend-checks CI checks to Makefile: make pr-go #11053
Labels
No labels
arch
riscv64
backport/v1.19
backport/v1.20
backport/v1.21/forgejo
backport/v10.0/forgejo
backport/v11.0/forgejo
backport/v12.0/forgejo
backport/v13.0/forgejo
backport/v14.0/forgejo
backport/v7.0/forgejo
backport/v8.0/forgejo
backport/v9.0/forgejo
breaking
bug
bug
confirmed
bug
duplicate
bug
needs-more-info
bug
new-report
bug
reported-upstream
code/actions
code/api
code/auth
code/auth/faidp
code/auth/farp
code/email
code/federation
code/git
code/migrations
code/packages
code/wiki
database
MySQL
database
PostgreSQL
database
SQLite
dependency-upgrade
dependency
certmagic
dependency
chart.js
dependency
Chi
dependency
Chroma
dependency
citation.js
dependency
codespell
dependency
css-loader
dependency
devcontainers
dependency
dropzone
dependency
editorconfig-checker
dependency
elasticsearch
dependency
enmime
dependency
F3
dependency
ForgeFed
dependency
garage
dependency
Git
dependency
git-backporting
dependency
Gitea
dependency
gitignore
dependency
go-ap
dependency
go-enry
dependency
go-gitlab
dependency
Go-org
dependency
go-rpmutils
dependency
go-sql-driver mysql
dependency
go-swagger
dependency
go-version
dependency
go-webauthn
dependency
gocron
dependency
Golang
dependency
goldmark
dependency
goquery
dependency
Goth
dependency
grpc-go
dependency
happy-dom
dependency
Helm
dependency
image-spec
dependency
jsonschema
dependency
KaTeX
dependency
lint
dependency
MariaDB
dependency
Mermaid
dependency
minio-go
dependency
misspell
dependency
Monaco
dependency
PDFobject
dependency
playwright
dependency
postcss
dependency
postcss-plugins
dependency
pprof
dependency
prometheus client_golang
dependency
protobuf
dependency
relative-time-element
dependency
renovate
dependency
reply
dependency
ssh
dependency
swagger-ui
dependency
tailwind
dependency
temporal-polyfill
dependency
terminal-to-html
dependency
tests-only
dependency
text-expander-element
dependency
urfave
dependency
vfsgen
dependency
vite
dependency
Woodpecker CI
dependency
x tools
dependency
XORM
Discussion
duplicate
enhancement/feature
forgejo/accessibility
forgejo/branding
forgejo/ci
forgejo/commit-graph
forgejo/documentation
forgejo/furnace cleanup
forgejo/i18n
forgejo/interop
forgejo/moderation
forgejo/privacy
forgejo/release
forgejo/scaling
forgejo/security
forgejo/ui
Gain
High
Gain
Nice to have
Gain
Undefined
Gain
Very High
good first issue
i18n/backport-stable
impact
large
impact
medium
impact
small
impact
unknown
Incompatible license
issue
closed
issue
do-not-exist-yet
issue
open
manual test
Manually tested during feature freeze
OS
FreeBSD
OS
Linux
OS
macOS
OS
Windows
problem
QA
regression
release blocker
Release Cycle
Feature Freeze
release-blocker
v7.0
release-blocker
v7.0.1
release-blocker
v7.0.2
release-blocker
v7.0.3
release-blocker
v7.0.4
release-blocker
v8.0.0
release-blocker/v9.0.0
run-all-playwright-tests
run-end-to-end-tests
test
manual
test
needed
test
needs-help
test
not-needed
test
present
untested
User research - time-tracker
valuable code
worth a release-note
User research - Accessibility
User research - Blocked
User research - Community
User research - Config (instance)
User research - Errors
User research - Filters
User research - Future backlog
User research - Git workflow
User research - Labels
User research - Moderation
User research - Needs input
User research - Notifications/Dashboard
User research - Rendering
User research - Repo creation
User research - Repo units
User research - Security
User research - Settings (in-app)
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo/forgejo!11053
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "slink/forgejo:make-pr-go"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.Otherwise sounds like a nice improvement. Maybe also should be mentioned on https://forgejo.org/docs/latest/contributor/testing/?
@ -13,3 +13,3 @@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 changesS/GO/Go
63b685a96059e2a8874fChanged GO into Go and docs pr opened: forgejo/docs#1714
@ -26,3 +26,2 @@- 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- run: su forgejo -c 'make -j$(nproc) pr-go'i would suggest to split it tioo multiple run commands for easier failure analyzation on failues. It's currently hard to find what fails
that would counter-act the goal of having a single source of truth.
If we have one thing in the CI and another in the
Makefile, they will diverge again.Should we maybe have a some magic string to make the CI format the output nicely?
not sure, i don't know if log grouping works on forgejo actions
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#grouping-log-lines
then we could detect actions and emit grouping commands on ci
#3337, its supported.
@Gusted wrote in #11053 (comment):
ha, found it too now😅
we can use
GITHUB_ACTIONSorFORGEJO_ACTIONSto detectJust
CI?I am trying to come up with something manageable for the Makefile...
sure
code.forgejo.org/forgejo/runner@6721a406e5/act/runner/run_context.go (L1360)build: move backend-checks CI checks to Makefileto WIP: build: move backend-checks CI checks to Makefile59e2a8874fe3e271934ce3e271934c58fbedc17fFTR: The following idea is nice, I think, because it does not require any changes to the makefile, but I found no way to replace the working directory output with the current target:
this produces:
But I am giving it up, because we should really have descriptive names for the groups
Actually... There is a debug option which might give us what we want.
@viceice could you have a look at https://codeberg.org/forgejo/forgejo/actions/runs/134218/jobs/0/attempt/1 and tell me what you think?
As mentioned before, the compelling advantage of something like this is that it does not require changes to the makefile (which can be forgotten etc.).
The drawback (if it is any) is that we need to accept additional debug output which we are less interested in, or we'd need to hack more line replacements for those parts of the output which we do not want to see (with the danger of accidentally suppressing something which we are interested in)
WIP: build: move backend-checks CI checks to Makefileto WIP: build: move CI checks to Makefilelooks promissing, maybe we should try to filter some more known verbose messages 🙃
Prerequisite 'tests/e2e/changes.go' is newer than target 'templates/swagger/v1_json.tmpl'.File 'swagger-check' does not exist.then we're porbably good to go
140c9d8e8e6d13f7794eWIP: build: move CI checks to Makefileto build: move backend-checks CI checks to Makefile:make pr-goready for merge:
tools/cimake.sh:
CI:
This failure https://codeberg.org/forgejo/forgejo/actions/runs/134508/jobs/3/attempt/1 looks unrelated, I did not touch e2e and the error looks like ... something swallowed some characters...?
6d13f7794e0d8262e582rebased and force-pushed, no changes to the patch
While this has been open, I've prepared a new backend check in #11142, using
semgrep. I'm inclined to leave thesemgrepchange separate from this newpr-gomake target because: (a) it already is, so neither of these changes will conflict on each other, (b) it requires a separate tool that can't be automatically installed by the go toolchain (semgrep) since it's not a go tool, (c) it's a relatively slow tool, (d) the slow perf is mitigated in CI because it uses patch-aware detection of what files to run against.Just wanted to raise this note to see if there's an alternate opinion before either change moves forward.
semgrep's applicability in #11142 will be so very small that it's unlikely to be an inconvenience, but that could change over time.Re @mfenniak
I am not competent regarding semgrep, but it seems to be a proprietary, closed source tool (I only checked briefly, the pip installer for the CE cli contains a big binary executable). As a matter of principle, I would not even install such a tool locally, and, consequently, I would vote against requiring it to pass for PRs to be merged. In my opinion, there is also a risk of relying too much on such a tool, and in my mind there is a broader conflict with forgejo's values.
I do not have any say in this project, so the maintainers are of course to make their decision independent of this opinion.
As a possible compromise, one option could be to just run the tool "asynchronously" against trunk.
@slink wrote in #11053 (comment):
This is a misunderstanding of a weird packaging choice. semgrep is an LGPL-2.1 licensed open source tool. https://github.com/semgrep/semgrep It's written in OCaml, so I'm not sure why they use a pip package as a distribution tool, but that's the cause of the binary -- it's not a python tool.
Now, there is a fair criticism of the project in a more nuanced way -- the authors recently removed capabilities from the open source tool to package them as part of their commercial engine. (https://semgrep.dev/blog/2024/important-updates-to-semgrep-oss/#json-and-sarif-output-changes) This resulted in a fork, Opengrep. We could easily adopt Opengrep instead if it proves to be the healthier project in the long-term due to the limited usage proposed at this time.
With that information in mind, how is your opinion on
make pr-goinfluenced?@mfenniak wrote in #11053 (comment):
Thank you so much for clearing up my misunderstanding. 🙏 FWIW, their corporate website does not exactly promote a link to their sources either, but I really should have looked more carefully. Thank you again for correcting my mistake.
As long as the toolchain can be built from sources, I am fine with requiring it.
@mfenniak I just realized that I might not have answered your actual question: Being inexperienced with semgrep, I am not sure how relevant it would be to run it locally. As a newbie to this project, I wanted to avoid pushing PRs for which CI immediately fails, and just today I found issues which would only should up in e2e. So I guess in principle
make pr-gocould include all CI checks, but it also needs to remain manageable in terms of runtime.So based on
it would seem sensible to not run it with
make pr-go?@slink wrote in #11053 (comment):
It runs in 6 seconds for me, but I'm not sure how well installing python packages is in the current Makefile, there's some as that was inherited from Gitea but I don't think we ever ran them.
Looks good, thanks!
Just want to say thank you for doing this & the docs update, since they would have helped with an earlier PR I submitted. Hopefully they help newer folks too.