Skip to content

Commit e90693e

Browse files
committed
setup-go-toolchain: own the Windows PATH for cgo
The toolchain action's contract should be "after this action, Go and cgo work in any shell on this runner." But on Windows we were still asking each caller to do if [ "$RUNNER_OS" = "Windows" ]; then export PATH=$(cygpath -u "$MSYS2_LOCATION"/ucrt64/bin):"$PATH" fi inline before invoking go test, plus thread MSYS2_LOCATION through as an env var sourced from the action's msys2-location output. That leaks msys2 implementation details into every workflow that runs cgo builds in shell: bash on Windows. Move the PATH addition into the action: a new "Add MSYS2 to PATH (Windows)" step writes the cygpath-converted UCRT64 bin dir to $GITHUB_PATH after the msys2 install. Callers using shell: bash on Windows now find gcc and the ICU libs without ceremony. Workflows using shell: 'msys2 {0}' (e.g. ci-bats-windows.yaml's build) are unaffected — that shell sets up its own environment. Drop the now-unused msys2-location output and the corresponding env-var threading from ci-go-tests.yaml.
1 parent a8b1190 commit e90693e

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

.github/actions/setup-go-toolchain/action.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
name: 'Set up Go toolchain'
2-
description: 'Set up Go and platform-specific dependencies (ICU4C) needed to build dolt. On macOS, sets CGO flags pointing at brew icu4c. On Windows, installs MSYS2 with icu/toolchain/pkg-config and exposes the install path via the msys2-location output. On Linux, just sets up Go.'
3-
4-
outputs:
5-
msys2-location:
6-
description: 'Path to the MSYS2 installation (Windows only).'
7-
value: ${{ steps.msys2.outputs.msys2-location }}
2+
description: 'Sets up Go and the platform-specific dependencies (ICU4C) needed to build dolt. After this action runs, Go and cgo work in `shell: bash` and `shell: msys2 {0}` on every runner OS — callers do not need to manage CGO flags or PATH themselves. macOS: sets CGO_CPPFLAGS/CGO_LDFLAGS pointing at brew icu4c. Windows: installs MSYS2 with icu/toolchain/pkg-config and prepends the UCRT64 bin dir to GITHUB_PATH so cgo can find gcc and the ICU libs.'
83

94
runs:
105
using: 'composite'
@@ -29,3 +24,9 @@ runs:
2924
path-type: inherit
3025
msystem: UCRT64
3126
pacboy: icu:p toolchain:p pkg-config:p
27+
- name: Add MSYS2 to PATH (Windows)
28+
if: runner.os == 'Windows'
29+
shell: bash
30+
run: |
31+
loc='${{ steps.msys2.outputs.msys2-location }}'
32+
echo "$(cygpath -u "$loc/ucrt64/bin")" >> "$GITHUB_PATH"

.github/workflows/ci-go-tests.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,10 @@ jobs:
5050
steps:
5151
- uses: actions/checkout@v6
5252
- uses: ./.github/actions/setup-go-toolchain
53-
id: toolchain
5453
- name: Run shard
5554
working-directory: ./go
5655
run: |
57-
if [ "$RUNNER_OS" = "Windows" ]; then
58-
export PATH=$(cygpath -u "$MSYS2_LOCATION"/ucrt64/bin):"$PATH"
59-
fi
6056
go run ./utils/cigotests run \
6157
--shard "${{ matrix.shard }}" \
6258
--os "${{ matrix.os }}" \
6359
--event "${{ github.event_name }}"
64-
env:
65-
MSYS2_LOCATION: ${{ steps.toolchain.outputs.msys2-location }}

0 commit comments

Comments
 (0)