Repository navigation
skills: report the release tag as the release source's catalog version - #8191
simonfaltum wants to merge 6 commits into
Conversation
The manifest's version field is the manifest schema version, the same in every release. The release source now sets Catalog.Version to the resolved release tag without its leading v. A local folder keeps the manifest value. Co-authored-by: Isaac <no-reply@databricks.com>
✅ Integration test reportCommit: bfd4c24
Top 3 slowest tests (at least 2 minutes):
|
…on for all sources Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Automated review at c519cfe. Each finding was verified against the code.
No blocking issues found. 4 non-blocking comment(s) below.
This PR makes the release skills source report the resolved release tag, without its leading "v", as Catalog.Version, so the value stops coming from the manifest's schema version field. The core change is small and correct for full semver tags. The issues below are about how refs get mapped to versions: shorthand semver refs like v2 lose their v even though the docs say branches are reported as given, and this mapping now disagrees with installer.DisplaySkillsVersion. There are also two smaller points: the doc comment names a bundled copy that doesn't exist yet, and the new test helper duplicates one that's already there.
| // releaseVersion strips the leading "v" from a semantic version tag. Any other | ||
| // ref, such as a branch named vendor-fix, is returned as given. | ||
| func releaseVersion(ref string) string { | ||
| if semver.IsValid(ref) { |
There was a problem hiding this comment.
[nice to have] semver.IsValid also accepts the shorthand forms v2 and v1.2, so DATABRICKS_SKILLS_REF=v2 (a branch) is reported as 2. That contradicts this function's comment and the Catalog.Version doc in skills.go, which say a branch is reported as given. Should the check require a full vMAJOR.MINOR.PATCH (for example semver.Canonical(ref) == ref, adjusted if prerelease or build metadata matters)? If not, the docs should say that short semver-looking refs lose their v too.
There was a problem hiding this comment.
Fixed in 59e43af: releaseVersion now strips the v only when semver.Canonical(ref) == ref, so v2 and v1.2 are reported as given. A test case for v2 covers it. A tag with build metadata is also kept as given, which is fine for release tags.
There was a problem hiding this comment.
|
|
||
| // releaseVersion strips the leading "v" from a semantic version tag. Any other | ||
| // ref, such as a branch named vendor-fix, is returned as given. | ||
| func releaseVersion(ref string) string { |
There was a problem hiding this comment.
[nice to have] installer.DisplaySkillsVersion in libs/aitools/installer/installer.go already turns a skills ref into a display version, but it strips the v from every ref, so the two now disagree. With DATABRICKS_SKILLS_REF=vendor-fix, this catalog reports vendor-fix while aitools install shows endor-fix. installer already imports libs/skills, so could this become the exported helper, with DisplaySkillsVersion calling it? If they're meant to differ, the doc comment should say how.
There was a problem hiding this comment.
Right, they disagree for non-tag refs. I left DisplaySkillsVersion alone: it feeds aitools install state, update and downgrade checks, which are not behind the skills preview gate, so changing it would alter existing behaviour in a PR meant to be gated. The releaseVersion comment now says the two differ on purpose. Making DisplaySkillsVersion call this helper (which also fixes vendor-fix showing as endor-fix) is better done as its own change with its own tests.
| // Version is the release version: the release tag without its leading "v" | ||
| // for the published release (a pinned DATABRICKS_SKILLS_REF that is a | ||
| // branch or commit is reported as given). A local | ||
| // folder and the bundled copy have no release tag here and report the |
There was a problem hiding this comment.
[nit] The doc says what "the bundled copy" reports, but this tree has no bundled source: Resolve in resolve.go only knows DATABRICKS_SKILLS_DIR, and fsSource.Catalog is the only other place that sets Version. Can you drop the bundled copy here and add it back with the change that adds that source?
There was a problem hiding this comment.
Done in 59e43af: the Catalog.Version doc no longer mentions a bundled copy. It will be added back with the change that adds that source.
| } | ||
| } | ||
|
|
||
| // serveReleases serves one tree per release tag under the base URL. |
There was a problem hiding this comment.
[nit] serveReleases repeats the StripPrefix + FileServer setup that serveRelease/serveReleaseFS (lines 22-34) already do for a single tag. Could serveReleaseFS take the tag instead, or could those two helpers be built on serveReleases, so there's one way to serve a test release?
There was a problem hiding this comment.
Done in 59e43af: serveReleaseFS now calls serveReleases with the single tag v1.2.0 and sets the ref, so the StripPrefix + FileServer setup lives in one place. serveRelease stays for the tests that need a custom handler.
… helpers Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
rugpanov
left a comment
There was a problem hiding this comment.
Approve. I found no blocking problems. There is 1 nice-to-have finding and there are 3 nits, as inline comments.
Risk: LOW. The change touches only the release source in libs/skills. No command reaches it at this head: Resolve returns only the DATABRICKS_SKILLS_DIR folder source, and the skills command group is hidden behind DATABRICKS_SKILLS_PREVIEW. It is a small change in three files, with unit tests, and a revert rolls it back.
Notes on the stack (no change needed in this PR):
- #8076 also rewrites the
// Version is the release version.line inlibs/skills/skills.go. The second PR to merge gets a text conflict. The #8076 text says that a release source "sets it to the release tag". After this PR, the value is the tag without its leading "v". - In #8115,
readBundledcomparesbundled.Versionwithcat.Version. After this PR, the live and cached catalogs report the release tag, but the bundled copy still reports the manifest'sversionfield. Then the check always fails, and the bundled fallback never serves a file. This fails closed, so it is safe. The bundled snapshot must record its release tag before #8115 depends on that fallback.
CI: 17 of 27 check runs pass and 10 are skipped. No check fails or is pending.
| Skills []Skill | ||
|
|
||
| // Version is the release version. | ||
| // Version is the release version: the release tag without its leading "v" |
There was a problem hiding this comment.
[nice to have] This doc names two cases: the published release and a local folder. The bundled copy is a third case. NewBundledSource in libs/skills/bundled_source.go builds its catalog with NewFSSource, so it also reports the manifest's version field. A reader can think that every source except a local folder reports a release tag. Add the bundled copy to the manifest-version case. For example: "A local folder and the bundled copy report the manifest's version field."
Note: the earlier bot comment said that this tree has no bundled source. That is not correct. libs/skills/bundled_source.go is on main since #8077, and this file still names the bundled copy in the package doc and in the FetchedAt and Stale docs.
There was a problem hiding this comment.
Fixed in bfd4c24: the Catalog.Version doc now says a local folder and the bundled copy report the manifest's version field.
| // vendor-fix would become endor-fix. | ||
| func releaseVersion(ref string) string { | ||
| // semver.Canonical drops build metadata, so compare without it. | ||
| base, _, _ := strings.Cut(ref, "+") |
There was a problem hiding this comment.
[nit] releaseVersion removes the build part before the check, but it does not check that the full ref is valid. For v1.2.3+ (an empty build part, which is not valid semver), it returns 1.2.3+. The doc above says that only a full tag loses its "v". Only a mistyped DATABRICKS_SKILLS_REF gives this input, so the risk is low. Add semver.IsValid(ref) && to the condition.
There was a problem hiding this comment.
Fixed in bfd4c24: the condition now starts with semver.IsValid(ref), so v1.2.3+ is returned as given. Added it as a test case.
| } | ||
|
|
||
| func TestReleaseSourceVersionIsReleaseTagNotManifestVersion(t *testing.T) { | ||
| manifest := func(skillVersion string) fs.FS { |
There was a problem hiding this comment.
[nit] manifest is an inline closure that only names a repeated operation. It captures nothing. .agents/rules/style-guide-go.md says: "Do not declare inline function closures just to name a repeated operation. Extract a regular named function instead." Move it to a named test helper, for example func releaseWithSkillVersion(v string) fs.FS.
There was a problem hiding this comment.
Fixed in bfd4c24: the closure is now the named helper releaseWithSkillVersion.
| } | ||
| serveReleases(t, map[string]fs.FS{"v1.2.0": release, "v1.2.3+build.1": release, "1.2.0": release, "vendor-fix": release, "v2": release}) | ||
|
|
||
| for ref, want := range map[string]string{"v1.2.0": "1.2.0", "v1.2.3+build.1": "1.2.3+build.1", "1.2.0": "1.2.0", "vendor-fix": "vendor-fix", "v2": "v2"} { |
There was a problem hiding this comment.
[nit] This loop goes over a map without t.Run. If require.NoError fails for one ref, the test stops, and the cases after it do not run. The map order is random, so the skipped cases change from run to run. Use t.Run(ref, ...), as the other table tests in this file do. Also add a pre-release case, for example v1.2.3-rc.1 gives 1.2.3-rc.1.
There was a problem hiding this comment.
Fixed in bfd4c24: the cases run under t.Run per ref, and I added v1.2.3-rc.1 -> 1.2.3-rc.1 (plus v1.2.3+ as given).
…sion test Co-authored-by: Isaac <no-reply@databricks.com>
Changes
The release skills source now sets
Catalog.Versionto the release tag it resolved, without the leadingv, instead of the manifest'sversionfield. A local folder source (DATABRICKS_SKILLS_DIR) keeps the manifest value. TheCatalog.Versiondoc now covers the release, a local folder, and a pinned branch or commit ref.Why
The manifest's
versionfield is the manifest schema version ("2"in every release), not the release. Any cache keyed byCatalog.Versionwould give two different releases one entry. This lands the release-source half of the fix asked for in the blocking thread onlibs/skills/chain.goline 82 of #8115: #8115 (comment). The other parts of that thread, recording the tag in the bundled snapshot and a chain-level test with two releases that share a manifest version, follow in a later change. It lands on main on its own, so #8076 and #8115 do not change.The feature stays behind
DATABRICKS_SKILLS_PREVIEW: the skills commands are hidden without it, so default CLI behaviour and existing goldens are unchanged. The guard test is the existing acceptance caseacceptance/cmd/skills/disabled: it runsskills listwithDATABRICKS_SKILLS_PREVIEWunset and expectsunknown command "skills", and checks the root help does not listskills. Nothing outside the gated command group reaches the changed code, so no further guard test is needed. No changelog entry is added, because the feature is preview-gated.Tests
"version": "2"report different catalog versions, equal to their tags.vreports the version without it. A ref that is not a semantic version, such asvendor-fix, is reported as given.go test ./libs/skills/...,go test ./acceptance -run 'TestAccept/cmd/skills',./task fmt-q lint-q.This pull request and its description were written by Isaac.