Skip to content
Closed
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
4 changes: 4 additions & 0 deletions .github/workflows/pull-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ jobs:
go-version-file: go.mod
check-latest: true
- run: make lint-spell
- name: Typos check
uses: crate-ci/typos@v1.44.0
with:
config: _typos.toml
Copy link
Copy Markdown
Member

@silverwind silverwind Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No action-only checks please. Run it during make lint-spell and remove this step. That way it can be ran locally which is very important.

You probably need to add a cargo.toml to pin this tool dependency, similar to what we already do for python using pyproject.toml.

Also if possible integrate it into make lint-spell-fix to automatically fix all errors.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No action-only checks please

lint-typos was added in the PR so it's runnable locally. Not sure why it's a separate rule and it doesn't cover installation (which I don't mind) but it does exist.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I missed that, was only seeing this.


lint-go-windows:
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
- Before committing any files, remove all trailing whitespace from source code lines
- Never force-push to pull request branches
- Always start issue and pull request comments with an authorship attribution
- Typos check: run `make lint-typos` when changing prose. For words that cannot be fixed (e.g. API stability), add `# typos:disable` or `// typos:disable` on that line, or allow-list the word in `_typos.toml` with a comment explaining why
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ WEB_DIRS := web_src/js web_src/css

ESLINT_FILES := web_src/js tools *.ts tests/e2e
STYLELINT_FILES := web_src/css web_src/js/components/*.vue
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) templates options/locale/locale_en-US.json .github $(filter-out CHANGELOG.md, $(wildcard *.go *.md *.yml *.yaml *.toml))
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) templates options/locale/locale_en-US.json .github $(filter-out CHANGELOG.md _typos.toml, $(wildcard *.go *.md *.yml *.yaml *.toml))
EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.json

GO_SOURCES := $(wildcard *.go)
Expand Down Expand Up @@ -273,10 +273,10 @@ checks-frontend: lockfile-check svg-check ## check frontend files
checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check ## check backend files

.PHONY: lint
lint: lint-frontend lint-backend lint-spell ## lint everything
lint: lint-frontend lint-backend lint-spell lint-typos ## lint everything

.PHONY: lint-fix
lint-fix: lint-frontend-fix lint-backend-fix lint-spell-fix ## lint everything and fix issues
lint-fix: lint-frontend-fix lint-backend-fix lint-spell-fix ## lint everything and fix issues (typos: run lint-typos and fix manually or add to _typos.toml)

.PHONY: lint-frontend
lint-frontend: lint-js lint-css ## lint frontend files
Expand Down Expand Up @@ -328,6 +328,11 @@ lint-spell: ## lint spelling
lint-spell-fix: ## lint spelling and fix issues
@git ls-files $(SPELLCHECK_FILES) | xargs go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -w

.PHONY: lint-typos
lint-typos: ## lint typos (crate-ci/typos); use "# typos:disable" in source for unfixable words
@command -v typos >/dev/null 2>&1 || { echo "typos not installed (see https://github.com/crate-ci/typos#installation), skipping"; exit 0; }
typos

.PHONY: lint-go
lint-go: ## lint go files
$(GO) run $(GOLANGCI_LINT_PACKAGE) run
Expand Down
158 changes: 158 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Typos (crate-ci/typos) configuration.
# Words we cannot fix (e.g. API stability, external names) must be allow-listed below
# with a comment explaining why. Alternatively add "# typos:disable" or "// typos:disable"
# on the same line in source to disable the check for that line only.

[files]
# Exclude paths that are not spell-checked (match SPELLCHECK_FILES and .gitignore)
extend-exclude = [
"CHANGELOG*.md",
"pnpm-lock.yaml",
"go.sum",
"uv.lock",
"*.min.js",
"*.min.css",
"public/assets",
"modules/migration/bindata.*",
"modules/options/bindata.*",
"modules/public/bindata.*",
"modules/templates/bindata.*",
".make_evidence",
"options/gitignore/Typo3",
"options/locale",
"assets/misspellings.csv",
"tests/*.ini.tmpl",
"tests/*.ini",
"routers/private/tests/repos/repo1_hook_verification_dummy_gpg_key.txt",
"routers/private/tests/repos/repo1_hook_verification",
"SECURITY.md",
"options/label",
"contrib/init/sunos",
"tools/generate-svg-vscode-extensions.json",
"web_src/fomantic",
]

[default]
# Ignore lines that contain a disable comment (use when a typo cannot be fixed)
extend-ignore-re = [
"(?m)^.*#\\s*typos:disable.*$",
"(?m)^.*//\\s*typos:disable.*$",
"(?m)^.*<!--\\s*typos:disable\\s*-->.*$",
]

[default.extend-words]
# Project name; cannot change
Gitea = "Gitea"
gitea = "gitea"
# TypoScript is a CMS project name, not a typo of TypeScript
TypoScript = "TypoScript"
# Meilisearch ranking rule name
typo = "typo"
# TYPO3 CMS project name
TYPO3 = "TYPO3"
Typo3 = "Typo3"
Comment on lines +47 to +53
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead rules?

