Skip to content

Commit

Permalink
In nektos/act, disable sandboxing and set OPAMROOTISOK
Browse files Browse the repository at this point in the history
using the act tool from https://github.com/nektos/act:
- Fix opam to run in act containers which have no /dev/pts for bubblewrap
  These containers act have no /dev/pts for bubblewrap == no sandboxing
- For act, set OPAMROOTISOK as act containers simulate a root user

Signed-off-by: Sora Morimoto <sora@morimoto.io>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Co-authored-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
  • Loading branch information
smorimoto and bernhardkaindl committed Dec 7, 2023
1 parent 420c920 commit 7b1f269
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to

- Add opam support for the Dependency submission API.

### Fixed

- Fix opam calls to support testing GitHub actions in local containers by using the act tool from [`nektos/act`](https://github.com/nektos/act).

### Removed

- Since decent official support is now available to deploy natively to GitHub Pages, `deploy-doc` has been deprecated and removed.
Expand Down
23 changes: 15 additions & 8 deletions dist/index.js

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

10 changes: 6 additions & 4 deletions dist/post/index.js

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

4 changes: 2 additions & 2 deletions packages/setup-ocaml/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const CYGWIN_ROOT_BIN = path.join(CYGWIN_ROOT, "bin");

export const CYGWIN_ROOT_WRAPPERBIN = path.join(CYGWIN_ROOT, "wrapperbin");

// [todo] remove the branch for Windows once opam 2.2 is released as stable.
// [TODO] remove the branch for Windows once opam 2.2 is released as stable.
export const ALLOW_PRERELEASE_OPAM =
PLATFORM !== "win32" &&
core.getBooleanInput("allow-prerelease-opam", {
Expand Down Expand Up @@ -69,7 +69,7 @@ export const OCAML_COMPILER = core.getInput("ocaml-compiler", {
trimWhitespace: true,
});

// [todo] remove this once opam 2.2 is released as stable.
// [TODO] remove this once opam 2.2 is released as stable.
export const OPAM_DEPEXT =
!ALLOW_PRERELEASE_OPAM &&
core.getBooleanInput("opam-depext", {
Expand Down
9 changes: 7 additions & 2 deletions packages/setup-ocaml/src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as process from "node:process";

import * as core from "@actions/core";
import { exec } from "@actions/exec";
import * as github from "@actions/github";

import {
restoreCygwinCache,
Expand Down Expand Up @@ -35,18 +36,22 @@ import { updateUnixPackageIndexFiles } from "./system.js";
import { resolveCompiler } from "./version.js";

export async function installer() {
// [NOTE] silence opam warnings triggered in act containers using root
if (github.context.actor === "nektos/act") {
core.exportVariable("OPAMROOTISOK", 1);
}
if (ALLOW_PRERELEASE_OPAM) {
core.exportVariable("OPAMCONFIRMLEVEL", "unsafe-yes");
} else {
// [todo] remove this once opam 2.2 is released as stable.
// [TODO] remove this once opam 2.2 is released as stable.
// https://github.com/ocaml/setup-ocaml/issues/299
core.exportVariable("OPAMCLI", "2.0");
}
core.exportVariable("OPAMCOLOR", "always");
core.exportVariable("OPAMERRLOGLEN", 0);
core.exportVariable("OPAMJOBS", os.cpus().length);
core.exportVariable("OPAMPRECISETRACKING", 1);
// [todo] remove this once opam 2.2 is released as stable.
// [TODO] remove this once opam 2.2 is released as stable.
// https://github.com/ocaml/opam/issues/3447
core.exportVariable("OPAMSOLVERTIMEOUT", 1000);
core.exportVariable("OPAMYES", 1);
Expand Down
6 changes: 4 additions & 2 deletions packages/setup-ocaml/src/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async function installUnixSystemPackages() {
if (PLATFORM === "linux") {
const { version: systemVersion } = await getSystemIdentificationInfo();
if (systemVersion === "18.04") {
// [info]: musl-tools bug in ubuntu 18.04;
// [INFO]: musl-tools bug in ubuntu 18.04;
// <https://github.com/ocaml/ocaml/issues/9131#issuecomment-599765888>
await exec("sudo", ["add-apt-repository", "ppa:avsm/musl"]);
}
Expand Down Expand Up @@ -138,7 +138,9 @@ async function initializeOpamUnix() {
await installUnixSystemPackages();
}
const disableSandboxing = [];
if (OPAM_DISABLE_SANDBOXING) {
// [NOTE] fix opam to run in act containers which have no "/dev/pts" for
// bubblewrap:
if (OPAM_DISABLE_SANDBOXING || github.context.actor === "nektos/act") {
disableSandboxing.push("--disable-sandboxing");
}
await exec("opam", [
Expand Down

0 comments on commit 7b1f269

Please sign in to comment.