From 765b95080bd100f8289e77c64a7167e4eb8a573c Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 26 Jul 2025 12:24:41 +0000 Subject: [PATCH] fix: runs-on is also mandatory for reusable workflows and may be needing container (#194) If not the schema validation will fail because it will be try to validate as if not calling a reusable workflow. ``` === RUN TestWorkflowCallRunsOn schema_test.go:119: Error Trace: /home/earl-warren/software/act/pkg/schema/schema_test.go:119 Error: Received unexpected error: Line: 10 Column 5: Failed to match job-factory: Line: 12 Column 5: Unknown Property uses Line: 13 Column 5: Unknown Property with Line: 15 Column 5: Unknown Property secrets Line: 10 Column 5: Failed to match workflow-job: Line: 11 Column 5: Unknown Property runs-on Test: TestWorkflowCallRunsOn ``` Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/194 Reviewed-by: Michael Kriese Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- act/schema/schema_test.go | 30 ++++++++++++++++++++++++++++++ act/schema/workflow_schema.json | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/act/schema/schema_test.go b/act/schema/schema_test.go index ce571c96..30fc9d13 100644 --- a/act/schema/schema_test.go +++ b/act/schema/schema_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "gopkg.in/yaml.v3" ) @@ -90,3 +91,32 @@ jobs: }).UnmarshalYAML(&node) assert.NoError(t, err) } + +func TestWorkflowCallRunsOn(t *testing.T) { + var node yaml.Node + err := yaml.Unmarshal([]byte(` +name: Build Silo Frontend DEV +on: + push: + branches: + - dev + - dev-* +jobs: + build_frontend_dev: + name: Build Silo Frontend DEV + runs-on: ubuntu-latest + container: + image: code.forgejo.org/oci/node:22-bookworm + uses: ./.github/workflows/build.yaml + with: + STAGE: dev + secrets: + PACKAGE_WRITER_TOKEN: ${{ secrets.PACKAGE_WRITER_TOKEN }} +`), &node) + require.NoError(t, err) + n := &Node{ + Definition: "workflow-root", + Schema: GetWorkflowSchema(), + } + require.NoError(t, n.UnmarshalYAML(&node)) +} diff --git a/act/schema/workflow_schema.json b/act/schema/workflow_schema.json index a976259c..dad253d6 100644 --- a/act/schema/workflow_schema.json +++ b/act/schema/workflow_schema.json @@ -1472,6 +1472,11 @@ "type": "non-empty-string", "required": true }, + "runs-on": { + "type": "runs-on", + "required": true + }, + "container": "container", "with": "workflow-job-with", "secrets": "workflow-job-secrets", "needs": "needs",