-
Notifications
You must be signed in to change notification settings - Fork 1
feat(flows): GitLab as a ticket source and repository host in onboarding #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cab6295
fix(flows): check the repository the way its CI does, and never throw…
5814e6e
fix(flows): look for checks again when the change adds the first test…
af387c4
feat(flows): give generated flows a two-hour wall-clock budget
10f7739
feat(flows): GitLab as a ticket source and repository host in onboarding
f5f1ef3
fix(flows): refuse relocating the local kit into a GitLab repository
1854914
fix(flows): compare against the base in the same tree, bound checks o…
38312f6
fix(flows): run the branch's check recipe against the base even when …
d3b89ef
Merge remote-tracking branch 'origin/fix/flow-resilient-checks' into …
6f79f6d
fix(flows): judge a GitLab remote by its host, not by its path
db7adaa
Merge remote-tracking branch 'origin/main' into feat/flows-gitlab-onb…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import ts from 'typescript'; | ||
| import { DEFAULT_FACTORY, factorySource, type FactoryDraft } from '../flow-onboarding'; | ||
| import { flowPreview } from '../flow-preview'; | ||
| import { localInput } from '../flow-local'; | ||
| import { ISSUE_SOURCES, issueSourceCode, repositoryHost, validSourcePreferences } from '../flow-sources'; | ||
|
|
||
| /** | ||
| * GitLab as a ticket source and, without a GitHub source, as the deploy target. | ||
| * The shapes follow AgentWorkforce/cloud#3800/#3801: the deploy handoff reads | ||
| * `sourceSettings.gitlab.project` ("namespace/project") and `labels`, and a | ||
| * delivered GitLab issue reaches the flow as | ||
| * `{ source: "gitlab", title, body, labels, project }`. | ||
| */ | ||
| const gitlab: FactoryDraft = { | ||
| ...DEFAULT_FACTORY, sources: ['gitlab'], agents: ['claude'], workflow: 'simple', step: 3, | ||
| sourceSettings: { gitlab: { project: 'AgentWorkforce-group/AgentWorkforce-project', labels: 'garden-ready' } }, | ||
| }; | ||
|
|
||
| /** Every export of the generated local flow, with `flow()` returning the body. */ | ||
| function load(source: string) { | ||
| const exports: Record<string, unknown> = {}; | ||
| const compiled = ts.transpileModule(source.replace('import { flow } from "@relayflows/surface";', ''), | ||
| { compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS } }); | ||
| new Function('exports', 'flow', compiled.outputText)(exports, (_name: string, _header: unknown, fn: unknown) => fn); | ||
| return exports as { issueRejection: (issue: unknown) => string }; | ||
| } | ||
|
|
||
| describe('GitLab ticket source', () => { | ||
| it('is offered with a project path and required labels, like GitHub', () => { | ||
| const source = ISSUE_SOURCES.find(item => item.id === 'gitlab')!; | ||
| expect(source.label).toBe('GitLab'); | ||
| expect(source.fields.map(field => field.key)).toEqual(['project', 'labels']); | ||
| }); | ||
|
|
||
| it('keeps GitLab settings through storage validation and refuses fields it does not have', () => { | ||
| expect(validSourcePreferences({ gitlab: { project: 'group/project', labels: 'ready' } })).toBe(true); | ||
| expect(validSourcePreferences({ gitlab: { repository: 'group/project' } })).toBe(false); | ||
| expect(validSourcePreferences({ gitlab: { mentioned: true } })).toBe(false); | ||
| }); | ||
|
|
||
| it('makes GitLab the repository host only when no GitHub source is chosen, as Cloud infers it', () => { | ||
| expect(repositoryHost(['gitlab'])).toBe('gitlab'); | ||
| expect(repositoryHost(['gitlab', 'linear'])).toBe('gitlab'); | ||
| expect(repositoryHost(['github', 'gitlab'])).toBe('github'); | ||
| expect(repositoryHost(['linear'])).toBe('github'); | ||
| expect(repositoryHost([])).toBe('github'); | ||
| }); | ||
|
|
||
| it('declares the project field Cloud delivers on a GitLab issue', () => { | ||
| expect(issueSourceCode(['gitlab'], gitlab.sourceSettings)).toContain('project?: string;'); | ||
| }); | ||
|
|
||
| it('filters a local GitLab ticket by project (case-insensitively) and labels', () => { | ||
| const { issueRejection } = load(factorySource(gitlab, 'local')); | ||
| const ticket = { source: 'gitlab', title: 't', body: 'b', labels: ['garden-ready'], project: 'agentworkforce-group/agentworkforce-project' }; | ||
| expect(issueRejection(ticket)).toBe(''); | ||
| expect(issueRejection({ ...ticket, project: 'other-group/app' })).toContain('project is "other-group/app"'); | ||
| expect(issueRejection({ ...ticket, labels: [] })).toContain('missing required label: garden-ready'); | ||
| // The kit's own prefilled ticket passes its own filters. | ||
| expect(issueRejection(localInput(gitlab).issue!)).toBe(''); | ||
| }); | ||
|
|
||
| it('shows the GitLab mark on the change-request step when GitLab is the host', () => { | ||
| const openStep = (draft: FactoryDraft) => flowPreview(draft)?.nodes.find(node => 'icons' in node && node.title === 'Open PR') as { icons: string[] } | undefined; | ||
| expect(openStep(gitlab)?.icons).toEqual(['gitlab']); | ||
| expect(openStep({ ...gitlab, sources: ['github', 'gitlab'] })?.icons).toEqual(['github']); | ||
| }); | ||
|
|
||
| it('hands Cloud the settings its deploy page reads to pick the GitLab project', () => { | ||
| // cloudConnectionsHref passes sources/sourceSettings through untouched; | ||
| // Cloud's flow-handoff reads sourceSettings.gitlab.project from them. | ||
| const source = factorySource(gitlab); | ||
| expect(source).toContain('relayflow-open-change'); | ||
| expect(gitlab.sourceSettings.gitlab?.project).toMatch(/^[^/\s]+(\/[^/\s]+)+$/); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.