Improve diagnostics for non-default bash on Windows

This commit is contained in:
Taiki Endo
2024-06-12 00:58:48 +09:00
parent 43f5aa7172
commit 01c63d291f
2 changed files with 17 additions and 39 deletions

View File

@@ -53,6 +53,9 @@ jobs:
- os: macos-14
- os: windows-2019
- os: windows-2022
# https://github.com/taiki-e/install-action/pull/518#issuecomment-2160736760
- os: windows-2022
bash: msys64
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
@@ -62,6 +65,11 @@ jobs:
- name: Generate tool list
id: tool-list
run: tools/ci/tool-list.sh "${{ matrix.tool }}" >>"${GITHUB_OUTPUT}"
- run: |
set -eEuxo pipefail
echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
echo "C:\msys64\usr\bin" >> $GITHUB_PATH
if: matrix.bash == 'msys64'
- uses: ./
with:
tool: ${{ steps.tool-list.outputs.tool }}
@@ -93,43 +101,6 @@ jobs:
exit 1
fi
# https://github.com/taiki-e/install-action/pull/518#issuecomment-2160736760
test-msys64:
strategy:
fail-fast: false
matrix:
include:
# - os: windows-2019
- os: windows-2022
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- uses: taiki-e/checkout-action@v1
- run: |
echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
echo "C:\msys64\usr\bin" >> $GITHUB_PATH
# cross attempts to install rust-src when Cargo.toml is available even if `cross --version`
- run: rm Cargo.toml
- name: Generate tool list
id: tool-list
run: tools/ci/tool-list.sh >>"${GITHUB_OUTPUT}"
- uses: ./
with:
tool: ${{ steps.tool-list.outputs.tool }}
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
- name: Test bash
run: just --version && shfmt --version && protoc --version
shell: bash
- name: Test pwsh
run: just --version; shfmt --version; protoc --version
shell: pwsh
- name: Test powershell
run: just --version; shfmt --version; protoc --version
shell: powershell
- name: Test cmd
run: just --version & shfmt --version & protoc --version
shell: cmd
test-container:
strategy:
fail-fast: false

11
main.sh
View File

@@ -517,8 +517,15 @@ info "host platform: ${host_arch}_${host_os}"
home="${HOME}"
if [[ "${host_os}" == "windows" ]]; then
# https://github.com/taiki-e/install-action/pull/518#issuecomment-2160736760
home="${home/\/home\//\/c\/Users\/}"
if [[ "${home}" == "/home/"* ]]; then
if [[ -d "${home/\/home\//\/c\/Users\/}" ]]; then
# MSYS2 https://github.com/taiki-e/install-action/pull/518#issuecomment-2160736760
home="${home/\/home\//\/c\/Users\/}"
else
# TODO: Cygwin https://github.com/taiki-e/install-action/issues/224#issuecomment-1720196288
warn "\$HOME starting /home/ (${home}) on Windows bash is usually fake path, this may cause installation issue"
fi
fi
fi
install_action_dir="${home}/.install-action"
tmp_dir="${install_action_dir}/tmp"