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 <[email protected]>
Signed-off-by: Bernhard Kaindl <[email protected]>
Co-authored-by: Bernhard Kaindl <[email protected]>
  • Loading branch information
smorimoto and bernhardkaindl committed Dec 7, 2023
1 parent 08947a2 commit 5d0366b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 46 deletions.
46 changes: 18 additions & 28 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).

## [2.1.8]

### Fixed
Expand Down Expand Up @@ -557,34 +561,20 @@ that require it.
[2.0.2]: https://github.com/ocaml/setup-ocaml/compare/v2.0.1...v2.0.2
[2.0.1]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta13...v2.0.0
[2.0.0-beta13]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta12...v2.0.0-beta13
[2.0.0-beta12]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta11...v2.0.0-beta12
[2.0.0-beta11]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta10...v2.0.0-beta11
[2.0.0-beta10]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta9...v2.0.0-beta10
[2.0.0-beta9]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta8...v2.0.0-beta9
[2.0.0-beta8]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta7...v2.0.0-beta8
[2.0.0-beta7]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta6...v2.0.0-beta7
[2.0.0-beta6]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta5...v2.0.0-beta6
[2.0.0-beta5]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta4...v2.0.0-beta5
[2.0.0-beta4]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta3...v2.0.0-beta4
[2.0.0-beta3]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta2...v2.0.0-beta3
[2.0.0-beta2]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta...v2.0.0-beta2
[2.0.0-beta]:
https://github.com/ocaml/setup-ocaml/compare/v2.0.0-alpha...v2.0.0-beta
[2.0.0-alpha]:
https://github.com/ocaml/setup-ocaml/compare/v1.1.11...v2.0.0-alpha
[2.0.0-beta13]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta12...v2.0.0-beta13
[2.0.0-beta12]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta11...v2.0.0-beta12
[2.0.0-beta11]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta10...v2.0.0-beta11
[2.0.0-beta10]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta9...v2.0.0-beta10
[2.0.0-beta9]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta8...v2.0.0-beta9
[2.0.0-beta8]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta7...v2.0.0-beta8
[2.0.0-beta7]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta6...v2.0.0-beta7
[2.0.0-beta6]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta5...v2.0.0-beta6
[2.0.0-beta5]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta4...v2.0.0-beta5
[2.0.0-beta4]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta3...v2.0.0-beta4
[2.0.0-beta3]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta2...v2.0.0-beta3
[2.0.0-beta2]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-beta...v2.0.0-beta2
[2.0.0-beta]: https://github.com/ocaml/setup-ocaml/compare/v2.0.0-alpha...v2.0.0-beta
[2.0.0-alpha]: https://github.com/ocaml/setup-ocaml/compare/v1.1.11...v2.0.0-alpha
[1.1.11]: https://github.com/ocaml/setup-ocaml/compare/v1.1.10...v1.1.11
[1.1.10]: https://github.com/ocaml/setup-ocaml/compare/v1.1.9...v1.1.10
[1.1.9]: https://github.com/ocaml/setup-ocaml/compare/v1.1.8...v1.1.9
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 5d0366b

Please sign in to comment.