feat: accept plain yaml/yml/json profiles in cloned repos and gists#74
Merged
Conversation
`raid profile add <git-url>` previously only picked up profile files matching the *.raid.yaml convention (or profile.json). Single-file gists and scratch repos that just contain `profile.yaml` or `myprofile.yml` would clone successfully but then fail with "No profile files found in repository". When the primary patterns (profile.raid.yaml, *.raid.yaml/*.raid.yml, profile.json) match nothing, fall back to any plain .yaml/.yml/.json at the repo root. processProfileFiles validates each candidate against the profile schema, so non-profile YAML in a repo root is still rejected with a clear "Skipping … invalid profile" message rather than misbehaving. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #74 +/- ##
==========================================
+ Coverage 90.71% 90.88% +0.17%
==========================================
Files 33 33
Lines 2788 2798 +10
==========================================
+ Hits 2529 2543 +14
+ Misses 169 167 -2
+ Partials 90 88 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends raid profile add <url> to support cloned repositories and single-file gists whose profile files don’t follow the *.raid.yaml / profile.json naming conventions, by adding a fallback that considers plain .yaml / .yml / .json files at the repo root when no primary matches are found.
Changes:
- Add a fallback in
findProfileFilesInDirto consider any root.yaml/.yml/.jsonwhen no*.raid.yaml/profile.jsonfiles are found. - Add tests covering the new fallback behavior and priority preservation when
*.raid.yamlexists. - Update docs/release notes and bump the beta patch version.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/resources/app.properties | Bumps app version to 0.10.1-beta. |
| src/cmd/profile/fetch.go | Adds fallback profile-file discovery for plain YAML/YML/JSON in cloned repos/gists. |
| src/cmd/profile/fetch_test.go | Adds coverage for the fallback discovery and precedence rules. |
| site/docs/usage/profile.mdx | Documents gist/scratch-repo behavior and adds examples. |
| site/docs/whats-new.mdx | Adds a 0.10.1 release note entry for the fallback behavior. |
Comment on lines
+185
to
+193
| for _, e := range entries { | ||
| if e.IsDir() { | ||
| continue | ||
| } | ||
| ext := strings.ToLower(filepath.Ext(e.Name())) | ||
| if ext == ".yaml" || ext == ".yml" || ext == ".json" { | ||
| add(e.Name()) | ||
| } | ||
| } |
Comment on lines
+146
to
+155
| func TestFindProfileFilesInDir_plainYAMLFallback(t *testing.T) { | ||
| dir := t.TempDir() | ||
| // A plain .yaml file should not be picked up. | ||
| // Single-file gist scenario: a plain .yaml at the root, no *.raid.yaml. | ||
| // Should be picked up as a fallback. | ||
| writeRaidYAML(t, dir, "plain.yaml", "p") | ||
| got := findProfileFilesInDir(dir) | ||
| if len(got) != 0 { | ||
| t.Errorf("findProfileFilesInDir plain yaml: got %v, want none", got) | ||
| if len(got) != 1 || !strings.HasSuffix(got[0], "plain.yaml") { | ||
| t.Errorf("findProfileFilesInDir plain yaml fallback: got %v", got) | ||
| } | ||
| } |
Copilot review feedback on #74: the new plain-yaml fallback in findProfileFilesInDir can now match arbitrary root yamls (e.g. docker-compose.yaml from a gist or scratch repo). Those candidates fail schema validation in processProfileFiles and the function previously returned exit 0 with "No new profiles found" — the same code path used when "all profiles already exist", which masks a real failure and means `raid profile add <url>` would falsely report success. Differentiate the two cases: - queued empty AND existingNames non-empty → "all already exist", exit 0 (unchanged for the ergonomic re-run case). - queued empty AND existingNames empty → "No valid profiles found", exit 1. Also adds a regression test exercising exactly the gist-style scenario flagged in the review: a cloned repo containing only docker-compose.yaml, which now correctly exits 1. Existing tests that assumed schema-invalid input was a soft success (httpURL_invalidProfile, httpURL_unmarshalError, invalidProfileName) updated to assert the new — and more correct — exit-1 behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The plain-yaml fallback in findProfileFilesInDir skips subdirectories (only files are profile candidates), but no existing test exercised that branch — the codecov/patch check was flagging it as uncovered. Real-world example: a scratch repo with docs/ and assets/ alongside a profile.yaml at the root. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Extends
raid profile add <url>so single-file gists (and scratch repos) whose profile file isn't named with the*.raid.yamlconvention work without renaming.Before: cloning a gist containing
profile.yaml(ormyprofile.yml,config.json) succeeded, butfindProfileFilesInDirmatched nothing and the user gotNo profile files found in repository.After: when none of the primary patterns (
profile.raid.yaml,*.raid.yaml/*.raid.yml,profile.json) match, raid falls back to any plain.yaml/.yml/.jsonat the repo root.processProfileFilesruns the same schema validation on each candidate, so non-profile YAML is still rejected withSkipping … invalid profilerather than producing incorrect behavior.Files
src/cmd/profile/fetch.go— fallback branch infindProfileFilesInDir.src/cmd/profile/fetch_test.go— tests covering: single plain.yamlfalls through, plain.yamlis NOT picked up when a*.raid.yamlis present (priority preserved), multiple plain files all selected, plain.jsonfallback. ExistingnoRaidYAML_noJSONtest renamed/repurposed to assert the new behavior.site/docs/usage/profile.mdx— example using a gist URL.site/docs/whats-new.mdx—0.10.1entry.src/resources/app.properties— version 0.10.0-beta → 0.10.1-beta (patch bump per CLAUDE.md, small enhancement).Test plan
go test ./...— all packages green.cmd/profilecoverage holds at 89.0%.cd site && npm run build— no broken links.🤖 Generated with Claude Code