Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions languageservice/src/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ beforeEach(() => {

describe("validation", () => {
it("valid workflow", async () => {
const result = await validate(createDocument("wf.yaml", "on: push\njobs:\n build:\n runs-on: ubuntu-latest"));
const result = await validate(
createDocument("wf.yaml", "on: push\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - run: echo")
);

expect(result.length).toBe(0);
});
Expand Down Expand Up @@ -144,7 +146,9 @@ jobs:
jobs:
build:
runs-on:
- ubuntu-latest`
- ubuntu-latest
steps:
- run: echo hello`
),
{valueProviderConfig: defaultValueProviders}
);
Expand Down Expand Up @@ -174,7 +178,9 @@ jobs:
- cron: '0 0 * *'
jobs:
build:
runs-on: ubuntu-latest`
runs-on: ubuntu-latest
steps:
- run: echo hello`
),
{valueProviderConfig: defaultValueProviders}
);
Expand Down
99 changes: 90 additions & 9 deletions workflow-parser/src/model/convert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ describe("convertWorkflowTemplate", () => {
content: `on: push
jobs:
build:
runs-on: ubuntu-latest`
runs-on: ubuntu-latest
steps: []`
},
nullTrace
);
Expand Down Expand Up @@ -55,9 +56,11 @@ jobs:
build:
if: \${{ true }}
runs-on: ubuntu-latest
steps: []
deploy:
if: true
runs-on: ubuntu-latest`
runs-on: ubuntu-latest
steps: []`
},
nullTrace
);
Expand Down Expand Up @@ -105,7 +108,8 @@ jobs:
jobs:
build:
needs: # comment to preserve whitespace in test
runs-on: ubuntu-latest`
runs-on: ubuntu-latest
steps: []`
},
nullTrace
);
Expand Down Expand Up @@ -150,11 +154,17 @@ jobs:
job1:
needs: [unknown-job, job3]
runs-on: ubuntu-latest
steps:
- run: echo job1
job2:
runs-on: ubuntu-latest
steps:
- run: echo job2
job3:
needs: job1
runs-on: ubuntu-latest`
runs-on: ubuntu-latest
steps:
- run: echo job3`
},
nullTrace
);
Expand All @@ -174,7 +184,7 @@ jobs:
},
{
Message:
"wf.yaml (Line: 9, Col: 12): Job 'job3' depends on job 'job1' which creates a cycle in the dependency graph."
"wf.yaml (Line: 13, Col: 12): Job 'job3' depends on job 'job1' which creates a cycle in the dependency graph."
}
],
events: {
Expand All @@ -190,7 +200,16 @@ jobs:
name: "job1",
needs: ["unknown-job", "job3"],
"runs-on": "ubuntu-latest",
steps: [],
steps: [
{
id: "__run",
if: {
expr: "success()",
type: 3
},
run: "echo job1"
}
],
type: "job"
},
{
Expand All @@ -201,7 +220,16 @@ jobs:
},
name: "job2",
"runs-on": "ubuntu-latest",
steps: [],
steps: [
{
id: "__run",
if: {
expr: "success()",
type: 3
},
run: "echo job2"
}
],
type: "job"
},
{
Expand All @@ -213,7 +241,16 @@ jobs:
name: "job3",
needs: ["job1"],
"runs-on": "ubuntu-latest",
steps: [],
steps: [
{
id: "__run",
if: {
expr: "success()",
type: 3
},
run: "echo job3"
}
],
type: "job"
}
]
Expand Down Expand Up @@ -316,6 +353,49 @@ jobs:
});
});

it("converts workflow with one job without steps", async () => {
const result = parseWorkflow(
{
name: "wf.yaml",
content: `on: push
jobs:
build:
runs-on: ubuntu-latest`
},
nullTrace
);

const template = await convertWorkflowTemplate(result.context, result.value!, undefined, {
errorPolicy: ErrorPolicy.TryConversion
});

expect(serializeTemplate(template)).toEqual({
errors: [
{
Message: "wf.yaml (Line: 4, Col: 5): Required property is missing: steps"
}
],
events: {
push: {}
},
jobs: [
{
id: "build",
if: {
expr: "success()",
type: 3
},
name: "build",
needs: undefined,
outputs: undefined,
"runs-on": "ubuntu-latest",
steps: [],
type: "job"
}
]
});
});

// Extra coverage since workflow_call components are not all covered by x-lang parsers
it("converts workflow_call on", async () => {
const result = parseWorkflow(
Expand All @@ -336,7 +416,8 @@ jobs:
secret2:
jobs:
build:
runs-on: ubuntu-latest`
runs-on: ubuntu-latest
steps: []`
},
nullTrace
);
Expand Down
5 changes: 4 additions & 1 deletion workflow-parser/src/workflow-v1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,10 @@
"concurrency": "job-concurrency",
"outputs": "job-outputs",
"defaults": "job-defaults",
"steps": "steps",
"steps": {
"type": "steps",
"required": true
},
"snapshot": "snapshot"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include-source: false # Drop file/line/col from output
---
on: push
jobs:
build:
runs-on: ubuntu-latest
---
{
"errors": [
{
"Message": ".github/workflows/errors-job-runs-on-and-no-steps.yml (Line: 4, Col: 5): Required property is missing: steps"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ jobs:
build:
runs-on: ubuntu-latest
uses: ./.github/workflows/foo.yml
steps:
- run: echo hello
Comment on lines +8 to +9
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding steps to a job that uses a reusable workflow (with uses) is incorrect. Jobs that call reusable workflows should not have steps - they delegate execution to the called workflow. This test case is validating that runs-on and uses cannot coexist on the same job. Adding steps here creates a confusing test case with multiple simultaneous validation errors (runs-on + uses + steps), when the test should focus solely on the runs-on + uses conflict.

Suggested change
steps:
- run: echo hello

Copilot uses AI. Check for mistakes.
---
{
"errors": [
Expand Down