feat: add GitCode Actions (CI) API support#18
Conversation
- Updated GitCode OpenAPI spec with 19 new action endpoints (artifact,
run, job, runner-group, runner-set, runner management)
- Added TagReassign rule for bare repos/{o}/{r} to prevent Users tag
pollution from new spec
- Added view configs for action/list, action/list-runs, action/list-jobs
- Added smoke test scenarios for action artifacts and action runs
- Fixed build_test.go to apply builtin normalizer rules in tests
New commands:
cora gitcode action list # list repo artifacts
cora gitcode action list-runs # list workflow runs
cora gitcode action list-jobs # list run jobs
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Welcome To opensourceways CommunityHey @TommyLike , thanks for your contribution to the community. Bot Usage ManualI'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. |
CLA Signature PassTommyLike, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
Linking Issue Notice@TommyLike , the pull request must be linked to at least one issue. |
There was a problem hiding this comment.
Code Review
This pull request introduces built-in views for GitCode action commands (list, list-runs, list-jobs), adds scenario tests for action artifacts and runs, and updates the tag reassignment rules. Feedback on the changes highlights two main issues: first, the broad path prefix rule for repositories may incorrectly hijack and group action-related endpoints under the repositories tag, which can be resolved by adding a more specific rule for actions; second, the test helper duplicates normalization rules from the registry, which should instead be loaded directly via the registry package to avoid maintenance overhead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| }, | ||
| TagReassign: []spec.TagReassignRule{ | ||
| {PathPrefix: "/api/v5/repos/{owner}/{repo}/pulls", Tag: "Pulls"}, | ||
| {PathPrefix: "/api/v5/repos/{owner}/{repo}", Tag: "Repositories"}, |
There was a problem hiding this comment.
The newly added bare prefix rule {PathPrefix: "/api/v5/repos/{owner}/{repo}", Tag: "Repositories"} will match any sub-paths under /api/v5/repos/{owner}/{repo} that do not have a more specific rule. This includes the newly added Actions/CI endpoints (e.g., /api/v5/repos/{owner}/{repo}/actions/...), which will be incorrectly reassigned to "Repositories" (and thus grouped under the repos command instead of action).
To prevent this hijacking and ensure the Actions/CI endpoints are correctly grouped under the action command, add an explicit, more specific TagReassign rule for the /actions sub-path.
| {PathPrefix: "/api/v5/repos/{owner}/{repo}", Tag: "Repositories"}, | |
| {PathPrefix: "/api/v5/repos/{owner}/{repo}/actions", Tag: "Action"}, | |
| {PathPrefix: "/api/v5/repos/{owner}/{repo}", Tag: "Repositories"}, |
| // Apply built-in normalizer rules (same as LoadSpec in registry). | ||
| normalizer := builtinNormalizer(svcName) | ||
| if normalizer != nil { | ||
| s = normalizer.Normalize(s) | ||
| } | ||
| cfg := &config.Config{Services: map[string]config.ServiceConfig{svcName: {BaseURL: "http://x"}}} | ||
| return Build(svcName, s, cfg, executor.New(cfg), view.NewRegistry()) | ||
| } | ||
|
|
||
| // builtinNormalizer returns the built-in normalizer for a service, or nil. | ||
| func builtinNormalizer(svcName string) *spec.Normalizer { | ||
| switch svcName { | ||
| case "gitcode": | ||
| return spec.NewNormalizer(spec.NormalizeRule{ | ||
| ResourceAlias: map[string]string{ | ||
| "repositories": "repos", | ||
| "organizations": "orgs", | ||
| "pull-requests": "pulls", | ||
| }, | ||
| TagReassign: []spec.TagReassignRule{ | ||
| {PathPrefix: "/api/v5/repos/{owner}/{repo}/pulls", Tag: "Pulls"}, | ||
| {PathPrefix: "/api/v5/repos/{owner}/{repo}", Tag: "Repositories"}, | ||
| {PathPrefix: "/api/v5/repos/{owner}/{repo}/issues", Tag: "Issues"}, | ||
| {PathPrefix: "/api/v5/repos/{owner}/{repo}/labels", Tag: "Labels"}, | ||
| {PathPrefix: "/api/v5/repos/{owner}/{repo}/branches", Tag: "Branch"}, | ||
| {PathPrefix: "/api/v5/repos/{owner}/{repo}/tags", Tag: "Tag"}, | ||
| {PathPrefix: "/api/v5/repos/{owner}/{repo}/releases", Tag: "Release"}, | ||
| {PathPrefix: "/api/v5/repos/{owner}/{repo}/milestones", Tag: "Milestone"}, | ||
| }, | ||
| OpIDVerbExtract: true, | ||
| }) | ||
| } | ||
| return nil | ||
| } |
There was a problem hiding this comment.
The builtinNormalizer function duplicates the entire gitcodeNormalize rule definition from internal/registry/builtin.go. This introduces a maintenance hazard where any updates to the normalization rules must be manually synchronized across both files.
Instead of duplicating the rules, you can leverage the existing registry package to load and normalize the spec. This ensures that the tests always run against the exact same normalization rules used in production.
Note: You will need to add "github.com/opensourceways/cora/internal/registry" to the import block at the top of this file.
_ = loader
_ = data
cfg := &config.Config{
Services: map[string]config.ServiceConfig{svcName: {BaseURL: "http://x"}},
}
cfg.SpecCache.Dir = t.TempDir()
reg := registry.New(cfg)
entry, err := reg.Lookup(svcName)
if err != nil {
t.Fatalf("failed to lookup service %s: %v", svcName, err)
}
s, err = entry.LoadSpec(context.Background())
if err != nil {
t.Fatalf("failed to load %s spec: %v", svcName, err)
}
return Build(svcName, s, cfg, executor.New(cfg), view.NewRegistry())
}
CLA Signature PassTommyLike, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
- Add /actions TagReassign rule to prevent bare repos rule from hijacking actions endpoints - Replace duplicated normalizer rules in tests with registry.New() to ensure parity with production LoadSpec behavior Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
21d9554 to
1290e27
Compare
CLA Signature PassTommyLike, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
Summary
Add GitCode Actions/CI API support with 19 new endpoints.
Changes
assets/openapi/gitcode/openapi.jsoninternal/registry/builtin.gorepos/{o}/{r}internal/view/builtin.gointernal/builder/build_test.goscenarios/gitcode/action-artifacts.yamlscenarios/gitcode/action-runs.yamlNew Commands
Quality
go test ./...— all passgo vet ./...— cleangofmt -l .— cleanGenerated with Claude Code