Compare commits

...

6 Commits

Author SHA1 Message Date
Beth Brennan 872c873c9d Merge pull request #10 from actions/release/0.3.0
Release version 0.3.0
2023-03-27 17:13:13 -04:00
GitHub Actions 29e676fad1 Release extension version 0.3.0 2023-03-27 20:49:33 +00:00
Beth Brennan e8b3c20aca Merge pull request #9 from actions/elbrenn/actions-provider
Wrap fetchActionsMetadata in provider checking sessionToken
2023-03-27 16:47:05 -04:00
Beth Brennan 50f9c04a91 Wrap fetchActionsMetadata in provider checking sessionToken 2023-03-27 14:00:58 -04:00
Christopher Schleiden 9c4b8a4c1c Merge pull request #8 from actions/joshmgross/update-codeowners
Update CODEOWNERS
2023-03-23 16:37:45 -07:00
Josh Gross 6b1e4ff115 Update CODEOWNERS 2023-03-23 19:07:33 -04:00
13 changed files with 168 additions and 2377 deletions
+1 -1
View File
@@ -1 +1 @@
* @github/c2c-actions-experience-parser-reviewers
* @actions/actions-experience
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@actions/expressions",
"version": "0.2.0",
"version": "0.3.0",
"license": "MIT",
"type": "module",
"source": "./src/index.ts",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@actions/languageserver",
"version": "0.2.0",
"version": "0.3.0",
"description": "Language server for GitHub Actions",
"license": "MIT",
"type": "module",
@@ -43,8 +43,8 @@
"watch": "tsc --build tsconfig.build.json --watch"
},
"dependencies": {
"@actions/languageservice": "^0.2.0",
"@actions/workflow-parser": "^0.2.0",
"@actions/languageservice": "^0.3.0",
"@actions/workflow-parser": "^0.3.0",
"@octokit/rest": "^19.0.7",
"@octokit/types": "^9.0.0",
"vscode-languageserver": "^8.0.2",
+2 -8
View File
@@ -26,7 +26,7 @@ import {getFileProvider} from "./file-provider";
import {InitializationOptions, RepositoryContext} from "./initializationOptions";
import {onCompletion} from "./on-completion";
import {ReadFileRequest, Requests} from "./request";
import {fetchActionMetadata} from "./utils/action-metadata";
import {getActionsMetadataProvider} from "./utils/action-metadata";
import {TTLCache} from "./utils/cache";
import {timeOperation} from "./utils/timer";
import {valueProviders} from "./value-providers";
@@ -108,13 +108,7 @@ export function initConnection(connection: Connection) {
const config: ValidationConfig = {
valueProviderConfig: valueProviders(client, repoContext, cache),
contextProviderConfig: contextProviders(client, repoContext, cache),
fetchActionMetadata: async action => {
if (client) {
return await fetchActionMetadata(client, cache, action);
}
return undefined;
},
actionsMetadataProvider: getActionsMetadataProvider(client, cache),
fileProvider: getFileProvider(client, cache, repoContext?.workspaceUri, async path => {
return await connection.sendRequest(Requests.ReadFile, {path} satisfies ReadFileRequest);
})
@@ -1,10 +1,24 @@
import {actionIdentifier, ActionMetadata, ActionReference} from "@actions/languageservice/action";
import {ActionsMetadataProvider} from "@actions/languageservice";
import {error} from "@actions/languageservice/log";
import {Octokit, RestEndpointMethodTypes} from "@octokit/rest";
import {parse} from "yaml";
import {TTLCache} from "./cache";
import {errorMessage, errorStatus} from "./error";
export function getActionsMetadataProvider(
client: Octokit | undefined,
cache: TTLCache
): ActionsMetadataProvider | undefined {
if (!client) {
return undefined;
}
return {
fetchActionMetadata: async action => fetchActionMetadata(client, cache, action)
};
}
export async function fetchActionMetadata(
client: Octokit,
cache: TTLCache,
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@actions/languageservice",
"version": "0.2.0",
"version": "0.3.0",
"description": "Language service for GitHub Actions",
"license": "MIT",
"type": "module",
@@ -44,8 +44,8 @@
"watch": "tsc --build tsconfig.build.json --watch"
},
"dependencies": {
"@actions/expressions": "^0.2.0",
"@actions/workflow-parser": "^0.2.0",
"@actions/expressions": "^0.3.0",
"@actions/workflow-parser": "^0.3.0",
"vscode-languageserver-textdocument": "^1.0.7",
"vscode-languageserver-types": "^3.17.2",
"vscode-uri": "^3.0.7",
+1 -1
View File
@@ -3,5 +3,5 @@ export {ContextProviderConfig} from "./context-providers/config";
export {documentLinks} from "./document-links";
export {hover} from "./hover";
export {Logger, LogLevel, registerLogger, setLogLevel} from "./log";
export {validate, ValidationConfig} from "./validate";
export {validate, ValidationConfig, ActionsMetadataProvider} from "./validate";
export {ValueProviderConfig, ValueProviderKind} from "./value-providers/config";
+2 -2
View File
@@ -14,7 +14,7 @@ export async function validateAction(
step: Step | undefined,
config: ValidationConfig | undefined
): Promise<void> {
if (!isMapping(stepToken) || !step || !isActionStep(step) || !config?.fetchActionMetadata) {
if (!isMapping(stepToken) || !step || !isActionStep(step) || !config?.actionsMetadataProvider) {
return;
}
@@ -23,7 +23,7 @@ export async function validateAction(
return;
}
const actionMetadata = await config.fetchActionMetadata(action);
const actionMetadata = await config.actionsMetadataProvider.fetchActionMetadata(action);
if (actionMetadata === undefined) {
diagnostics.push({
severity: DiagnosticSeverity.Error,
+81 -64
View File
@@ -14,75 +14,77 @@ beforeEach(() => {
});
const validationConfig: ValidationConfig = {
fetchActionMetadata: (ref: ActionReference) => {
let metadata: ActionMetadata | undefined = undefined;
switch (ref.owner + "/" + ref.name + "@" + ref.ref) {
case "actions/checkout@v3":
metadata = {
name: "Checkout",
description: "Checkout a Git repository at a particular version",
inputs: {
repository: {
description: "Repository name with owner",
default: "${{ github.repository }}"
actionsMetadataProvider: {
fetchActionMetadata: (ref: ActionReference) => {
let metadata: ActionMetadata | undefined = undefined;
switch (ref.owner + "/" + ref.name + "@" + ref.ref) {
case "actions/checkout@v3":
metadata = {
name: "Checkout",
description: "Checkout a Git repository at a particular version",
inputs: {
repository: {
description: "Repository name with owner",
default: "${{ github.repository }}"
}
}
}
};
break;
case "actions/setup-node@v1":
metadata = {
name: "Setup Node.js environment",
description:
"Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH.",
inputs: {
version: {
description: "Deprecated. Use node-version instead. Will not be supported after October 1, 2019",
deprecationMessage:
"The version property will not be supported after October 1, 2019. Use node-version instead"
};
break;
case "actions/setup-node@v1":
metadata = {
name: "Setup Node.js environment",
description:
"Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH.",
inputs: {
version: {
description: "Deprecated. Use node-version instead. Will not be supported after October 1, 2019",
deprecationMessage:
"The version property will not be supported after October 1, 2019. Use node-version instead"
}
}
}
};
break;
case "actions/deploy-pages@main":
metadata = {
name: "Deploy GitHub Pages site",
description: "A GitHub Action to deploy an artifact as a GitHub Pages site",
inputs: {
token: {
required: true,
description: "token to use",
default: "${{ github.token }}"
};
break;
case "actions/deploy-pages@main":
metadata = {
name: "Deploy GitHub Pages site",
description: "A GitHub Action to deploy an artifact as a GitHub Pages site",
inputs: {
token: {
required: true,
description: "token to use",
default: "${{ github.token }}"
}
}
}
};
break;
case "actions/cache@v1":
metadata = {
name: "Cache",
description: "Cache artifacts like dependencies and build outputs to improve workflow execution time",
inputs: {
path: {
description: "A directory to store and save the cache",
required: true
},
key: {
description: "An explicit key for restoring and saving the cache",
required: true
},
"restore-keys": {
description: "An ordered list of keys to use for restoring the cache if no cache hit occurred for key",
required: false
};
break;
case "actions/cache@v1":
metadata = {
name: "Cache",
description: "Cache artifacts like dependencies and build outputs to improve workflow execution time",
inputs: {
path: {
description: "A directory to store and save the cache",
required: true
},
key: {
description: "An explicit key for restoring and saving the cache",
required: true
},
"restore-keys": {
description: "An ordered list of keys to use for restoring the cache if no cache hit occurred for key",
required: false
}
}
}
};
break;
case "actions/action-no-input@v1":
metadata = {
name: "Action with no inputs",
description: "An action with no inputs"
};
};
break;
case "actions/action-no-input@v1":
metadata = {
name: "Action with no inputs",
description: "An action with no inputs"
};
}
return Promise.resolve(metadata);
}
return Promise.resolve(metadata);
}
};
@@ -101,6 +103,21 @@ jobs:
expect(result).toEqual([]);
});
it("no actionsMetadataProvider", async () => {
const input = `
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/does-not-exist@v3
`;
const config: ValidationConfig = {};
const result = await validate(createDocument("wf.yaml", input), config);
expect(result).toEqual([]);
});
it("action does not exist", async () => {
const input = `
on: push
+5 -1
View File
@@ -28,10 +28,14 @@ import {defaultValueProviders} from "./value-providers/default";
export type ValidationConfig = {
valueProviderConfig?: ValueProviderConfig;
contextProviderConfig?: ContextProviderConfig;
fetchActionMetadata?(action: ActionReference): Promise<ActionMetadata | undefined>;
actionsMetadataProvider?: ActionsMetadataProvider;
fileProvider?: FileProvider;
};
export type ActionsMetadataProvider = {
fetchActionMetadata(action: ActionReference): Promise<ActionMetadata | undefined>;
};
/**
* Validates a workflow file
*
+1 -1
View File
@@ -1,5 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "0.2.0"
"version": "0.3.0"
}
+52 -2290
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@actions/workflow-parser",
"version": "0.2.0",
"version": "0.3.0",
"license": "MIT",
"type": "module",
"source": "./src/index.ts",
@@ -43,7 +43,7 @@
"watch": "tsc --build tsconfig.build.json --watch"
},
"dependencies": {
"@actions/expressions": "^0.2.0",
"@actions/expressions": "^0.3.0",
"cronstrue": "^2.21.0",
"yaml": "^2.0.0-8"
},