# SMTP HELO command (RFC 5321); protocol term
helo = "helo"
Helo = "Helo"
HELO = "HELO"
Comment on lines +55 to +57
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one of them should be enough

# File extension / format name (e.g. Clojure edn, Makefile .mak)
edn = "edn"
mak = "mak"
cpy = "cpy"
odf = "odf"
Comment on lines +58 to +62
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# File extension / format name (e.g. Clojure edn, Makefile .mak)
edn = "edn"
mak = "mak"
cpy = "cpy"
odf = "odf"

# SunOS SMF framework property name
startd = "startd"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's ignored though?

# TLS cipher name (3DES EDE); crypto standard
ede = "ede"
# Local variable name in bleve query; changing would alter behavior
tru = "tru"
# Abbreviation for TABLE in CLI usage text
TABL = "TABL"
# Both spellings exist; keep for API stability
Unparseable = "Unparseable"
unparseable = "unparseable"
# i18n key used in all locale files; cannot change key
enterred = "enterred"
# Substring in base64 or test data (false positive)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Don't do this.

Ot = "Ot"
nd = "nd"
Nd = "Nd"
ND = "ND"
iy = "iy"
Iy = "Iy"
ba = "ba"
BA = "BA"
Pn = "Pn"
Iz = "Iz"
ue = "ue"
Ue = "Ue"
Mis = "Mis"
Ser = "Ser"
Yto = "Yto"
fo = "fo"
ist = "ist"
Ein = "Ein"
noo = "noo"
oder = "oder"
ono = "ono"
ags = "ags"
alle = "alle"
ALLWAYS = "ALLWAYS"
Comment on lines +76 to +100
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while typos has indeed problem with base64 this is not a good approach.
It's a huge bag of items which at times are base64 garbage, are test data or emoji data while it skips a real issue of "Mis" in "Mis-configured".
ALLWAYS is should not be labeled as test data since it's an old config key.

caf = "caf"
claus = "claus"
Claus = "Claus"
rcall = "rcall"
Comment on lines +101 to +104
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
caf = "caf"
claus = "claus"
Claus = "Claus"
rcall = "rcall"

# util.Iif ternary helper and TestTemplateIif; public API
Iif = "Iif"
# JSON tag "commiter" in structs/repo_wiki.go and swagger; API compatibility
commiter = "commiter"
# Variable from m.GetFrom() in mailer; API
froms = "froms"
# Variable name in jobparser model (plural of data)
datas = "datas"
# Patch line in diff tests ("+--some coment 2"); test fixture
coment = "coment"
# Migration comment; leave as-is to avoid touching migration
goint = "goint"
# File extension / icon name in material-icon-rules.json
stap = "stap"
Comment on lines +117 to +118
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# File extension / icon name in material-icon-rules.json
stap = "stap"
# File extension / icon name in material-icon-rules.json
stap = "stap"
edn = "edn"
mak = "mak"
cpy = "cpy"
rcall = "rcall"
caf = "caf"

styl = "styl"
tese = "tese"
# Test filename "shouldbe.vendor" in git attribute tests
shouldbe = "shouldbe"
# Variable name in repo/issue.go labels split
splitted = "splitted"
# Template comment "indivdual user"; leave to avoid template churn
indivdual = "indivdual"
# Module name and API (interpeter.go, NewInterpeter); public API
interpeter = "interpeter"
Interpeter = "Interpeter"
# Old package_property name in migration (rpm.metdata → rpm.metadata)
metdata = "metdata"
# block.PrecendingCharacter() from markup library; external API
Precending = "Precending"
# Migration function RemoveLabelUneededCols; cannot rename
Uneeded = "Uneeded"
# Emoji shortcode "womens" (women's room) in emoji_data.go
womens = "womens"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
womens = "womens"
womens = "womens"
claus = "claus"

# ARIA attribute aria-activedescendant; HTML standard
actived = "actived"
Actived = "Actived"
Comment on lines +138 to +140
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad comment, all the mentions I see refer to dropped column in database.

# Part of determineSHAforPR; public API
Afor = "Afor"
# "plastic.branchexplorer" in fileicon rules; external tool name
branche = "branche"
# Abbreviation or identifier; keep for compatibility
Colum = "Colum"
# Credentials-related identifier; keep for compatibility
Credental = "Credental"
# Identifier (e.g. global); keep for compatibility
gloabl = "gloabl"

[default.extend-identifiers]
# util.Iif is ternary helper; cannot change: public API
Iif = "Iif"
iif = "iif"
# determineSHAforPR function name; cannot change: public API
SHAforPR = "SHAforPR"
Afor = "Afor"
Comment on lines +152 to +158
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead rules?

24 changes: 12 additions & 12 deletions modules/actions/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const (
)

