-
Notifications
You must be signed in to change notification settings - Fork 46
fix: resolve create harness Dockerfile paths from command cwd #1474
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
Open
kiwigitops
wants to merge
1
commit into
aws:main
Choose a base branch
from
kiwigitops:fix-create-harness-dockerfile-base
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { ConfigIO } from '../../../lib'; | ||
| import { createDefaultProjectSpec } from '../../project'; | ||
| import { HarnessPrimitive } from '../HarnessPrimitive'; | ||
| import { randomUUID } from 'node:crypto'; | ||
| import { mkdir, readFile, rm, writeFile } from 'node:fs/promises'; | ||
| import { tmpdir } from 'node:os'; | ||
| import { join } from 'node:path'; | ||
| import { afterEach, describe, expect, it } from 'vitest'; | ||
|
|
||
| describe('HarnessPrimitive', () => { | ||
| const tempDirs: string[] = []; | ||
|
|
||
| afterEach(async () => { | ||
| await Promise.all(tempDirs.map(dir => rm(dir, { recursive: true, force: true }))); | ||
| tempDirs.length = 0; | ||
| }); | ||
|
|
||
| it('resolves create-flow Dockerfile paths from the command working directory', async () => { | ||
| const commandCwd = join(tmpdir(), `harness-dockerfile-${randomUUID()}`); | ||
| tempDirs.push(commandCwd); | ||
| const projectRoot = join(commandCwd, 'HarnessProject'); | ||
| const configBaseDir = join(projectRoot, 'agentcore'); | ||
| await mkdir(projectRoot, { recursive: true }); | ||
|
|
||
| const configIO = new ConfigIO({ baseDir: configBaseDir }); | ||
| await configIO.initializeBaseDir(); | ||
| await configIO.writeAWSDeploymentTargets([]); | ||
| await configIO.writeDeployedState({ targets: {} }); | ||
| await configIO.writeProjectSpec(createDefaultProjectSpec('HarnessProject')); | ||
|
|
||
| await writeFile(join(commandCwd, 'Dockerfile.custom'), 'FROM public.ecr.aws/docker/library/python:3.12\n'); | ||
|
|
||
| const result = await new HarnessPrimitive().add({ | ||
| name: 'MyHarness', | ||
| modelProvider: 'bedrock', | ||
| modelId: 'global.anthropic.claude-sonnet-4-6', | ||
| skipMemory: true, | ||
| dockerfilePath: './Dockerfile.custom', | ||
| dockerfileBaseDir: commandCwd, | ||
| configBaseDir, | ||
| }); | ||
|
|
||
| expect(result.success).toBe(true); | ||
| const harnessDir = join(projectRoot, 'app', 'MyHarness'); | ||
| await expect(readFile(join(harnessDir, 'Dockerfile.custom'), 'utf-8')).resolves.toContain('python:3.12'); | ||
|
|
||
| const harnessSpec = JSON.parse(await readFile(join(harnessDir, 'harness.json'), 'utf-8')); | ||
| expect(harnessSpec.dockerfile).toBe('Dockerfile.custom'); | ||
| }); | ||
| }); |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: might be worth a brief comment here noting that
dockerfileBaseDirintentionally uses CWD (not outputDir) since the Dockerfile is a source input.