Substitute matrix variables into category input
This is a common case, so we should handle it.
This commit is contained in:
parent
e2d523ca5e
commit
daf4614f68
6 changed files with 119 additions and 53 deletions
52
lib/workflow.test.js
generated
52
lib/workflow.test.js
generated
|
|
@ -355,8 +355,8 @@ function errorCodes(actual, expected) {
|
|||
on: ["push"]
|
||||
`)), []));
|
||||
});
|
||||
(0, ava_1.default)("getCategoryInput returns category for simple workflow with category", (t) => {
|
||||
t.is((0, workflow_1.getCategoryInput)(yaml.load(`
|
||||
(0, ava_1.default)("tryGetCategoryInput returns category for simple workflow with category", (t) => {
|
||||
t.is((0, workflow_1.tryGetCategoryInput)(yaml.load(`
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
@ -366,10 +366,10 @@ function errorCodes(actual, expected) {
|
|||
- uses: github/codeql-action/analyze@v2
|
||||
with:
|
||||
category: some-category
|
||||
`)), "some-category");
|
||||
`), {}), "some-category");
|
||||
});
|
||||
(0, ava_1.default)("getCategoryInput returns undefined for simple workflow without category", (t) => {
|
||||
t.is((0, workflow_1.getCategoryInput)(yaml.load(`
|
||||
(0, ava_1.default)("tryGetCategoryInput returns undefined for simple workflow without category", (t) => {
|
||||
t.is((0, workflow_1.tryGetCategoryInput)(yaml.load(`
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
@ -377,30 +377,42 @@ function errorCodes(actual, expected) {
|
|||
- uses: actions/checkout@v2
|
||||
- uses: github/codeql-action/init@v2
|
||||
- uses: github/codeql-action/analyze@v2
|
||||
`)), undefined);
|
||||
`), {}), undefined);
|
||||
});
|
||||
(0, ava_1.default)("getCategoryInput throws error for workflow with dynamic category", (t) => {
|
||||
t.throws(() => (0, workflow_1.getCategoryInput)(yaml.load(`
|
||||
(0, ava_1.default)("tryGetCategoryInput finds category for workflow with language matrix", (t) => {
|
||||
t.is((0, workflow_1.tryGetCategoryInput)(yaml.load(`
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
language: [javascript, python]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: github/codeql-action/init@v2
|
||||
with:
|
||||
language: \${{ matrix.language }}
|
||||
- uses: github/codeql-action/analyze@v2
|
||||
with:
|
||||
category: "/language:\${{ matrix.language }}"
|
||||
`), { language: "javascript" }), "/language:javascript");
|
||||
});
|
||||
(0, ava_1.default)("tryGetCategoryInput throws error for workflow with dynamic category", (t) => {
|
||||
t.throws(() => (0, workflow_1.tryGetCategoryInput)(yaml.load(`
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
language: [javascript, python]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: github/codeql-action/init@v2
|
||||
with:
|
||||
language: \${{ matrix.language }}
|
||||
- uses: github/codeql-action/analyze@v2
|
||||
with:
|
||||
category: "/language:\${{ matrix.language }}"
|
||||
`)), {
|
||||
message: "Could not get category input since it contained a dynamic value.",
|
||||
category: "\${{ github.workflow }}"
|
||||
`), {}), {
|
||||
message: "Could not get category input since it contained an unrecognized dynamic value.",
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("getCategoryInput throws error for workflow with multiple categories", (t) => {
|
||||
t.throws(() => (0, workflow_1.getCategoryInput)(yaml.load(`
|
||||
(0, ava_1.default)("tryGetCategoryInput throws error for workflow with multiple categories", (t) => {
|
||||
t.throws(() => (0, workflow_1.tryGetCategoryInput)(yaml.load(`
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
@ -413,7 +425,7 @@ function errorCodes(actual, expected) {
|
|||
- uses: github/codeql-action/analyze@v2
|
||||
with:
|
||||
category: another-category
|
||||
`)), {
|
||||
`), {}), {
|
||||
message: "Could not get category input since multiple categories were specified by the analysis step.",
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue