Exclude vendor directories from CI gofmt formatting checks in ci-workflow.yaml

Aperta
#566 4 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
github-actions, go
Ambito
ci-cd

Direzione di ricerca

The failing step is the Check formatting job in .github/workflows/ci-workflow.yaml (around line 244), which runs gofmt -l validator and recurses into validator/vendor/. Read the comment in .pre-commit-config.yaml that claims the vendor exclude covers this gate, then check which other Go module jobs run gofmt the same way. Done means go mod vendor in validator/ leaves git diff validator/vendor/ empty and the CI formatting step passes without gofmt -w. The issue says agents may not edit the workflow file, so this needs a maintainer to authorize the change.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

blocked bug infra needs-human triaged

What happened

During the implementation of PR #555, the code agent added validator/vendor/ to vendor gopkg.in/yaml.v3 v3.0.1 so that the spec-validator pre-commit hook could build offline in sandboxed environments with GOPROXY=off. While .pre-commit-config.yaml was configured to exclude validator/vendor/.* from the local gofmt hook, GitHub Actions CI workflow runs 44815928254 and 44815939634 failed during the V2 specification validator job's Check formatting step (.github/workflows/ci-workflow.yaml:244).

The failure occurred because CI runs files="$(gofmt -l validator)" || exit $? directly against the validator directory, which recursed into validator/vendor/ and detected formatting variances in upstream yaml.v3 source files. To unblock CI in commit 7454bfb, the fix agent ran gofmt -w on validator/vendor/, modifying 9 of the 13 third-party Go files. In his review on commit 7454bfb, maintainer John Strunk pointed out: 'The vendor comment is false, and the exclude does not reach the gate it was added for... CI's .github/workflows/ci-workflow.yaml:244 runs gofmt -l validator, which recurses into vendor/ and ignores the pre-commit exclude. A future go mod vendor restores the upstream bytes and fails that CI job again. Fix: state the real invariant and the procedure in the comment... Do not revert to a pristine vendor tree: that needs a change to the CI gofmt step under .github/workflows/, which you may not make.'

Because agent workflows are strictly forbidden from modifying .github/workflows/ci-workflow.yaml, the agent could not fix the root cause in CI. A human-authorized workflow fix is needed so vendored dependencies remain pristine.

What could go better

Third-party vendored dependencies should remain byte-for-byte identical to their upstream sources. Running gofmt -w against validator/vendor/ violates this invariant and creates maintenance friction: any developer or agent running go mod vendor in the future will restore the upstream formatting, re-triggering CI formatting failures.

CI currently runs gofmt -l <dir> directly via shell commands across module jobs rather than using scripts/check_gofmt.py or excluding vendor/ subdirectories. By updating .github/workflows/ci-workflow.yaml to exclude vendor/ directories from gofmt -l, validator/vendor/ can be restored to pristine upstream bytes without failing the CI formatting gate.

Proposed change

In .github/workflows/ci-workflow.yaml, update the Check formatting step under the validator job (and ensure equivalent protection across other Go module jobs) to exclude vendor/ directories from gofmt inspection.

Specifically, replace:

      - name: Check formatting
        run: |
          files="$(gofmt -l validator)" || exit $?
          test -z "$files"

with a command that ignores vendor/, such as:

      - name: Check formatting
        run: |
          files="$(find validator -name '*.go' -not -path '*/vendor/*' -exec gofmt -l {} +)" || exit $?
          test -z "$files"

or invoke python3 scripts/check_gofmt.py passing only non-vendor files. Once the CI step excludes vendor/, re-run go mod vendor inside validator/ to restore validator/vendor/gopkg.in/yaml.v3 to pristine upstream formatting, and update the comment in .pre-commit-config.yaml accordingly.

Validation criteria

  1. In validator/, executing go mod vendor followed by git diff validator/vendor/ produces pristine upstream files identical to gopkg.in/yaml.v3 v3.0.1.
  2. Running the updated .github/workflows/ci-workflow.yaml on a PR carrying pristine vendored code succeeds on the Check formatting step without requiring manual gofmt -w.

Related issues checked

Searched: gofmt vendor repo:redhat-et/ProtoBot is:issue; vendor ci-workflow repo:redhat-et/ProtoBot is:issue; gofmt exclude vendor repo:redhat-et/ProtoBot is:issue; gofmt vendor repo:fullsend-ai/fullsend repo:fullsend-ai/agents repo:redhat-et/ProtoBot is:issue; vendor formatting repo:fullsend-ai/fullsend repo:fullsend-ai/agents repo:redhat-et/ProtoBot is:issue
Considered: #560, #544
#560 proposes standardizing Go module checks via composite action but retains gofmt recursion over module paths without vendor exclusion. #544 resolved local offline pre-commit failures by vendoring validator/vendor/ but did not update ci-workflow.yaml, leading directly to the gofmt CI failure when vendor/ was added.


Generated by retro agent from https://github.com/redhat-et/ProtoBot/pull/555

Lingua principale
Go
Stelle
7
Fork
9
Merge medio
22h 37m
PR unite (30g)
118

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di redhat-et/ProtoBot

Tutte le issue di redhat-et/ProtoBot

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.