Skip to content

Commit b4aea9f

Browse files
kinkethewilsonator
authored andcommitted
GHA: Add Windows jobs to main workflow
1 parent d03a4d4 commit b4aea9f

File tree

2 files changed

+56
-9
lines changed

2 files changed

+56
-9
lines changed

.github/workflows/main.yml

+43-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
jobs:
13-
posix:
13+
main:
1414
strategy:
1515
fail-fast: false
1616
matrix:
@@ -61,12 +61,20 @@ jobs:
6161
# de-facto bootstrap version on OSX
6262
# See: https://github.com/dlang/dmd/pull/13890
6363
host_dmd: dmd-2.099.1
64+
# Windows
65+
- job_name: Windows x64, LDC
66+
os: windows-2022
67+
host_dmd: ldc-latest
68+
- job_name: Windows x86, LDC
69+
os: windows-2022
70+
host_dmd: ldc-latest
71+
model: 32
6472
name: ${{ matrix.job_name }}
6573
runs-on: ${{ matrix.os }}
6674
timeout-minutes: 40
6775
env:
6876
# for ci/run.sh:
69-
OS_NAME: ${{ startsWith(matrix.os, 'ubuntu') && 'linux' || (startsWith(matrix.os, 'macos') && 'osx' || '') }}
77+
OS_NAME: ${{ startsWith(matrix.os, 'ubuntu') && 'linux' || (startsWith(matrix.os, 'macos') && 'osx' || (startsWith(matrix.os, 'windows') && 'windows' || '')) }}
7078
MODEL: ${{ matrix.model || '64' }}
7179
HOST_DMD: ${{ matrix.host_dmd }}
7280
N: ${{ startsWith(matrix.os, 'macos') && '3' || '2' }}
@@ -75,14 +83,32 @@ jobs:
7583
DMD_TEST_COVERAGE: ${{ matrix.coverage && '1' || '0' }}
7684
# work around https://issues.dlang.org/show_bug.cgi?id=23517
7785
MACOSX_DEPLOYMENT_TARGET: '11'
86+
defaults:
87+
run:
88+
shell: bash
7889
steps:
7990
- uses: actions/checkout@v4
8091
with:
8192
fetch-depth: 50
82-
- name: Install prerequisites
93+
94+
- name: 'Posix: Install prerequisites'
95+
if: runner.os != 'Windows'
8396
run: ${{ runner.os == 'macOS' && 'ci/cirrusci.sh' || 'sudo -E ci/cirrusci.sh' }}
84-
- name: Install host compiler
97+
- name: 'Windows: Set up MSVC environment'
98+
if: runner.os == 'Windows'
99+
uses: seanmiddleditch/gha-setup-vsdevenv@v4
100+
with:
101+
arch: ${{ env.MODEL == '64' && 'x64' || 'x86' }}
102+
103+
- name: 'Posix: Install host compiler'
104+
if: runner.os != 'Windows'
85105
run: ci/run.sh install_host_compiler
106+
- name: 'Windows: Install host compiler'
107+
if: runner.os == 'Windows'
108+
uses: dlang-community/[email protected]
109+
with:
110+
compiler: ${{ matrix.host_dmd }}
111+
86112
- name: Set up repos
87113
run: |
88114
set -uexo pipefail
@@ -104,6 +130,12 @@ jobs:
104130
ci/run.sh setup_repos "$REPO_BRANCH"
105131
- name: Build
106132
run: ${{ matrix.disable_debug_for_dmd_unittests && 'ENABLE_DEBUG=0' || '' }} ci/run.sh build
133+
env:
134+
# on Windows, `ci/run.sh build` expects the DMD env var to be set to the DMD-CLI-compatible host compiler
135+
DMD: ${{ runner.os == 'Windows' && (startsWith(matrix.host_dmd, 'ldc') && 'ldmd2' || 'dmd') || '' }}
136+
# work around the LDC host compiler on Windows assuming the first link.exe in PATH is the MSVC one
137+
# (VSINSTALLDIR is set, but GHA uses Git's bin\bash.exe for `shell: bash`, which prepends Git's usr\bin to PATH, with GNU link.exe)
138+
LDC_VSDIR_FORCE: ${{ runner.os == 'Windows' && startsWith(matrix.host_dmd, 'ldc') && '1' || '' }}
107139
- name: Rebuild dmd (with enabled coverage)
108140
if: matrix.coverage
109141
run: ENABLE_RELEASE=0 ENABLE_DEBUG=1 ENABLE_COVERAGE=1 ci/run.sh rebuild
@@ -112,6 +144,13 @@ jobs:
112144
- name: Test druntime
113145
if: '!matrix.coverage'
114146
run: ci/run.sh test_druntime
147+
- name: 'Windows x86: Add 32-bit libcurl.dll to PATH (required for Phobos unittests)'
148+
if: runner.os == 'Windows' && env.MODEL == '32' && !matrix.coverage
149+
run: |
150+
# LDC
151+
echo "$(dirname "$(which $DC)")/../lib32" >> $GITHUB_PATH
152+
# DMD
153+
echo "$(dirname "$(which $DC)")/../bin" >> $GITHUB_PATH
115154
- name: Test phobos
116155
if: '!matrix.coverage'
117156
run: ci/run.sh test_phobos

