-
-
Notifications
You must be signed in to change notification settings - Fork 703
205 lines (180 loc) · 6.94 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# very similar to the DMD script: https://github.com/dlang/dmd/blob/master/.github/workflows/main.yml
name: Main
on:
- pull_request # without merge conflicts
- push # branch or tag
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
main:
strategy:
fail-fast: false
matrix:
include:
# Linux
- job_name: Ubuntu 22.04 x64
os: ubuntu-22.04
- job_name: Ubuntu 22.04 x86
os: ubuntu-22.04
model: 32
# macOS
- job_name: macOS 13 x64
os: macos-13
- job_name: macOS 12 x64
os: macos-12
# Windows
- job_name: Windows x64
os: windows-2022
- job_name: Windows x86
os: windows-2022
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' || (startsWith(matrix.os, 'windows') && 'windows' || '')) }}
MODEL: ${{ matrix.model || '64' }}
HOST_DMD: dmd
# N is set dynamically below
FULL_BUILD: false
# 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: Clone DMD
run: |
set -uexo pipefail
ref='${{ github.ref }}'
if [[ "$ref" =~ ^refs/pull/ ]]; then
# PR: clone the DMD head with the same name as this Phobos PR's target branch
# e.g., DMD stable when targeting Phobos stable
REPO_BRANCH="$GITHUB_BASE_REF"
elif [[ "$ref" =~ ^refs/(heads|tags)/(.*)$ ]]; then
# no PR: clone the DMD head with the same name as this Phobos head
# e.g., DMD stable for a push to Phobos stable, or DMD v2.105.2 for Phobos tag v2.105.2
REPO_BRANCH="${BASH_REMATCH[2]}"
else
echo "Error: unexpected GitHub ref '$ref'" >&2
exit 1
fi
git clone --branch "$REPO_BRANCH" --depth 1 https://github.com/dlang/dmd.git ../dmd
- name: Set environment variable N (parallelism)
run: echo "N=$(${{ runner.os == 'macOS' && 'sysctl -n hw.logicalcpu' || 'nproc' }})" >> $GITHUB_ENV
- name: 'Posix: Install prerequisites'
if: runner.os != 'Windows'
run: cd ../dmd && ${{ runner.os == 'macOS' && 'ci/cirrusci.sh' || 'sudo -E ci/cirrusci.sh' }}
- name: 'Windows: Set up MSVC environment'
if: runner.os == 'Windows'
uses: seanmiddleditch/gha-setup-vsdevenv@v4
with:
arch: ${{ env.MODEL == '64' && 'x64' || 'x86' }}
# NOTE: Linker ICEs with Xcode 15.0.1 (default version on macos-13)
# * https://issues.dlang.org/show_bug.cgi?id=24407
# Remove this step if the default gets changed to 15.1 in actions/runner-images.
- name: 'macOS 13: Switch to Xcode v15.1'
if: matrix.os == 'macos-13'
run: sudo xcode-select -switch /Applications/Xcode_15.1.app
- name: 'Posix: Install host compiler'
if: runner.os != 'Windows'
run: cd ../dmd && 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: ldc-latest
- name: Build
run: cd ../dmd && 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' && 'ldmd2' || '' }}
# 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' && '1' || '' }}
- name: Test dmd
run: cd ../dmd && ci/run.sh test_dmd
- name: Test druntime
run: cd ../dmd && 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'
run: echo "$(dirname "$(which $DC)")/../lib32" >> $GITHUB_PATH
- name: Test phobos
run: cd ../dmd && ci/run.sh test_phobos
freebsd-vm:
strategy:
fail-fast: false
matrix:
include:
- job_name: FreeBSD 13.2 x64
freebsd_version: '13.2'
name: ${{ matrix.job_name }}
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 50
- name: Run in VM
uses: cross-platform-actions/action@v0.23.0
with:
operating_system: freebsd
hypervisor: qemu
memory: 12G
cpu_count: 4
sync_files: runner-to-vm
version: ${{ matrix.freebsd_version }}
shell: bash
run: |
set -uexo pipefail
freebsd_version='${{ matrix.freebsd_version }}'
freebsd_major="${freebsd_version:0:2}"
export OS_NAME=freebsd
export MODEL=64
export HOST_DMD=dmd
export N="$(nproc)"
export FULL_BUILD=false
export CI_DFLAGS="-version=TARGET_FREEBSD${freebsd_major}"
#if [[ "$freebsd_major" == 12 ]]; then
# sudo sed -i '' -e 's|pkg.FreeBSD.org|mirrors.xtom.com/freebsd-pkg|' /etc/pkg/FreeBSD.conf
#fi
bash --version
echo '::group::Install git'
sudo pkg install -y git
echo '::endgroup::'
echo '::group::Clone DMD'
ref='${{ github.ref }}'
if [[ "$ref" =~ ^refs/pull/ ]]; then
REPO_BRANCH="$GITHUB_BASE_REF"
elif [[ "$ref" =~ ^refs/(heads|tags)/(.*)$ ]]; then
REPO_BRANCH="${BASH_REMATCH[2]}"
else
echo "Error: unexpected GitHub ref '$ref'" >&2
exit 1
fi
git clone --branch "$REPO_BRANCH" --depth 1 https://github.com/dlang/dmd.git ../dmd
echo '::endgroup::'
cd ../dmd
echo '::group::Install prerequisites'
sudo -E ci/cirrusci.sh
echo '::endgroup::'
echo '::group::Install host compiler'
ci/run.sh install_host_compiler
echo '::endgroup::'
echo '::group::Build'
ci/run.sh build
echo '::endgroup::'
echo '::group::Test dmd'
ci/run.sh test_dmd
echo '::endgroup::'
echo '::group::Test druntime'
ci/run.sh test_druntime
echo '::endgroup::'
echo '::group::Test phobos'
ci/run.sh test_phobos
echo '::endgroup::'