Merge pull request #201 from lawrencegripper/lg/snapshot-keyword
Snapshot support
This commit is contained in:
@@ -9,10 +9,12 @@
|
|||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js",
|
||||||
|
"types": "./dist/index.d.ts"
|
||||||
},
|
},
|
||||||
"./*": {
|
"./*": {
|
||||||
"import": "./dist/*.js"
|
"import": "./dist/*.js",
|
||||||
|
"types": "./dist/*.d.ts"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"typesVersions": {
|
"typesVersions": {
|
||||||
|
|||||||
@@ -43,8 +43,8 @@
|
|||||||
"watch": "tsc --build tsconfig.build.json --watch"
|
"watch": "tsc --build tsconfig.build.json --watch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/languageservice": "^0.3.17",
|
"@actions/languageservice": "^0.3.18",
|
||||||
"@actions/workflow-parser": "^0.3.17",
|
"@actions/workflow-parser": "^0.3.18",
|
||||||
"@octokit/rest": "^21.1.1",
|
"@octokit/rest": "^21.1.1",
|
||||||
"@octokit/types": "^9.0.0",
|
"@octokit/types": "^9.0.0",
|
||||||
"vscode-languageserver": "^8.0.2",
|
"vscode-languageserver": "^8.0.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/languageservice",
|
"name": "@actions/languageservice",
|
||||||
"version": "0.3.17",
|
"version": "0.3.18",
|
||||||
"description": "Language service for GitHub Actions",
|
"description": "Language service for GitHub Actions",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/expressions": "^0.3.17",
|
"@actions/expressions": "^0.3.17",
|
||||||
"@actions/workflow-parser": "^0.3.17",
|
"@actions/workflow-parser": "^0.3.18",
|
||||||
"vscode-languageserver-textdocument": "^1.0.7",
|
"vscode-languageserver-textdocument": "^1.0.7",
|
||||||
"vscode-languageserver-types": "^3.17.2",
|
"vscode-languageserver-types": "^3.17.2",
|
||||||
"vscode-uri": "^3.0.8",
|
"vscode-uri": "^3.0.8",
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ jobs:
|
|||||||
|`;
|
|`;
|
||||||
const result = await complete(...getPositionFromCursor(input));
|
const result = await complete(...getPositionFromCursor(input));
|
||||||
expect(result).not.toBeUndefined();
|
expect(result).not.toBeUndefined();
|
||||||
expect(result.length).toEqual(20);
|
expect(result.length).toEqual(21);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("string definition completion in sequence", async () => {
|
it("string definition completion in sequence", async () => {
|
||||||
@@ -243,7 +243,7 @@ jobs:
|
|||||||
runs-|`;
|
runs-|`;
|
||||||
const result = await complete(...getPositionFromCursor(input));
|
const result = await complete(...getPositionFromCursor(input));
|
||||||
expect(result).not.toBeUndefined();
|
expect(result).not.toBeUndefined();
|
||||||
expect(result).toHaveLength(20);
|
expect(result).toHaveLength(21);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("job key with comment afterwards", async () => {
|
it("job key with comment afterwards", async () => {
|
||||||
@@ -254,7 +254,7 @@ jobs:
|
|||||||
#`;
|
#`;
|
||||||
const result = await complete(...getPositionFromCursor(input));
|
const result = await complete(...getPositionFromCursor(input));
|
||||||
expect(result).not.toBeUndefined();
|
expect(result).not.toBeUndefined();
|
||||||
expect(result).toHaveLength(20);
|
expect(result).toHaveLength(21);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("job key with other values afterwards", async () => {
|
it("job key with other values afterwards", async () => {
|
||||||
@@ -266,7 +266,7 @@ jobs:
|
|||||||
concurrency: 'group-name'`;
|
concurrency: 'group-name'`;
|
||||||
const result = await complete(...getPositionFromCursor(input));
|
const result = await complete(...getPositionFromCursor(input));
|
||||||
expect(result).not.toBeUndefined();
|
expect(result).not.toBeUndefined();
|
||||||
expect(result).toHaveLength(19);
|
expect(result).toHaveLength(20);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("step key without space after colon", async () => {
|
it("step key without space after colon", async () => {
|
||||||
@@ -335,7 +335,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
`;
|
`;
|
||||||
const result = await complete(...getPositionFromCursor(input));
|
const result = await complete(...getPositionFromCursor(input));
|
||||||
expect(result).toHaveLength(16);
|
expect(result).toHaveLength(17);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("complete from behind a colon will replace it", async () => {
|
it("complete from behind a colon will replace it", async () => {
|
||||||
@@ -348,7 +348,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
`;
|
`;
|
||||||
const result = await complete(...getPositionFromCursor(input));
|
const result = await complete(...getPositionFromCursor(input));
|
||||||
expect(result).toHaveLength(16);
|
expect(result).toHaveLength(17);
|
||||||
const textEdit = result[0].textEdit as TextEdit;
|
const textEdit = result[0].textEdit as TextEdit;
|
||||||
expect(textEdit.range).toEqual({
|
expect(textEdit.range).toEqual({
|
||||||
start: {line: 5, character: 4},
|
start: {line: 5, character: 4},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/workflow-parser",
|
"name": "@actions/workflow-parser",
|
||||||
"version": "0.3.17",
|
"version": "0.3.18",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"source": "./src/index.ts",
|
"source": "./src/index.ts",
|
||||||
@@ -9,10 +9,12 @@
|
|||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js",
|
||||||
|
"types": "./dist/index.d.ts"
|
||||||
},
|
},
|
||||||
"./*": {
|
"./*": {
|
||||||
"import": "./dist/*.js"
|
"import": "./dist/*.js",
|
||||||
|
"types": "./dist/*.d.ts"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"typesVersions": {
|
"typesVersions": {
|
||||||
|
|||||||
@@ -16,7 +16,16 @@ export function convertJob(context: TemplateContext, jobKey: StringToken, token:
|
|||||||
context.error(jobKey, error);
|
context.error(jobKey, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
let concurrency, container, env, environment, name, outputs, runsOn, services, strategy: TemplateToken | undefined;
|
let concurrency,
|
||||||
|
container,
|
||||||
|
env,
|
||||||
|
environment,
|
||||||
|
name,
|
||||||
|
outputs,
|
||||||
|
runsOn,
|
||||||
|
services,
|
||||||
|
strategy,
|
||||||
|
snapshot: TemplateToken | undefined;
|
||||||
let needs: StringToken[] | undefined = undefined;
|
let needs: StringToken[] | undefined = undefined;
|
||||||
let steps: Step[] = [];
|
let steps: Step[] = [];
|
||||||
let workflowJobRef: StringToken | undefined;
|
let workflowJobRef: StringToken | undefined;
|
||||||
@@ -86,6 +95,10 @@ export function convertJob(context: TemplateContext, jobKey: StringToken, token:
|
|||||||
services = item.value;
|
services = item.value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "snapshot":
|
||||||
|
snapshot = item.value;
|
||||||
|
break;
|
||||||
|
|
||||||
case "steps":
|
case "steps":
|
||||||
steps = convertSteps(context, item.value);
|
steps = convertSteps(context, item.value);
|
||||||
break;
|
break;
|
||||||
@@ -147,7 +160,8 @@ export function convertJob(context: TemplateContext, jobKey: StringToken, token:
|
|||||||
container,
|
container,
|
||||||
services,
|
services,
|
||||||
outputs,
|
outputs,
|
||||||
steps
|
steps,
|
||||||
|
snapshot
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export type BaseJob = {
|
|||||||
concurrency?: TemplateToken;
|
concurrency?: TemplateToken;
|
||||||
strategy?: TemplateToken;
|
strategy?: TemplateToken;
|
||||||
outputs?: MappingToken;
|
outputs?: MappingToken;
|
||||||
|
snapshot?: TemplateToken;
|
||||||
};
|
};
|
||||||
|
|
||||||
// `job-factory` in the schema
|
// `job-factory` in the schema
|
||||||
|
|||||||
@@ -1710,7 +1710,8 @@
|
|||||||
"concurrency": "job-concurrency",
|
"concurrency": "job-concurrency",
|
||||||
"outputs": "job-outputs",
|
"outputs": "job-outputs",
|
||||||
"defaults": "job-defaults",
|
"defaults": "job-defaults",
|
||||||
"steps": "steps"
|
"steps": "steps",
|
||||||
|
"snapshot": "snapshot"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1854,6 +1855,43 @@
|
|||||||
"loose-value-type": "any"
|
"loose-value-type": "any"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"snapshot": {
|
||||||
|
"description": "Use `snapshot` to define a custom image you want to create or update after your job succeeds by taking a snapshot of your runner.",
|
||||||
|
"one-of": [
|
||||||
|
"non-empty-string",
|
||||||
|
"snapshot-mapping"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"snapshot-mapping": {
|
||||||
|
"mapping": {
|
||||||
|
"properties": {
|
||||||
|
"image-name": {
|
||||||
|
"description": "The desired name of the custom image you want to create or update.",
|
||||||
|
"type": "non-empty-string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"if": "snapshot-if",
|
||||||
|
"version": {
|
||||||
|
"description": "The desired major version updates upon a new custom image version creation.",
|
||||||
|
"type": "non-empty-string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"snapshot-if": {
|
||||||
|
"context": [
|
||||||
|
"github",
|
||||||
|
"inputs",
|
||||||
|
"vars",
|
||||||
|
"needs",
|
||||||
|
"strategy",
|
||||||
|
"matrix"
|
||||||
|
],
|
||||||
|
"description": "Use the if conditional to prevent a snapshot from being taken unless a condition is met. Any supported context and expression can be used to create a conditional. Expressions in an `if` conditional do not require the bracketed expression syntax. When you use expressions in an `if` conditional, you may omit the expression syntax because GitHub automatically evaluates the `if` conditional as an expression.",
|
||||||
|
"string": {
|
||||||
|
"is-expression": true
|
||||||
|
}
|
||||||
|
},
|
||||||
"runs-on": {
|
"runs-on": {
|
||||||
"description": "Use `runs-on` to define the type of machine to run the job on.\n* The destination machine can be either a GitHub-hosted runner, larger runner, or a self-hosted runner.\n* You can target runners based on the labels assigned to them, or their group membership, or a combination of these.\n* You can provide `runs-on` as a single string or as an array of strings.\n* If you specify an array of strings, your workflow will execute on any runner that matches all of the specified `runs-on` values.\n* If you would like to run your workflow on multiple machines, use `jobs.<job_id>.strategy`.",
|
"description": "Use `runs-on` to define the type of machine to run the job on.\n* The destination machine can be either a GitHub-hosted runner, larger runner, or a self-hosted runner.\n* You can target runners based on the labels assigned to them, or their group membership, or a combination of these.\n* You can provide `runs-on` as a single string or as an array of strings.\n* If you specify an array of strings, your workflow will execute on any runner that matches all of the specified `runs-on` values.\n* If you would like to run your workflow on multiple machines, use `jobs.<job_id>.strategy`.",
|
||||||
"context": [
|
"context": [
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
include-source: false # Drop file/line/col from output
|
||||||
|
---
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo hi
|
||||||
|
snapshot:
|
||||||
|
image-name: custom-image
|
||||||
|
version: 1.*
|
||||||
|
if: ${{ github.event_name == 'something' }}
|
||||||
|
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"type": "job",
|
||||||
|
"id": "build",
|
||||||
|
"name": "build",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"runs-on": "ubuntu-latest",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "__run",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"run": "echo hi"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"snapshot": {
|
||||||
|
"type": 2,
|
||||||
|
"map": [
|
||||||
|
{
|
||||||
|
"Key": "image-name",
|
||||||
|
"Value": "custom-image"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Key": "version",
|
||||||
|
"Value": "1.*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Key": "if",
|
||||||
|
"Value": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "github.event_name == 'something'"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
include-source: false # Drop file/line/col from output
|
||||||
|
---
|
||||||
|
# on: push
|
||||||
|
# jobs:
|
||||||
|
# job1:
|
||||||
|
# runs-on: windows-2019
|
||||||
|
# snapshot: custom-image
|
||||||
|
# steps:
|
||||||
|
# - run: echo 1
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo hi
|
||||||
|
snapshot: custom-image
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"type": "job",
|
||||||
|
"id": "build",
|
||||||
|
"name": "build",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"runs-on": "ubuntu-latest",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "__run",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"run": "echo hi"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"snapshot": "custom-image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user