GHA: Add Windows jobs to main workflow

This commit is contained in:
Martin Kinkelin 2023-12-22 02:39:56 +01:00 committed by Nicholas Wilson
parent d03a4d43af
commit b4aea9f670
2 changed files with 56 additions and 9 deletions

View file

@ -10,7 +10,7 @@ concurrency:
cancel-in-progress: true
jobs:
posix:
main:
strategy:
fail-fast: false
matrix:
@ -61,12 +61,20 @@ jobs:
# de-facto bootstrap version on OSX
# See: https://github.com/dlang/dmd/pull/13890
host_dmd: dmd-2.099.1
# Windows
- job_name: Windows x64, LDC
os: windows-2022
host_dmd: ldc-latest
- job_name: Windows x86, LDC
os: windows-2022
host_dmd: ldc-latest
model: 32
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 40
env:
# for ci/run.sh:
OS_NAME: ${{ startsWith(matrix.os, 'ubuntu') && 'linux' || (startsWith(matrix.os, 'macos') && 'osx' || '') }}
OS_NAME: ${{ startsWith(matrix.os, 'ubuntu') && 'linux' || (startsWith(matrix.os, 'macos') && 'osx' || (startsWith(matrix.os, 'windows') && 'windows' || '')) }}
MODEL: ${{ matrix.model || '64' }}
HOST_DMD: ${{ matrix.host_dmd }}
N: ${{ startsWith(matrix.os, 'macos') && '3' || '2' }}
@ -75,14 +83,32 @@ jobs:
DMD_TEST_COVERAGE: ${{ matrix.coverage && '1' || '0' }}
# work around https://issues.dlang.org/show_bug.cgi?id=23517
MACOSX_DEPLOYMENT_TARGET: '11'
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 50
- name: Install prerequisites
- name: 'Posix: Install prerequisites'
if: runner.os != 'Windows'
run: ${{ runner.os == 'macOS' && 'ci/cirrusci.sh' || 'sudo -E ci/cirrusci.sh' }}
- name: Install host compiler
- name: 'Windows: Set up MSVC environment'
if: runner.os == 'Windows'
uses: seanmiddleditch/gha-setup-vsdevenv@v4
with:
arch: ${{ env.MODEL == '64' && 'x64' || 'x86' }}
- name: 'Posix: Install host compiler'
if: runner.os != 'Windows'
run: ci/run.sh install_host_compiler
- name: 'Windows: Install host compiler'
if: runner.os == 'Windows'
uses: dlang-community/setup-dlang@v1.3.0
with:
compiler: ${{ matrix.host_dmd }}
- name: Set up repos
run: |
set -uexo pipefail
@ -104,6 +130,12 @@ jobs:
ci/run.sh setup_repos "$REPO_BRANCH"
- name: Build
run: ${{ matrix.disable_debug_for_dmd_unittests && 'ENABLE_DEBUG=0' || '' }} ci/run.sh build
env:
# on Windows, `ci/run.sh build` expects the DMD env var to be set to the DMD-CLI-compatible host compiler
DMD: ${{ runner.os == 'Windows' && (startsWith(matrix.host_dmd, 'ldc') && 'ldmd2' || 'dmd') || '' }}
# work around the LDC host compiler on Windows assuming the first link.exe in PATH is the MSVC one
# (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)
LDC_VSDIR_FORCE: ${{ runner.os == 'Windows' && startsWith(matrix.host_dmd, 'ldc') && '1' || '' }}
- name: Rebuild dmd (with enabled coverage)
if: matrix.coverage
run: ENABLE_RELEASE=0 ENABLE_DEBUG=1 ENABLE_COVERAGE=1 ci/run.sh rebuild
@ -112,6 +144,13 @@ jobs:
- name: Test druntime
if: '!matrix.coverage'
run: ci/run.sh test_druntime
- name: 'Windows x86: Add 32-bit libcurl.dll to PATH (required for Phobos unittests)'
if: runner.os == 'Windows' && env.MODEL == '32' && !matrix.coverage
run: |
# LDC
echo "$(dirname "$(which $DC)")/../lib32" >> $GITHUB_PATH
# DMD
echo "$(dirname "$(which $DC)")/../bin" >> $GITHUB_PATH
- name: Test phobos
if: '!matrix.coverage'
run: ci/run.sh test_phobos

View file

@ -7,7 +7,7 @@ set -uexo pipefail
# N: number of parallel build jobs
if [ -z ${N+x} ] ; then echo "Variable 'N' needs to be set."; exit 1; fi
# OS_NAME: linux|osx|freebsd
# OS_NAME: linux|osx|freebsd|windows
if [ -z ${OS_NAME+x} ] ; then echo "Variable 'OS_NAME' needs to be set."; exit 1; fi
# FULL_BUILD: true|false (true on Linux: use full permutations for DMD tests)
if [ -z ${FULL_BUILD+x} ] ; then echo "Variable 'FULL_BUILD' needs to be set."; exit 1; fi
@ -58,13 +58,17 @@ clone() {
# build dmd (incl. building and running the unittests), druntime, phobos
build() {
if [ "$OS_NAME" != "windows" ]; then
source ~/dlang/*/activate # activate host compiler, incl. setting `DMD`
fi
$DMD compiler/src/build.d -ofgenerated/build
generated/build -j$N MODEL=$MODEL HOST_DMD=$DMD DFLAGS="$CI_DFLAGS" BUILD=debug unittest
generated/build -j$N MODEL=$MODEL HOST_DMD=$DMD DFLAGS="$CI_DFLAGS" ENABLE_RELEASE=1 dmd
make -j$N -C druntime MODEL=$MODEL
make -j$N -C ../phobos MODEL=$MODEL
if [ "$OS_NAME" != "windows" ]; then
deactivate # deactivate host compiler
fi
}
# self-compile dmd
@ -124,7 +128,9 @@ test_phobos() {
# test dub package
test_dub_package() {
if [ "$OS_NAME" != "windows" ]; then
source ~/dlang/*/activate # activate host compiler
fi
# GDC's standard library is too old for some example scripts
if [[ "${DMD:-dmd}" =~ "gdmd" ]] ; then
echo "Skipping DUB examples on GDC."
@ -146,7 +152,9 @@ test_dub_package() {
# Test rdmd build
"${build_path}/dmd" -version=NoBackend -version=GC -version=NoMain -Jgenerated/dub -Jsrc/dmd/res -Isrc -i -run test/dub_package/frontend.d
fi
if [ "$OS_NAME" != "windows" ]; then
deactivate
fi
}
# clone phobos repos if not already available