feat(build): add workflow output aliases

This commit is contained in:
Virgil 2026-04-02 03:02:43 +00:00
parent 0fca52d975
commit 4b707a11f2
2 changed files with 34 additions and 0 deletions

View file

@ -113,6 +113,8 @@ func initWorkflowFlags() {
releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathAliasInput, "workflowOutputPath", "", i18n.T("cmd.build.workflow.flag.workflow_output_path"))
releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathHyphenAliasInput, "workflow-output-path", "", i18n.T("cmd.build.workflow.flag.workflow_output_path"))
releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathSnakeAliasInput, "workflow_output_path", "", i18n.T("cmd.build.workflow.flag.workflow_output_path"))
releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathAliasInput, "workflow-output", "", i18n.T("cmd.build.workflow.flag.workflow_output_path"))
releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathAliasInput, "workflow_output", "", i18n.T("cmd.build.workflow.flag.workflow_output_path"))
}
// buildCmd := &cli.Command{Use: "build"}
@ -133,6 +135,8 @@ func AddWorkflowCommand(buildCmd *cli.Command) {
// runReleaseWorkflow(ctx, releaseWorkflowInputs{outputPathInput: "ci/release.yml"}) // uses the outputPath alias
// runReleaseWorkflow(ctx, releaseWorkflowInputs{legacyOutputInput: "ci/release.yml"}) // uses the legacy output alias
// runReleaseWorkflow(ctx, releaseWorkflowInputs{workflowOutputPathInput: "ci/release.yml"}) // uses the workflowOutputPath alias
// runReleaseWorkflow(ctx, releaseWorkflowInputs{workflowOutputPathInput: "ci/release.yml"}) // uses the workflow-output alias
// runReleaseWorkflow(ctx, releaseWorkflowInputs{workflowOutputPathInput: "ci/release.yml"}) // uses the workflow_output alias
// runReleaseWorkflow(ctx, releaseWorkflowInputs{workflowOutputPathSnakeInput: "ci/release.yml"}) // uses the workflow_output_path alias
// runReleaseWorkflow(ctx, releaseWorkflowInputs{workflowOutputPathHyphenInput: "ci/release.yml"}) // uses the workflow-output-path alias
func runReleaseWorkflow(_ context.Context, inputs releaseWorkflowInputs) error {

View file

@ -159,6 +159,8 @@ func TestBuildCmd_RunReleaseWorkflow_Good(t *testing.T) {
workflowOutputPathCamelFlag := releaseWorkflowCmd.Flags().Lookup("workflowOutputPath")
workflowOutputPathFlag := releaseWorkflowCmd.Flags().Lookup("workflow-output-path")
workflowOutputPathSnakeFlag := releaseWorkflowCmd.Flags().Lookup("workflow_output_path")
workflowOutputFlag := releaseWorkflowCmd.Flags().Lookup("workflow-output")
workflowOutputSnakeFlag := releaseWorkflowCmd.Flags().Lookup("workflow_output")
assert.NotNil(t, pathFlag)
assert.NotNil(t, workflowPathCamelFlag)
@ -181,6 +183,10 @@ func TestBuildCmd_RunReleaseWorkflow_Good(t *testing.T) {
assert.NotNil(t, workflowOutputPathCamelFlag)
assert.NotEmpty(t, workflowOutputPathFlag.Usage)
assert.NotEmpty(t, workflowOutputPathSnakeFlag.Usage)
assert.NotNil(t, workflowOutputFlag)
assert.NotNil(t, workflowOutputSnakeFlag)
assert.NotEmpty(t, workflowOutputFlag.Usage)
assert.NotEmpty(t, workflowOutputSnakeFlag.Usage)
assert.NotEqual(t, pathFlag.Usage, outputFlag.Usage)
assert.Equal(t, pathFlag.Usage, workflowPathCamelFlag.Usage)
assert.Equal(t, pathFlag.Usage, workflowPathFlag.Usage)
@ -190,6 +196,8 @@ func TestBuildCmd_RunReleaseWorkflow_Good(t *testing.T) {
assert.Equal(t, outputPathFlag.Usage, outputPathSnakeFlag.Usage)
assert.Equal(t, workflowOutputPathFlag.Usage, workflowOutputPathCamelFlag.Usage)
assert.Equal(t, workflowOutputPathFlag.Usage, workflowOutputPathSnakeFlag.Usage)
assert.Equal(t, workflowOutputPathFlag.Usage, workflowOutputFlag.Usage)
assert.Equal(t, workflowOutputPathFlag.Usage, workflowOutputSnakeFlag.Usage)
})
t.Run("writes to a custom relative path", func(t *testing.T) {
@ -301,4 +309,26 @@ func TestBuildCmd_RunReleaseWorkflow_Good(t *testing.T) {
assert.Contains(t, content, "workflow_call:")
assert.Contains(t, content, "workflow_dispatch:")
})
t.Run("writes to the workflow-output alias", func(t *testing.T) {
customPath := "ci/workflow-output-release.yml"
err := runReleaseWorkflowInDir(projectDir, "", customPath)
require.NoError(t, err)
content, err := io.Local.Read(ax.Join(projectDir, customPath))
require.NoError(t, err)
assert.Contains(t, content, "workflow_call:")
assert.Contains(t, content, "workflow_dispatch:")
})
t.Run("writes to the workflow_output alias", func(t *testing.T) {
customPath := "ci/workflow_output-release.yml"
err := runReleaseWorkflowInDir(projectDir, "", customPath)
require.NoError(t, err)
content, err := io.Local.Read(ax.Join(projectDir, customPath))
require.NoError(t, err)
assert.Contains(t, content, "workflow_call:")
assert.Contains(t, content, "workflow_dispatch:")
})
}