Fix compatibility issue with Cygwin sh

```
D:\a\_temp\00683b68-582f-4719-bd7a-9e98dd7975b7.sh: line 1: set: -
: invalid option
set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
```
This commit is contained in:
Taiki Endo
2024-09-28 16:20:03 +09:00
parent 4a3cc43080
commit 942f3ad679
3 changed files with 42 additions and 15 deletions

View File

@@ -63,24 +63,30 @@ jobs:
bash: msys64 bash: msys64
- os: windows-2022 - os: windows-2022
bash: cygwin bash: cygwin
- os: windows-2022
tool: major.minor.patch
- os: windows-2022
tool: major.minor
- os: windows-2022
tool: major
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
timeout-minutes: 60 timeout-minutes: 60
steps: steps:
- run: | - run: |
printf 'C:\msys64\mingw32\bin\n' >>"${GITHUB_PATH}" printf '%s\n' 'C:\msys64\mingw32\bin' >>"${GITHUB_PATH}"
printf 'C:\msys64\usr\bin\n' >>"${GITHUB_PATH}" printf '%s\n' 'C:\msys64\usr\bin' >>"${GITHUB_PATH}"
if: matrix.bash == 'msys64' if: matrix.bash == 'msys64'
- run: | - run: |
choco install --no-progress --requirechecksums cygwin choco install --no-progress --requirechecksums cygwin
printf 'C:\tools\cygwin\bin\n' >>"${GITHUB_PATH}" printf '%s\n' 'C:\tools\cygwin\bin' >>"${GITHUB_PATH}"
printf 'C:\tools\cygwin\usr\bin\n' >>"${GITHUB_PATH}" printf '%s\n' 'C:\tools\cygwin\usr\bin' >>"${GITHUB_PATH}"
if: matrix.bash == 'cygwin' if: matrix.bash == 'cygwin'
- uses: taiki-e/checkout-action@v1 - uses: taiki-e/checkout-action@v1
# cross attempts to install rust-src when Cargo.toml is available even if `cross --version` # cross attempts to install rust-src when Cargo.toml is available even if `cross --version`
- run: rm Cargo.toml - run: rm Cargo.toml
- name: Generate tool list - name: Generate tool list
id: tool-list id: tool-list
run: tools/ci/tool-list.sh "${{ matrix.tool }}" >>"${GITHUB_OUTPUT}" run: tools/ci/tool-list.sh "${{ matrix.tool }}" "${{ matrix.os }}" "${{ matrix.bash }}" >>"${GITHUB_OUTPUT}"
- run: env - run: env
- uses: ./ - uses: ./
with: with:

View File

@@ -46,3 +46,11 @@ runs:
INPUT_TOOL: ${{ inputs.tool }} INPUT_TOOL: ${{ inputs.tool }}
INPUT_CHECKSUM: ${{ inputs.checksum }} INPUT_CHECKSUM: ${{ inputs.checksum }}
INPUT_FALLBACK: ${{ inputs.fallback }} INPUT_FALLBACK: ${{ inputs.fallback }}
if: runner.os != 'Windows'
- run: bash --noprofile --norc "${GITHUB_ACTION_PATH:?}/main.sh"
shell: bash
env:
INPUT_TOOL: ${{ inputs.tool }}
INPUT_CHECKSUM: ${{ inputs.checksum }}
INPUT_FALLBACK: ${{ inputs.fallback }}
if: runner.os == 'Windows'

View File

@@ -40,6 +40,9 @@ glibc_pre_2_17_incompat=(
musl_incompat=( musl_incompat=(
"${glibc_pre_2_17_incompat[@]}" "${glibc_pre_2_17_incompat[@]}"
) )
win2019_gnu_incompat=(
cargo-spellcheck
)
incompat_tools=() incompat_tools=()
case "${1:-}" in case "${1:-}" in
@@ -51,9 +54,11 @@ case "${1:-}" in
;; ;;
*) *)
echo "tool=$1" echo "tool=$1"
exit 0 exit 1
;; ;;
esac esac
runner="${2:-}"
bash="${3:-}"
case "$(uname -s)" in case "$(uname -s)" in
Linux) Linux)
host_os=linux host_os=linux
@@ -92,7 +97,16 @@ case "$(uname -s)" in
fi fi
;; ;;
Darwin) host_os=macos ;; Darwin) host_os=macos ;;
MINGW* | MSYS* | CYGWIN* | Windows_NT) host_os=windows ;; MINGW* | MSYS* | CYGWIN* | Windows_NT)
host_os=windows
case "${bash}" in
msys64 | cygwin)
if [[ "${runner}" == "windows-2019" ]]; then
incompat_tools+=("${win2019_gnu_incompat[@]}")
fi
;;
esac
;;
*) bail "unrecognized OS type '$(uname -s)'" ;; *) bail "unrecognized OS type '$(uname -s)'" ;;
esac esac
@@ -104,20 +118,19 @@ for manifest in tools/codegen/base/*.json; do
continue continue
fi fi
case "${host_os}" in case "${host_os}" in
linux*) linux*) ;;
for incompat in ${incompat_tools[@]+"${incompat_tools[@]}"}; do
if [[ "${incompat}" == "${tool_name}" ]]; then
tool_name=''
break
fi
done
;;
*) *)
if [[ "$(jq -r ".platform.x86_64_${host_os}" "${manifest}")" == "null" ]]; then if [[ "$(jq -r ".platform.x86_64_${host_os}" "${manifest}")" == "null" ]]; then
continue continue
fi fi
;; ;;
esac esac
for incompat in ${incompat_tools[@]+"${incompat_tools[@]}"}; do
if [[ "${incompat}" == "${tool_name}" ]]; then
tool_name=''
break
fi
done
if [[ -n "${tool_name}" ]]; then if [[ -n "${tool_name}" ]]; then
if [[ "${version}" != "latest" ]]; then if [[ "${version}" != "latest" ]]; then
latest_version=$(jq -r ".latest.version" "manifests/${tool_name}.json") latest_version=$(jq -r ".latest.version" "manifests/${tool_name}.json")