Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
runreal-warman committed Nov 4, 2024
2 parents e720bf2 + 0978ce1 commit 0c43131
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 139 deletions.
151 changes: 13 additions & 138 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9\\-]*$",
"description": "Workflow id"
},
"name": {
"type": "string",
"description": "Workflow name"
Expand Down
6 changes: 5 additions & 1 deletion src/commands/workflow/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export const exec = new Command<GlobalOptions>()
const { dryRun, mode } = options
const cfg = config.get(options as CliOptions) as any

const run = cfg.workflows.find((w: any) => w.name === workflow)
if (!cfg.workflows) {
throw new ValidationError('No workflows defined in config')
}

const run = cfg.workflows.find((w) => w.id === workflow || w.name === workflow)
if (!run) {
throw new ValidationError(`Workflow ${workflow} not found`)
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const ConfigSchema = z.object({
}),
workflows: z.array(
z.object({
id: z.string().regex(new RegExp('^[a-zA-Z0-9][a-zA-Z0-9\\-]*$')).optional().describe('Workflow id'),
name: z.string().describe('Workflow name'),
steps: z.array(
z.object({
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/test.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"workflows": [
{
"id": "compile-client",
"name": "compile client",
"steps": [
{
Expand All @@ -27,6 +28,7 @@
]
},
{
"id": "compile-server",
"name": "compile server",
"steps": [
{
Expand All @@ -43,6 +45,7 @@
]
},
{
"id": "cook-all",
"name": "cook all",
"steps": [
{
Expand All @@ -59,6 +62,7 @@
]
},
{
"id": "package-client",
"name": "package client",
"steps": [
{
Expand All @@ -79,6 +83,7 @@
]
},
{
"id": "package-server",
"name": "package server",
"steps": [
{
Expand Down
3 changes: 3 additions & 0 deletions tests/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Deno.test('renderConfig should deeply replace all placeholders in config object'
metadata: { ts: '2024-02-29T12:34:56Z' },
workflows: [
{
id: 'compile',
name: 'compile',
steps: [
{
Expand All @@ -109,6 +110,7 @@ Deno.test('renderConfig should deeply replace all placeholders in config object'
metadata: { ts: '2024-02-29T12:34:56Z' },
workflows: [
{
id: 'compile',
name: 'compile',
steps: [
{
Expand All @@ -135,6 +137,7 @@ Deno.test('replace paths in template', () => {
metadata: { ts: '2024-02-29T12:34:56Z' },
workflows: [
{
id: 'compile',
name: 'compile',
steps: [
{
Expand Down

0 comments on commit 0c43131

Please sign in to comment.