-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add working directory support to commands #353
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
feat: Add working directory support to commands #353
Conversation
Users can now specify a custom working_directory for each command
in their app.json configuration. This allows commands to run in
different directories than the app's default path.
Changes:
- Added WorkingDirectory field to CommandSpec struct
- Updated pr.yaml template to use command-specific working_directory
- Regenerated JSON schema to include new field
- Added tests for working_directory field unmarshalling
- Updated playground workflows with regenerated templates
Example usage:
{
"commands": {
"test": {
"command": "pnpm test",
"working_directory": "packages/core"
}
}
}
Backwards compatible: commands without working_directory continue
to use the app's path as before.
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #353 +/- ##
==========================================
+ Coverage 64.59% 69.47% +4.87%
==========================================
Files 154 184 +30
Lines 6064 7279 +1215
==========================================
+ Hits 3917 5057 +1140
+ Misses 2064 2025 -39
- Partials 83 197 +114 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The setup function in cmd_test.go has parameters that appear unused because the test is skipped with t.Skip(). Added nolint:unparam to suppress the linter warning until the test is properly implemented.
This comment has been minimized.
This comment has been minimized.
Updated the Commands section in the apps documentation to reflect: - The three command formats (boolean, string, object) - Correct field names (command instead of run) - New working_directory field with examples - Other fields like skip_ci and timeout - Removed outdated 'enabled' field from examples This aligns the documentation with the actual implementation.
Review summary
This PR successfully adds working directory support to commands in a clean, backwards-compatible manner. The implementation is solid with good test coverage for the struct unmarshalling. The feature is well-documented with clear examples. However, there's a missing integration test to verify the template generation works correctly with the new field. Critical issues 🔴None Warnings 🟡Missing integration test for template generation
Suggested test caset.Run("WorkingDirectory Field", func(t *testing.T) {
t.Parallel()
appDef := &appdef.Definition{
Apps: []appdef.App{
{
Name: "web",
Title: "Web",
Path: "./web",
Type: appdef.AppTypeGoLang,
Commands: types.NewOrderedMap[Command, CommandSpec](),
},
},
}
// Add a command with working_directory
appDef.Apps[0].Commands.Set(CommandTest, CommandSpec{
Cmd: "go test ./...",
WorkingDirectory: "./packages/core",
})
input := setup(t, afero.NewMemMapFs(), appDef)
err := PR(t.Context(), input)
require.NoError(t, err)
file, err := afero.ReadFile(input.FS, filepath.Join(workflowsPath, "pr.yaml"))
require.NoError(t, err)
content := string(file)
assert.Contains(t, content, "working-directory: ./packages/core")
}Suggestions 🟢1. Consider path validation
This could be added in a follow-up PR if desired. 2. Documentation clarity on path resolution
Consider adding a sentence to clarify: "The |
Users can now specify a custom working_directory for each command in their app.json configuration. This allows commands to run in different directories than the app's default path.
Changes:
Example usage:
{
"commands": { "test": { "command": "pnpm test", "working_directory": "packages/core" } } }
Backwards compatible: commands without working_directory continue to use the app's path as before.