From 930d8dd7f930eae275bfe50fc00b0b8b8cc6a4d0 Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Wed, 9 Oct 2024 20:01:31 +0200 Subject: [PATCH] Add msys2 option --- .github/workflows/checkin.yml | 2 +- .../workflows/{ => disabled}/cache-minimal.yml | 0 .github/workflows/{ => disabled}/test-cache.yml | 4 ---- .github/workflows/selftest.yml | 17 ++++++++++++----- README.md | 6 +++--- action.yml | 4 ++++ lib/main.js | 13 +++++++++++++ src/main.ts | 13 +++++++++++++ 8 files changed, 46 insertions(+), 13 deletions(-) rename .github/workflows/{ => disabled}/cache-minimal.yml (100%) rename .github/workflows/{ => disabled}/test-cache.yml (93%) diff --git a/.github/workflows/checkin.yml b/.github/workflows/checkin.yml index 2febfde2..c897d9a1 100644 --- a/.github/workflows/checkin.yml +++ b/.github/workflows/checkin.yml @@ -5,7 +5,7 @@ jobs: check_pr: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: "npm ci" run: npm ci diff --git a/.github/workflows/cache-minimal.yml b/.github/workflows/disabled/cache-minimal.yml similarity index 100% rename from .github/workflows/cache-minimal.yml rename to .github/workflows/disabled/cache-minimal.yml diff --git a/.github/workflows/test-cache.yml b/.github/workflows/disabled/test-cache.yml similarity index 93% rename from .github/workflows/test-cache.yml rename to .github/workflows/disabled/test-cache.yml index 86fcf296..95c4f764 100644 --- a/.github/workflows/test-cache.yml +++ b/.github/workflows/disabled/test-cache.yml @@ -1,7 +1,3 @@ -# Changes to the v2 branch must be proposed via PRs in the branch -# v3-next. This way we can check the action just as GHA is going to -# use it. - name: Test cache on: diff --git a/.github/workflows/selftest.yml b/.github/workflows/selftest.yml index fbce260b..7f214f31 100644 --- a/.github/workflows/selftest.yml +++ b/.github/workflows/selftest.yml @@ -1,7 +1,3 @@ -# Changes to the v2 branch must be proposed via PRs in the branch -# v2-next. This way we can check the action just as GHA is going to -# use it. - name: Selftest on: @@ -14,8 +10,11 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-12, macos-14, windows-latest] + os: [ubuntu-latest, macos-12, macos-14, windows-latest] target: [stable, nightly, source] + msys2: [true, false] + # A bit redundant for non-windows platforms, but let's keep things + # simple for the very rare times this workflow is run runs-on: ${{ matrix.os }} @@ -28,6 +27,7 @@ jobs: uses: ./ # This uses the action code in the current PR if: matrix.target == 'stable' with: + msys2: ${{ matrix.msys2 }} cache: false # We test without cache, as caching is tested in a separate workflow. # This way we make sure the cache isn't hiding any issue. @@ -36,6 +36,7 @@ jobs: uses: ./ if: matrix.target == 'nightly' with: + msys2: ${{ matrix.msys2 }} version: nightly cache: false @@ -43,6 +44,7 @@ jobs: uses: ./ if: matrix.target == 'source' with: + msys2: ${{ matrix.msys2 }} branch: master cache: false @@ -59,3 +61,8 @@ jobs: - run: alr -n version | grep "os:" | grep WINDOWS if: matrix.os == 'windows-latest' shell: bash + + # Verify proper msys2 behavior + - run: alr -n version && false # FAILING UNTIL WE ASCERTAIN THE PROPER OUTPUT + if: matrix.os == 'windows-latest' && matrix.msys2 == 'true' + shell: bash diff --git a/README.md b/README.md index cf2d540b..f4d0c456 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,10 @@ inputs: description: Arguments to pass to `alr toolchain` after setup. required: false default: 'gnat_native gprbuild' - toolchain_dir: - description: Location to install the toolchain under. + msys2: + description: Whether to install MSYS2 on Windows. When false, `msys2.do_not_install` will be set to true in alire's settings. required: false - default: '' + default: true cache: description: Whether to reuse a cached previous install. required: false diff --git a/action.yml b/action.yml index 2dae233d..eea42767 100644 --- a/action.yml +++ b/action.yml @@ -16,6 +16,10 @@ inputs: description: Arguments to pass to `alr toolchain` after setup. required: false default: 'gnat_native gprbuild' + msys2: + description: Whether to install MSYS2 on Windows. When false, `msys2.do_not_install` will be set to true in alire's settings. + required: false + default: true cache: description: Whether to reuse a cached previous install. required: false diff --git a/lib/main.js b/lib/main.js index 8054dcf2..e4f1cf67 100644 --- a/lib/main.js +++ b/lib/main.js @@ -127,17 +127,20 @@ function run() { try { var version; var branch; + var msys2; var tool_args; if (process.argv[2]) { // e.g., node lib/script.js const inputs = JSON.parse(process.argv[2]); version = inputs.version; branch = inputs.branch; + msys2 = inputs.msys2; tool_args = inputs.toolchain; } else { // Old way in case this is fixed by GH version = core.getInput('version'); branch = core.getInput('branch'); + msys2 = core.getInput('msys2') == "true"; tool_args = core.getInput('toolchain'); } // Install the requested version/branch unless cached @@ -159,6 +162,16 @@ function run() { yield exec.exec(`alr -n settings --global --set index.auto_update_asked true`); console.log("Enabled index auto-refresh without further asking."); } + // Disable msys2 installation if requested + if (process.platform == "win32") { + if (msys2) { + console.log("MSYS2 installation NOT disabled."); + } + else { + yield exec.exec(`alr -n settings --global --set msys2.do_not_install true`); + console.log("MSYS2 installation DISABLED."); + } + } // And configure the toolchain if (tool_args.length > 0 && !cached) { yield exec.exec(`alr -n toolchain ${tool_args != "--disable-assistant" ? "--select " : ""} ${tool_args}`); diff --git a/src/main.ts b/src/main.ts index 5f9d75bc..46017a78 100644 --- a/src/main.ts +++ b/src/main.ts @@ -103,17 +103,20 @@ async function run() { try { var version : string var branch : string + var msys2 : boolean var tool_args : string if (process.argv[2]) { // e.g., node lib/script.js const inputs = JSON.parse(process.argv[2]) version = inputs.version branch = inputs.branch + msys2 = inputs.msys2 tool_args = inputs.toolchain } else { // Old way in case this is fixed by GH version = core.getInput('version'); branch = core.getInput('branch'); + msys2 = core.getInput('msys2') == "true"; tool_args = core.getInput('toolchain'); } @@ -140,6 +143,16 @@ async function run() { console.log("Enabled index auto-refresh without further asking."); } + // Disable msys2 installation if requested + if (process.platform == "win32") { + if (msys2) { + console.log("MSYS2 installation NOT disabled."); + } else { + await exec.exec(`alr -n settings --global --set msys2.do_not_install true`); + console.log("MSYS2 installation DISABLED."); + } + } + // And configure the toolchain if (tool_args.length > 0 && !cached) { await exec.exec(`alr -n toolchain ${tool_args != "--disable-assistant" ? "--select " : ""} ${tool_args}`);