Skip to content
Draft

draft #349

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
39 changes: 39 additions & 0 deletions languageservice/src/complete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,45 @@ jobs:
});
});

describe("permissions workflows completion", () => {
it("includes workflows in top-level permissions", async () => {
const input = `on: push
permissions:
|`;
const result = await complete(...getPositionFromCursor(input));

expect(result).not.toBeUndefined();
const labels = result.map(x => x.label);
expect(labels).toContain("workflows");
});

it("offers only write and none for workflows", async () => {
const input = `on: push
permissions:
workflows: |`;
const result = await complete(...getPositionFromCursor(input));

expect(result).not.toBeUndefined();
const labels = result.map(x => x.label);
expect(labels).toContain("write");
expect(labels).not.toContain("read");
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

The test name says it "offers only write and none" for workflows, but the assertions only check for write and absence of read. Add an assertion that none is offered (and consider asserting no other values are present) so the test matches its intent and guards the permission-level-write-or-no-access behavior.

Suggested change
expect(labels).not.toContain("read");
expect(labels).toContain("none");
expect([...labels].sort()).toEqual(["none", "write"]);

Copilot uses AI. Check for mistakes.
});

it("includes workflows in job-level permissions", async () => {
const input = `on: push
jobs:
build:
runs-on: ubuntu-latest
permissions:
|`;
const result = await complete(...getPositionFromCursor(input));

expect(result).not.toBeUndefined();
const labels = result.map(x => x.label);
expect(labels).toContain("workflows");
});
});
Comment on lines +1019 to +1056
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

This PR states it enables both autocomplete and validation for permissions: workflows: write, but the added tests only cover completion. Consider adding a validation test that workflows: write is accepted and workflows: read is rejected to ensure the schema change is exercised through the validation pipeline too.

Copilot uses AI. Check for mistakes.

describe("service container command/entrypoint completion", () => {
it("suggests entrypoint and command in service container", async () => {
const input = `on: push
Expand Down
4 changes: 4 additions & 0 deletions workflow-parser/src/workflow-v1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,10 @@
"statuses": {
"type": "permission-level-any",
"description": "Commit statuses."
},
"workflows": {
"type": "permission-level-write-or-no-access",
"description": "Update GitHub Actions workflow files."
}
}
}
Expand Down
Loading