diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 7e5754e..21f06dc 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -199,7 +199,7 @@ jobs: rm -rf node_modules - name: run action uses: ./ - - run: msys2 go env + - run: msys2 -c "go env" env: MSYS2_PATH_TYPE: inherit @@ -219,7 +219,7 @@ jobs: uses: ./ with: path-type: inherit - - run: msys2 go env + - run: msys2 -c "go env" install: needs: [path-type] @@ -292,3 +292,41 @@ jobs: update: true install: base-devel git - run: git describe --dirty --tags + + errorhandling: + needs: [defaultdirty] + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: build action + shell: bash + run: | + npm ci + npm run pkg + rm -rf node_modules + - name: run action + uses: ./ + - shell: msys2 {0} + run: | + (! false | true) || exit 1; # make sure "-o pipefail" is active by default + [[ "$-" =~ 'e' ]] || exit 1; # make sure "set -e" is active by default + + workingdir: + needs: [errorhandling] + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: build action + shell: bash + run: | + npm ci + npm run pkg + rm -rf node_modules + - name: run action + uses: ./ + - shell: msys2 {0} + run: | + # make sure we are in checkout directory + dir="$(pwd)" + cd "$GITHUB_WORKSPACE" + [[ "$dir" == "$(pwd)" ]] diff --git a/README.md b/README.md index 5aa8fd4..fb6b0d6 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Then, for multi-line scripts: Or, for single line commands: ```yaml - - run: msys2 uname -a + - run: msys2 -c 'uname -a' ``` ### Default shell @@ -90,7 +90,7 @@ Furthermore, the environment variable can be overridden. This is useful when mul pacman --noconfirm -U mingw-w64-*-any.pkg.tar.xz - run: | set MSYSTEM=MINGW64 - msys2 + msys2 -c '' ``` #### path-type diff --git a/main.js b/main.js index 3a72128..6b98ce8 100644 --- a/main.js +++ b/main.js @@ -38,12 +38,12 @@ async function run() { const p_install = core.getInput('install'); const p_cache = core.getInput('cache'); - let drive = 'C:'; + let base = 'C:'; if (p_release) { // Use upstream package instead of the default installation in the virtual environment. core.startGroup('Downloading MSYS2...'); - drive = '%~dp0'; + base = '%~dp0'; let inst_dest = path.join(tmp_dir, 'base.exe'); await tc.downloadTool(inst_url, inst_dest); @@ -60,18 +60,11 @@ async function run() { } let wrap = [ - `setlocal`, `@echo off`, + `setlocal`, `IF NOT DEFINED MSYS2_PATH_TYPE set MSYS2_PATH_TYPE=` + p_pathtype, - `set "args=%*"`, - `set "args=%args:\\=/%"`, - /* TODO: - See https://www.msys2.org/wiki/Launchers/#the-idea - Ideally, there would be some better solution than 'cd $OLDPWD', such as using 'CHERE_INVOKING=1'. - However, since an intermediate file is used, it would probably make CHERE_INVOKING use the location of - 'msys2.cmd' or the temporal file created by GitHub's runner. - */ - drive + `\\msys64\\usr\\bin\\env.exe /usr/bin/bash --norc -ilceo pipefail "cd $OLDPWD && %args%"` + `set CHERE_INVOKING=1`, + base + `\\msys64\\usr\\bin\\bash.exe -leo pipefail %*` ].join('\r\n'); let cmd = path.join(dest, 'msys2.cmd'); @@ -89,7 +82,7 @@ async function run() { } async function run(args, opts) { - await exec.exec('cmd', ['/D', '/S', '/C', cmd].concat(args), opts); + await exec.exec('cmd', ['/D', '/S', '/C', cmd].concat(['-c', args.join(' ')]), opts); } async function pacman(args, opts) {