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

Add msys2 option #81

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/checkin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/selftest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- nightly
- source
- stable
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 }}

Expand All @@ -31,6 +34,7 @@ jobs:
if: matrix.target == 'stable'
uses: ./ # This uses the action code in the current PR
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.
Expand All @@ -39,13 +43,15 @@ jobs:
if: matrix.target == 'nightly'
uses: ./
with:
msys2: ${{ matrix.msys2 }}
version: nightly
cache: false

- name: Setup from source (master)
if: matrix.target == 'source'
uses: ./
with:
msys2: ${{ matrix.msys2 }}
branch: master
cache: false

Expand Down Expand Up @@ -80,3 +86,13 @@ jobs:
- run: alr -n version | grep "arch:" | grep AARCH64
if: runner.arch == 'ARM64'
shell: bash

# Verify proper msys2 behavior

- run: alr -n version | grep "distribution:" | grep MSYS2
if: matrix.os == 'windows-latest' && matrix.msys2 == true
shell: bash

- run: alr -n version | grep "distribution:" | grep UNKNOWN
if: matrix.os == 'windows-latest' && matrix.msys2 == false
shell: bash
3 changes: 3 additions & 0 deletions .github/workflows/test-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
with:
version: ${{matrix.config.version}}
branch: ${{matrix.config.branch}}
msys2: false
# Not needed, speed up test. This is tested in selftest.yml

# Next attemp should hit cache given the previous run

Expand All @@ -55,6 +57,7 @@ jobs:
with:
version: ${{matrix.config.version}}
branch: ${{matrix.config.branch}}
msys2: false

- name: Diagnose cache use
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,7 +54,7 @@ runs:
id: cache-key
shell: bash
run: |
echo "key=alr[1][${{ steps.find-hash.outputs.version }}][${{ inputs.toolchain }}][${{ runner.os }}][${{ runner.arch }}][${{ steps.find-hash.outputs.hash }}]" >> $GITHUB_OUTPUT
echo "key=alr[1][${{steps.find-hash.outputs.version}}][${{inputs.toolchain}}][msys2=${{inputs.msys2}}][${{runner.os}}][${{runner.arch}}][${{steps.find-hash.outputs.hash}}]" >> $GITHUB_OUTPUT
# The first value in square brackets is to make the key unique for debugging

- name: Reuse cached installation
Expand Down Expand Up @@ -107,7 +111,8 @@ runs:
shell: bash
run: echo "need=true" >> $GITHUB_OUTPUT

# Download a stable alr capable of installing a toolchain
# Download a stable alr capable of installing a toolchain. Avoid to install
# a msys2 at this point which is not needed and confuses later tests.
- name: Install GNAT (I)
if: steps.need-GNAT.outputs.need == 'true'
shell: bash
Expand All @@ -124,6 +129,8 @@ runs:
unzip -o ${alr_filename} "bin/alr*" -d tmp_alr
rm ${alr_filename}
echo "$(pwd -W 2>/dev/null || pwd)/tmp_alr/bin" >> $GITHUB_PATH
tmp_alr/bin/alr settings --global --set msys2.do_not_install true || \
tmp_alr/bin/alr config --global --set msys2.do_not_install true

# Perform the actual `alr install` and remove the `alr` just used to avoid
# conflicts with the `alr` being built.
Expand Down
17 changes: 17 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,22 @@ function run() {
try {
var version;
var branch;
var msys2;
var tool_args;
if (process.argv[2]) { // e.g., node lib/script.js <json object>
const inputs = JSON.parse(process.argv[2]);
// Log the inputs for the record
console.log("Inputs: " + process.argv[2]);
version = inputs.version;
branch = inputs.branch;
msys2 = inputs.msys2 == "true";
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
Expand All @@ -168,6 +173,18 @@ 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) {
// Re-enable in case it was disabled during previous actions steps
yield exec.exec(`alr -n settings --global --set msys2.do_not_install false`);
console.log(`MSYS2 installation NOT disabled (msys2=${msys2})`);
}
else {
yield exec.exec(`alr -n settings --global --set msys2.do_not_install true`);
console.log(`MSYS2 installation DISABLED (msys2=${msys2})`);
}
}
// And configure the toolchain
if (tool_args.length > 0 && !cached) {
yield exec.exec(`alr -n toolchain ${tool_args != "--disable-assistant" ? "--select " : ""} ${tool_args}`);
Expand Down
23 changes: 23 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,24 @@ 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 <json object>
const inputs = JSON.parse(process.argv[2])

// Log the inputs for the record
console.log("Inputs: " + process.argv[2])

version = inputs.version
branch = inputs.branch
msys2 = inputs.msys2 == "true";
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');
}

Expand All @@ -142,6 +149,10 @@ async function run() {
// Add to path in any case
core.addPath(path.join(process.cwd(), install_dir, 'bin'));

// Identify the major version number to choose between config/settings
const major : number = parseInt(version.split(".")[0], 10);
const settings_cmd : string = (major >= 2 ? "settings" : "config");

// Disable index auto-refresh asking, that may cause trouble to users
// on first run, but only if the major version is >=2, which
// introduced the feature.
Expand All @@ -150,6 +161,18 @@ async function run() {
console.log("Enabled index auto-refresh without further asking.");
}

// Disable msys2 installation if requested
if (process.platform == "win32") {
if (msys2) {
// Re-enable in case it was disabled during previous actions steps
await exec.exec(`alr -n ${settings_cmd} --global --set msys2.do_not_install false`);
console.log(`MSYS2 installation NOT disabled (msys2=${msys2})`);
} else {
await exec.exec(`alr -n ${settings_cmd} --global --set msys2.do_not_install true`);
console.log(`MSYS2 installation DISABLED (msys2=${msys2})`);
}
}

// And configure the toolchain
if (tool_args.length > 0 && !cached) {
await exec.exec(`alr -n toolchain ${tool_args != "--disable-assistant" ? "--select " : ""} ${tool_args}`);
Expand Down
Loading