Share default runner label list

This commit is contained in:
Beth Brennan
2023-02-08 12:22:27 -05:00
parent cfe75cef4a
commit 6c067e1fa5
2 changed files with 18 additions and 32 deletions
@@ -1,31 +1,16 @@
import {Value} from "@github/actions-languageservice/value-providers/config";
import {DEFAULT_RUNNER_LABELS} from "@github/actions-languageservice/value-providers/default";
import {Octokit} from "@octokit/rest";
import {TTLCache} from "../utils/cache";
// Limitation: getRunnerLabels returns default hosted labels and labels for repository self-hosted runners.
// It doesn't return labels for organization runners visible to the repository.
export async function getRunnerLabels(client: Octokit, cache: TTLCache, owner: string, name: string): Promise<Value[]> {
const defaultLabels = [
"ubuntu-latest",
"ubuntu-22.04",
"ubuntu-20.04",
"ubuntu-18.04",
"windows-latest",
"windows-2022",
"windows-2019",
"windows-2016",
"macos-latest",
"macos-12",
"macos-11",
"macos-10.15",
"self-hosted"
];
const repoLabels = await cache.get(`${owner}/${name}/runner-labels`, undefined, () =>
fetchRunnerLabels(client, owner, name)
);
for (const label of defaultLabels) {
for (const label of DEFAULT_RUNNER_LABELS) {
repoLabels.add(label);
}
@@ -4,6 +4,21 @@ import {needs} from "./needs";
import {reusableJobInputs} from "./reusable-job-inputs";
import {stringsToValues} from "./strings-to-values";
export const DEFAULT_RUNNER_LABELS = [
"ubuntu-latest",
"ubuntu-22.04",
"ubuntu-20.04",
"ubuntu-18.04",
"windows-latest",
"windows-2022",
"windows-2019",
"macos-latest",
"macos-12",
"macos-11",
"macos-10.15",
"self-hosted"
];
export const defaultValueProviders: ValueProviderConfig = {
needs: {
kind: ValueProviderKind.AllowedValues,
@@ -15,20 +30,6 @@ export const defaultValueProviders: ValueProviderConfig = {
},
"runs-on": {
kind: ValueProviderKind.SuggestedValues,
get: async (_: WorkflowContext) =>
stringsToValues([
"ubuntu-latest",
"ubuntu-22.04",
"ubuntu-20.04",
"ubuntu-18.04",
"windows-latest",
"windows-2022",
"windows-2019",
"macos-latest",
"macos-12",
"macos-11",
"macos-10.15",
"self-hosted"
])
get: async (_: WorkflowContext) => stringsToValues(DEFAULT_RUNNER_LABELS)
}
};