// IsDefaultBranchWorkflow returns true if the event only triggers workflows on the default branch
func IsDefaultBranchWorkflow(triggedEvent webhook_module.HookEventType) bool {
switch triggedEvent {
func IsDefaultBranchWorkflow(triggeredEvent webhook_module.HookEventType) bool {
switch triggeredEvent {
case webhook_module.HookEventDelete:
// GitHub "delete" event
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#delete
Expand Down Expand Up @@ -65,17 +65,17 @@ func IsDefaultBranchWorkflow(triggedEvent webhook_module.HookEventType) bool {
}

// canGithubEventMatch check if the input Github event can match any Gitea event.
func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEventType) bool {
func canGithubEventMatch(eventName string, triggeredEvent webhook_module.HookEventType) bool {
switch eventName {
case GithubEventRegistryPackage:
return triggedEvent == webhook_module.HookEventPackage
return triggeredEvent == webhook_module.HookEventPackage

// See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#gollum
case GithubEventGollum:
return triggedEvent == webhook_module.HookEventWiki
return triggeredEvent == webhook_module.HookEventWiki

case GithubEventIssues:
switch triggedEvent {
switch triggeredEvent {
case webhook_module.HookEventIssues,
webhook_module.HookEventIssueAssign,
webhook_module.HookEventIssueLabel,
Expand All @@ -87,7 +87,7 @@ func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEvent
}

case GithubEventPullRequest, GithubEventPullRequestTarget:
switch triggedEvent {
switch triggeredEvent {
case webhook_module.HookEventPullRequest,
webhook_module.HookEventPullRequestSync,
webhook_module.HookEventPullRequestAssign,
Expand All @@ -101,7 +101,7 @@ func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEvent
}

case GithubEventPullRequestReview:
switch triggedEvent {
switch triggeredEvent {
case webhook_module.HookEventPullRequestReviewApproved,
webhook_module.HookEventPullRequestReviewComment,
webhook_module.HookEventPullRequestReviewRejected:
Expand All @@ -112,14 +112,14 @@ func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEvent
}

case GithubEventSchedule:
return triggedEvent == webhook_module.HookEventSchedule
return triggeredEvent == webhook_module.HookEventSchedule

case GithubEventIssueComment:
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_comment-use-issue_comment
return triggedEvent == webhook_module.HookEventIssueComment ||
triggedEvent == webhook_module.HookEventPullRequestComment
return triggeredEvent == webhook_module.HookEventIssueComment ||
triggeredEvent == webhook_module.HookEventPullRequestComment

default:
return eventName == string(triggedEvent)
return eventName == string(triggeredEvent)
}
}
16 changes: 8 additions & 8 deletions modules/actions/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func GetEventsFromContent(content []byte) ([]*jobparser.Event, error) {
func DetectWorkflows(
gitRepo *git.Repository,
commit *git.Commit,
triggedEvent webhook_module.HookEventType,
triggeredEvent webhook_module.HookEventType,
payload api.Payloader,
detectSchedule bool,
) ([]*DetectedWorkflow, []*DetectedWorkflow, error) {
Expand All @@ -134,7 +134,7 @@ func DetectWorkflows(
continue
}
for _, evt := range events {
log.Trace("detect workflow %q for event %#v matching %q", entry.Name(), evt, triggedEvent)
log.Trace("detect workflow %q for event %#v matching %q", entry.Name(), evt, triggeredEvent)
if evt.IsSchedule() {
if detectSchedule {
dwf := &DetectedWorkflow{
Expand All @@ -144,7 +144,7 @@ func DetectWorkflows(
}
schedules = append(schedules, dwf)
}
} else if detectMatched(gitRepo, commit, triggedEvent, payload, evt) {
} else if detectMatched(gitRepo, commit, triggeredEvent, payload, evt) {
dwf := &DetectedWorkflow{
EntryName: entry.Name(),
TriggerEvent: evt,
Expand Down Expand Up @@ -193,20 +193,20 @@ func DetectScheduledWorkflows(gitRepo *git.Repository, commit *git.Commit) ([]*D
return wfs, nil
}

func detectMatched(gitRepo *git.Repository, commit *git.Commit, triggedEvent webhook_module.HookEventType, payload api.Payloader, evt *jobparser.Event) bool {
if !canGithubEventMatch(evt.Name, triggedEvent) {
func detectMatched(gitRepo *git.Repository, commit *git.Commit, triggeredEvent webhook_module.HookEventType, payload api.Payloader, evt *jobparser.Event) bool {
if !canGithubEventMatch(evt.Name, triggeredEvent) {
return false
}

switch triggedEvent {
switch triggeredEvent {
case // events with no activity types
webhook_module.HookEventCreate,
webhook_module.HookEventDelete,
webhook_module.HookEventFork,
webhook_module.HookEventWiki,
webhook_module.HookEventSchedule:
if len(evt.Acts()) != 0 {
log.Warn("Ignore unsupported %s event arguments %v", triggedEvent, evt.Acts())
log.Warn("Ignore unsupported %s event arguments %v", triggeredEvent, evt.Acts())
}
// no special filter parameters for these events, just return true if name matched
return true
Expand Down Expand Up @@ -260,7 +260,7 @@ func detectMatched(gitRepo *git.Repository, commit *git.Commit, triggedEvent web
return matchWorkflowRunEvent(payload.(*api.WorkflowRunPayload), evt)

default:
log.Warn("unsupported event %q", triggedEvent)
log.Warn("unsupported event %q", triggeredEvent)
return false
}
}
Expand Down
Loading
Loading