ci/run.sh

+13-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -uexo pipefail
77

88
# N: number of parallel build jobs
99
if [ -z ${N+x} ] ; then echo "Variable 'N' needs to be set."; exit 1; fi
10-
# OS_NAME: linux|osx|freebsd
10+
# OS_NAME: linux|osx|freebsd|windows
1111
if [ -z ${OS_NAME+x} ] ; then echo "Variable 'OS_NAME' needs to be set."; exit 1; fi
1212
# FULL_BUILD: true|false (true on Linux: use full permutations for DMD tests)
1313
if [ -z ${FULL_BUILD+x} ] ; then echo "Variable 'FULL_BUILD' needs to be set."; exit 1; fi
@@ -58,13 +58,17 @@ clone() {
5858

5959
# build dmd (incl. building and running the unittests), druntime, phobos
6060
build() {
61-
source ~/dlang/*/activate # activate host compiler, incl. setting `DMD`
61+
if [ "$OS_NAME" != "windows" ]; then
62+
source ~/dlang/*/activate # activate host compiler, incl. setting `DMD`
63+
fi
6264
$DMD compiler/src/build.d -ofgenerated/build
6365
generated/build -j$N MODEL=$MODEL HOST_DMD=$DMD DFLAGS="$CI_DFLAGS" BUILD=debug unittest
6466
generated/build -j$N MODEL=$MODEL HOST_DMD=$DMD DFLAGS="$CI_DFLAGS" ENABLE_RELEASE=1 dmd
6567
make -j$N -C druntime MODEL=$MODEL
6668
make -j$N -C ../phobos MODEL=$MODEL
67-
deactivate # deactivate host compiler
69+
if [ "$OS_NAME" != "windows" ]; then
70+
deactivate # deactivate host compiler
71+
fi
6872
}
6973

7074
# self-compile dmd
@@ -124,7 +128,9 @@ test_phobos() {
124128

125129
# test dub package
126130
test_dub_package() {
127-
source ~/dlang/*/activate # activate host compiler
131+
if [ "$OS_NAME" != "windows" ]; then
132+
source ~/dlang/*/activate # activate host compiler
133+
fi
128134
# GDC's standard library is too old for some example scripts
129135
if [[ "${DMD:-dmd}" =~ "gdmd" ]] ; then
130136
echo "Skipping DUB examples on GDC."
@@ -146,7 +152,9 @@ test_dub_package() {
146152
# Test rdmd build
147153
"${build_path}/dmd" -version=NoBackend -version=GC -version=NoMain -Jgenerated/dub -Jsrc/dmd/res -Isrc -i -run test/dub_package/frontend.d
148154
fi
149-
deactivate
155+
if [ "$OS_NAME" != "windows" ]; then
156+
deactivate
157+
fi
150158
}
151159

152160
# clone phobos repos if not already available

0 commit comments

Comments
 (0)