Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use core.group instead for more strict grouping #718

Merged
merged 1 commit into from
Nov 4, 2023
Merged
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
392 changes: 196 additions & 196 deletions dist/index.js

Large diffs are not rendered by default.

332 changes: 166 additions & 166 deletions dist/post/index.js

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions lint-doc/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lint-fmt/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions lint-opam/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions packages/lint-doc/src/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import * as core from "@actions/core";
import { exec } from "@actions/exec";

export async function installOpamPackages() {
core.startGroup("Install opam packages");
await exec("opam", ["install", ".", "--deps-only", "--with-doc"]);
core.endGroup();
await core.group("Install opam packages", async () => {
await exec("opam", ["install", ".", "--deps-only", "--with-doc"]);
});
}

export async function installOdoc() {
core.startGroup("Install odoc");
await exec("opam", ["depext", "--install", "conf-m4", "dune", "odoc>=1.5.0"]);
core.endGroup();
await core.group("Install odoc", async () => {
await exec("opam", [
"depext",
"--install",
"conf-m4",
"dune",
"odoc>=1.5.0",
]);
});
}
6 changes: 3 additions & 3 deletions packages/lint-fmt/src/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as core from "@actions/core";
import { exec } from "@actions/exec";

export async function installOcamlformat(version: string) {
core.startGroup("Install ocamlformat");
await exec("opam", ["depext", "--install", `ocamlformat=${version}`]);
core.endGroup();
await core.group("Install ocamlformat", async () => {
await exec("opam", ["depext", "--install", `ocamlformat=${version}`]);
});
}
24 changes: 12 additions & 12 deletions packages/lint-opam/src/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import * as core from "@actions/core";
import { exec } from "@actions/exec";

export async function installOpamPackages() {
core.startGroup("Install opam packages");
await exec("opam", [
"install",
".",
"--deps-only",
"--with-test",
"--with-doc",
]);
core.endGroup();
await core.group("Install opam packages", async () => {
await exec("opam", [
"install",
".",
"--deps-only",
"--with-test",
"--with-doc",
]);
});
}

export async function installOpamDuneLint() {
core.startGroup("Install opam-dune-lint");
await exec("opam", ["depext", "--install", "opam-dune-lint"]);
core.endGroup();
await core.group("Install opam-dune-lint", async () => {
await exec("opam", ["depext", "--install", "opam-dune-lint"]);
});
}
100 changes: 50 additions & 50 deletions packages/setup-ocaml/src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,75 +220,75 @@ async function saveCache(key: string, paths: string[]) {
}

export async function restoreCygwinCache() {
core.startGroup("Retrieve the Cygwin cache");
const { key, restoreKeys } = await composeCygwinCacheKeys();
const paths = composeCygwinCachePaths();
await restoreCache(key, restoreKeys, paths);
core.endGroup();
await core.group("Retrieve the Cygwin cache", async () => {
const { key, restoreKeys } = await composeCygwinCacheKeys();
const paths = composeCygwinCachePaths();
await restoreCache(key, restoreKeys, paths);
});
}

export async function saveCygwinCache() {
core.startGroup("Save the Cygwin cache");
const { key } = await composeCygwinCacheKeys();
const paths = composeCygwinCachePaths();
await saveCache(key, paths);
core.endGroup();
await core.group("Save the Cygwin cache", async () => {
const { key } = await composeCygwinCacheKeys();
const paths = composeCygwinCachePaths();
await saveCache(key, paths);
});
}

export async function restoreDuneCache() {
core.startGroup("Retrieve the dune cache");
const { key, restoreKeys } = composeDuneCacheKeys();
const paths = composeDuneCachePaths();
await restoreCache(key, restoreKeys, paths);
core.endGroup();
await core.group("Retrieve the dune cache", async () => {
const { key, restoreKeys } = composeDuneCacheKeys();
const paths = composeDuneCachePaths();
await restoreCache(key, restoreKeys, paths);
});
}

export async function saveDuneCache() {
core.startGroup("Save the dune cache");
const { key } = composeDuneCacheKeys();
const paths = composeDuneCachePaths();
await saveCache(key, paths);
core.endGroup();
await core.group("Save the dune cache", async () => {
const { key } = composeDuneCacheKeys();
const paths = composeDuneCachePaths();
await saveCache(key, paths);
});
}

export async function restoreOpamCache() {
core.startGroup("Retrieve the opam cache");
const { key, restoreKeys } = await composeOpamCacheKeys();
const paths = composeOpamCachePaths();
const cacheKey = await restoreCache(key, restoreKeys, paths);
core.endGroup();
return cacheKey;
return await core.group("Retrieve the opam cache", async () => {
const { key, restoreKeys } = await composeOpamCacheKeys();
const paths = composeOpamCachePaths();
const cacheKey = await restoreCache(key, restoreKeys, paths);
return cacheKey;
});
}

