Repository navigation
Format the generated OpenAPI client in the Task pipeline, untrack the Task checksum, align spec-source docs - #40
Open
DzmitryHumianiuk wants to merge 4 commits into
Open
DzmitryHumianiuk wants to merge 4 commits into
DzmitryHumianiuk wants to merge 4 commits into
Conversation
…ecksum - generate-openapi-client: run gofmt on the generated code before it replaces pkg/openapi. The generator does not format its output and the committed client is gofmt-clean, so a regeneration shows formatting-only changes (372 files as reported in #33; not reproduced here, no Docker). - generate-openapi-client: pass an ignore list (scripts/openapi-generator-ignore) so the generator stops writing .travis.yml, git_push.sh and README.md. The tracked copies go away with the next regeneration. - Untrack .task/checksum/preprocess-schema: .task/ is git-ignored, the file was added in 247d914. - Taskfile.yml and AGENTS.md now name the same spec source (/api/api-docs; beta is where the snapshot was taken, demo is the public equivalent). /api/v1/api-docs on demo answers 401. Not run: the generator itself (needs Docker). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Output of `task generate-openapi-client` (openapi-generator v7.25.0, jq 1.8.1): no .go file changes. The generator no longer writes .travis.yml, git_push.sh and README.md, their entries leave .openapi-generator/FILES, and .openapi-generator-ignore is now the copy of scripts/openapi-generator-ignore (a pre-existing ignore file is not listed in FILES). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… demo as the spec source - The generator container wrote its output as root on Linux, so the gofmt step and the next run's rm -rf would fail. It now runs with --user uid:gid. - --git-repo-id uses the module path case (goRP). It only appears in README.md and git_push.sh, which are not generated any more. - Taskfile.yml and AGENTS.md name https://demo.reportportal.io/api/api-docs as the canonical spec source. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Member
Author
Update: the pipeline was run with Docker, the result is committed
Regeneration result
Changes made after the run
Verification
Investigation log
Scripts and logs (local scratch files, for re-running): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #39
task generate-openapi-clientnow formats its output withgofmtbefore it replacespkg/openapi, and no longer asks the generator for.travis.yml,git_push.shandREADME.md. The tracked Task checksum is removed from the index, andTaskfile.ymlandAGENTS.mdname the same spec source.The generator was run with Docker (see the update comment):
pkg/openapiis regenerated by the task in f014579. No.gofile changed; the three dropped files are deleted and.openapi-generator/FILES/.openapi-generator-ignoreare updated.Changes
Taskfile.yml,generate-openapi-client:gofmt -w "{{.GENERATED_DIR}}"aftercompat.gois copied and before the swap. A failed format keeps the committed client, like a failed generation does.cp scripts/openapi-generator-ignore "{{.GENERATED_DIR}}/.openapi-generator-ignore"before the generator runs.--user "$(id -u):$(id -g)", left out on Windows), so the output isn't owned by root on Linux.--git-repo-id goRP/v5/pkg/openapi(wasgorp/…)..github/workflows/build.yml: new jobopenapi-driftruns the task and fails whenpkg/openapidiffers.pkg/openapi: regenerated by the task (f014579).scripts/openapi-generator-ignore(new):.travis.yml,git_push.sh,README.md..task/checksum/preprocess-schema: removed from the index (git rm --cached)..gitignorealready has.task/.AGENTS.md: spec source, the format step and the ignore list are described;scripts/row mentions the new file.Why plain
gofmtgofmt -l pkg/openapiandgofmt -s -l pkg/openapiboth print nothing.gofumpt,gci,golines) skip generated files:.golangci.yml:30-31hasformatters.exclusions.generated: lax, and every file the generator writes has theCode generated … DO NOT EDITheader (373 of 374; the exception iscompat.go, a hand-written template thatgofmt -wleaves unchanged). Sogo fmt ./..., the first command oftask fmt, is what formatted the committed tree.gofmt -w <dir>needs no package loading and no Docker. It also formatscompat.go, which is already gofmt-clean (pkg/openapi/compat.goequals the template byte for byte).Generator leftovers: what is dropped and what is kept
.travis.ymlgit_push.shgithub.com/reportportal/gorp/v5/pkg/openapi. Not usable here.README.mddocs/*.md, which are not generated (modelDocs=false,apiDocs=false); the install snippet has the import path in the wrong case (gorpinstead ofgoRP).api/openapi.yamlopenapi-modified.jsonis git-ignored). It makes the effect of a jq-filter change reviewable..gitignore,.openapi-generator/FILES,.openapi-generator/VERSIONFILESandVERSIONrecord what was generated and by which generator version.The ignore list lives in
scripts/and is copied in on every run, because the generator writes into a freshbuild/openapiandpkg/openapiis replaced as a whole: the.openapi-generator-ignorethat is committed inpkg/openapiis never read by this pipeline.The three dropped files are deleted by the regeneration in f014579 (not by hand).
Spec source
reportportal-api-docs.jsonwas taken fromhttps://beta.epmrpp.reportportal.io/api/api-docs. The only record of this is commit 3d526db, which replaced the spec and changed the Taskfile comment from demo to beta in one step. The host resolves to private addresses (10.x) and cannot be reached from outside, so this could not be checked against the host itself.https://demo.reportportal.io/api/api-docsserves the same document: same size (731971 bytes), and identical after theexamplevalues are removed. The 15 differing values are random UUIDs and e-mail addresses; two downloads from demo a few seconds apart differ from each other in the same way. So the content shows the same service-api build (6.0.0), not which host it came from.https://demo.reportportal.io/api/v1/api-docs(the URL inAGENTS.md) answers 401.https://demo.reportportal.io/api/api-docsas the canonical source (aedd18b); the internal host is no longer mentioned.Not verified
--userfix were shown inside the Linux VM on a Docker volume, not by a fulltask generate-openapi-clienton Linux. The first run of theopenapi-driftjob on this PR is that proof; the job has not run yet.AGENTS.mdsays Podman works through adockersymlink. In a rootless engine the container's root already is the host user, so the old command worked there. With--user uid:gidthe process may become a subordinate id that cannot write the bind mount, and then generation fails. Not tried. If it fails, the flag has to be made conditional.--userflag is left out when Task reportsOS=windows; this branch of the template was not executed.gofmtacross Go versions. The committed tree is formatted bygofmt1.27.4. The CI job takes Go fromgo.mod. A later Go release that changesgofmtoutput would make the drift job fail until the client is regenerated.Investigation log
Base:
origin/master517efe6. Go 1.27.4, darwin/arm64.Format step:
gofmt -l pkg/openapi | wc -l→ 0;gofmt -s -l pkg/openapi | wc -l→ 0..golangci.yml:23-31: formattersgci, gofmt, gofumpt, goimports, golines,exclusions.generated: lax.cmp scripts/openapi-compat/compat.go.tmpl pkg/openapi/compat.go→ identical.codegen-work/proof.sh,codegen-work/perturb.pyin the scratchpad):cp -R pkg/openapi proof/build/openapi;diff -r→ 0 lines.gofmt -w "build/openapi"(the Taskfile command with the variable filled in);diff -r build/openapi <repo>/pkg/openapi→ 0 lines.gofmt -l build/openapilists 51.gofmt -w "build/openapi"again →diff -r0 lines,gofmt -llists 0.ruby -ryamlparses the editedTaskfile.yml; thegenerate-openapi-clientcommands are, in order:preprocess:schema,rm -rf,mkdir -p,cp …ignore,docker run … generate,cp compat.go.tmpl,gofmt -w,rm -rf,mv.Checksum file:
git ls-files .task→.task/checksum/preprocess-schema;.gitignore:42→.task/.git log --diff-filter=A --format='%h %s' -- .task/checksum/preprocess-schema→ 247d914 "CI: use govulncheck v1.9.0 and the latest Go 1.27 patch in lint and release".git ls-files -ci --exclude-standardprints nothing.Spec source:
Taskfile.yml:16(beta,/api/api-docs) againstAGENTS.md:92(demo,/api/v1/api-docs).git log -S'beta.epmrpp' -- Taskfile.yml AGENTS.md README.md→ 3d526db only;git show 3d526db -- Taskfile.ymlshows the comment changing from demo to beta in the commit that replaced the spec.jq '{openapi, info, servers}' reportportal-api-docs.json→ OpenAPI 3.0.1,info.version6.0.0, server/api, 251 paths, 322 schemas. The same for the demo snapshotconsilium2/data/live-api-docs.json.cmpof the two: differ;jq -S . | diff→ 30 lines, all"example"(15 values).curl https://demo.reportportal.io/api/api-docstwice → 200, 731971 bytes each, different SHA-256 (one equals the consilium snapshot).jq -S 'walk(if type=="object" then del(.example) else . end)' | shasum -a 256→f85036bd…8511efor the committed file and for both demo downloads.curl https://demo.reportportal.io/api/v1/api-docs→ 401invalid_token.curl https://demo.reportportal.io/api/info→ service-api 6.0.0, branchrc/6.0.0-038258bf….host beta.epmrpp.reportportal.io→ 10.68.x.x;curltimes out.Generator leftovers:
git ls-files pkg/openapi | grep -v '\.go$'→.gitignore,.openapi-generator-ignore,.openapi-generator/FILES,.openapi-generator/VERSION,.travis.yml,README.md,api/openapi.yaml,git_push.sh.pkg/openapi/.openapi-generator/FILES:3-5,53lists.travis.yml,README.md,api/openapi.yaml,git_push.sh.grep -c '](docs/' pkg/openapi/README.md→ 682;pkg/openapi/docsdoes not exist;pkg/openapi/README.md:17has the wrong-case import path.Taskfile.yml:85-86(rm -rf+mkdir -pofbuild/openapi) is why the committed.openapi-generator-ignoreis never read.Checks:
go build ./...,go vet ./...,go test ./...pass (internal/commands,pkg/gorpok).task lintnot run (Docker); no Go file changed.🤖 Generated with Claude Code