export async function saveOpamCache() {
core.startGroup("Save the opam cache");
await exec("opam", [
"clean",
"--all-switches",
"--download-cache",
"--logs",
"--repo-cache",
"--unused-repositories",
]);
const { key } = await composeOpamCacheKeys();
const paths = composeOpamCachePaths();
await saveCache(key, paths);
core.endGroup();
await core.group("Save the opam cache", async () => {
await exec("opam", [
"clean",
"--all-switches",
"--download-cache",
"--logs",
"--repo-cache",
"--unused-repositories",
]);
const { key } = await composeOpamCacheKeys();
const paths = composeOpamCachePaths();
await saveCache(key, paths);
});
}

export async function restoreOpamDownloadCache() {
core.startGroup("Retrieve the opam download cache");
const { key, restoreKeys } = composeOpamDownloadCacheKeys();
const paths = composeOpamDownloadCachePaths();
const cacheKey = await restoreCache(key, restoreKeys, paths);
core.endGroup();
return cacheKey;
return await core.group("Retrieve the opam download cache", async () => {
const { key, restoreKeys } = composeOpamDownloadCacheKeys();
const paths = composeOpamDownloadCachePaths();
const cacheKey = await restoreCache(key, restoreKeys, paths);
return cacheKey;
});
}

export async function saveOpamDownloadCache() {
core.startGroup("Save the opam download cache");
const { key } = composeOpamDownloadCacheKeys();
const paths = composeOpamDownloadCachePaths();
await saveCache(key, paths);
core.endGroup();
await core.group("Save the opam download cache", async () => {
const { key } = composeOpamDownloadCacheKeys();
const paths = composeOpamDownloadCachePaths();
await saveCache(key, paths);
});
}
41 changes: 23 additions & 18 deletions packages/setup-ocaml/src/depext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@ import { OPAM_DEPEXT_FLAGS, Platform } from "./constants";
import { getPlatform } from "./system";

export async function installDepext(ocamlVersion: string) {
core.startGroup("Install depext");
const platform = getPlatform();
const depextCygwinports =
platform === Platform.Win32 ? ["depext-cygwinports"] : [];
await exec("opam", ["install", "opam-depext", ...depextCygwinports]);
if (platform === Platform.Win32) {
let base = "";
if (ocamlVersion.includes("mingw64")) {
base = "x86_64-w64-mingw32";
} else if (ocamlVersion.includes("mingw32")) {
base = "i686-w64-mingw32";
await core.group("Install depext", async () => {
const platform = getPlatform();
const depextCygwinports =
platform === Platform.Win32 ? ["depext-cygwinports"] : [];
await exec("opam", ["install", "opam-depext", ...depextCygwinports]);
if (platform === Platform.Win32) {
let base = "";
if (ocamlVersion.includes("mingw64")) {
base = "x86_64-w64-mingw32";
} else if (ocamlVersion.includes("mingw32")) {
base = "i686-w64-mingw32";
}
core.addPath(
path.posix.join("/", "usr", base, "sys-root", "mingw", "bin"),
);
}
core.addPath(path.posix.join("/", "usr", base, "sys-root", "mingw", "bin"));
}
core.endGroup();
});
}

export async function installDepextPackages(fpaths: string[]) {
core.startGroup("Install system packages required by opam packages");
const fnames = fpaths.map((fpath) => path.basename(fpath, ".opam"));
await exec("opam", ["depext", ...fnames, ...OPAM_DEPEXT_FLAGS]);
core.endGroup();
await core.group(
"Install system packages required by opam packages",
async () => {
const fnames = fpaths.map((fpath) => path.basename(fpath, ".opam"));
await exec("opam", ["depext", ...fnames, ...OPAM_DEPEXT_FLAGS]);
},
);
}
49 changes: 26 additions & 23 deletions packages/setup-ocaml/src/dune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,33 @@ const {
} = github.context;

export async function installDune() {
core.startGroup("Install dune");
await exec("opam", ["depext", "--install", "dune"]);
core.endGroup();
await core.group("Install dune", async () => {
await exec("opam", ["depext", "--install", "dune"]);
});
}

export async function trimDuneCache() {
core.startGroup("Remove oldest files from the dune cache to free space");
const octokit = github.getOctokit(GITHUB_TOKEN);
const {
data: { total_count: totalCount },
} = await octokit.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id,
});
const cacheSize = Math.floor(5000 / totalCount);
await exec("opam", [
"exec",
"--",
"dune",
"cache",
"trim",
"--size",
`${cacheSize}MB`,
]);
core.endGroup();
await core.group(
"Remove oldest files from the dune cache to free space",
async () => {
const octokit = github.getOctokit(GITHUB_TOKEN);
const {
data: { total_count: totalCount },
} = await octokit.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id,
});
const cacheSize = Math.floor(5000 / totalCount);
await exec("opam", [
"exec",
"--",
"dune",
"cache",
"trim",
"--size",
`${cacheSize}MB`,
]);
},
);
}
Loading
Loading