-
-
Notifications
You must be signed in to change notification settings - Fork 5
202 lines (185 loc) · 8.49 KB
/
e2e.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
# End-to-end test for C++ bindings
#
# This provide the final test in D's C++ compatibility,
# an end-to-end test using standard C++ library.
# Testing C++ interop is done in two stages: at the lower layer,
# compilers will test C++ features in isolation (or combination,
# as can be seen in `dmd/compiler/test/runnable_cxx/` for example.
# The second layer, this one, test C++ interop assuming the compiler
# generates the proper mangling / uses the right ABI.
name: E2E tests
# Only triggers on pushes to master & stable, as well as PR to master and stable
# Sometimes reverts appear in the upstream repository (e.g. when the revert button
# is clicked by a contributor with commit access), this should be tested as PR).
#
# Also note that Github actions does not retrigger on target branch changes,
# hence the check on push.
on:
pull_request:
branches:
- v*.*.x
paths-ignore:
- 'README.md'
push:
branches:
- v*.*.x
# Use this branch name in your fork to test changes
- github-actions
jobs:
main:
name: Run
strategy:
fail-fast: false
matrix:
os:
- { name: ubuntu-20.04, arch: x86_64-linux-gnu-ubuntu-20.04 }
dc:
- ldc-latest
target:
- { name: g++-9, compiler: g++, cxx-version: 9.4.0 }
# Using a specific version for reproductibility.
# Feel free to update when a new release has matured.
runs-on: ${{ matrix.os.name }}
steps:
########################################
# Setting up the host D compiler #
########################################
- name: Prepare compiler
uses: dlang-community/setup-dlang@v1
with:
compiler: ${{ matrix.dc }}
# Checkout this repository
- name: Checkout
uses: actions/checkout@v4
########################################
# Setting up the host C++ compiler #
########################################
- name: '[Posix] Load cached clang'
id: cache-clang
if: matrix.target.compiler == 'clang' && runner.os != 'Windows'
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/clang+llvm-${{ matrix.target.cxx-version }}-${{ matrix.os.arch }}/
key: ${{ matrix.target.cxx-version }}-${{ matrix.os.arch }}-2022-09-25-2121
- name: '[Posix] Setting up clang ${{ matrix.target.cxx-version }}'
if: matrix.target.compiler == 'clang' && runner.os != 'Windows' && steps.cache-clang.outputs.cache-hit != 'true'
run: |
if [ "${{ matrix.target.cxx-version }}" == "8.0.0" -o "${{ matrix.target.cxx-version }}" == "9.0.0" ]; then
wget --quiet --directory-prefix=${{ github.workspace }} https://releases.llvm.org/${{ matrix.target.cxx-version }}/clang+llvm-${{ matrix.target.cxx-version }}-${{ matrix.os.arch }}.tar.xz
else
wget --quiet --directory-prefix=${{ github.workspace }} https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.target.cxx-version }}/clang+llvm-${{ matrix.target.cxx-version }}-${{ matrix.os.arch }}.tar.xz
fi
tar -x -C ${{ github.workspace }} -f ${{ github.workspace }}/clang+llvm-${{ matrix.target.cxx-version }}-${{ matrix.os.arch }}.tar.xz
TMP_CC='${{ github.workspace }}/clang+llvm-${{ matrix.target.cxx-version }}-${{ matrix.os.arch }}/bin/clang'
# On OSX, the system header are installed via `xcode-select` and not distributed with clang
# Since some part of the testsuite rely on CC being only a binary (not a command),
# and config files where only introduced from 6.0.0, use a wrapper script.
if [ "${{ matrix.os.name }}" == "macOS-11" ]; then
# Note: heredoc shouldn't be indented
cat << 'EOF' > ${TMP_CC}-wrapper
#!/bin/bash
# Note: We need to use this because github.workspace is not stable
SCRIPT_FULL_PATH=$(dirname "$0")
${SCRIPT_FULL_PATH}/clang -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ $@
EOF
# Invoking clang with `clang++` will link the C++ standard library
# Make sure we got two separate wrapper for this
cat << 'EOF' > ${TMP_CC}++-wrapper
#!/bin/bash
SCRIPT_FULL_PATH=$(dirname "$0")
${SCRIPT_FULL_PATH}/clang++ -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ $@
EOF
chmod +x ${TMP_CC}-wrapper ${TMP_CC}++-wrapper
fi
- name: '[Posix] Setup environment variables'
if: matrix.target.compiler == 'clang' && runner.os != 'Windows'
run: |
TMP_CC='${{ github.workspace }}/clang+llvm-${{ matrix.target.cxx-version }}-${{ matrix.os.arch }}/bin/clang'
if [ "${{ matrix.os.name }}" == "macOS-11" ]; then
echo "CC=${TMP_CC}-wrapper" >> $GITHUB_ENV
echo "CXX=${TMP_CC}++-wrapper" >> $GITHUB_ENV
echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
else
echo "CC=${TMP_CC}" >> $GITHUB_ENV
echo "CXX=${TMP_CC}++" >> $GITHUB_ENV
fi
# On OSX and Linux, clang is installed by default and in the path,
# so make sure ${CC} works
- name: '[Posix] Verifying installed clang version'
if: matrix.target.compiler == 'clang' && runner.os != 'Windows'
run: |
set -e
if ${CXX} --version | grep -q 'version ${{ matrix.target.cxx-version }}'; then
${CXX} --version
else
echo "Expected version ${{ matrix.target.cxx-version }}, from '${CXX}', got:"
${CXX} --version
exit 1
fi
# G++ is only supported on Linux
- name: '[Linux] Setting up g++ ${{ matrix.target.cxx-version }}'
if: matrix.target.compiler == 'g++'
run: |
# Workaround bug in Github actions
wget https://cli-assets.heroku.com/apt/release.key
sudo apt-key add release.key
# Make sure we have the essentials
sudo apt-get update
sudo apt-get install ca-certificates
sudo apt-get install build-essential software-properties-common -y
# This ppa provides multiple versions of g++
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install -y ${{ matrix.target.name }} ${{ matrix.target.name }}-multilib
echo "CC=${{ matrix.target.name }}" >> $GITHUB_ENV
echo "CXX=${{ matrix.target.name }}" >> $GITHUB_ENV
# Make sure ${CC} works and we don't use the $PATH one
- name: '[Linux] Verifying installed g++ version'
if: matrix.target.compiler == 'g++'
run: |
set -e
if ${CXX} --version | grep -q '${{ matrix.target.name }} (Ubuntu '; then
${CXX} --version
else
echo "Expected version ${{ matrix.target.name }}, from '${CXX}', got:"
${CXX} --version
exit 1
fi
# Restore or install dmc (and DM make)
- name: '[Windows] Restore dmc from cache'
id: cache-dmc
if: runner.os == 'Windows'
uses: actions/cache@v3
with:
path: ${{ github.workspace }}\tools\
key: ${{ matrix.os.name }}-dmc857
- name: '[Windows] Install dmc'
if: runner.os == 'Windows' && steps.cache-dmc.outputs.cache-hit != 'true'
shell: powershell
run: |
$url = "http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm857c.zip"
$sha256hash = "F51CDFEB45EAF4FFBF7ABF0FE9B3D548B202B4528401005C2C3192B00BC32367"
Write-Host ('Downloading {0} ...' -f $url)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ProgressPreference = 'SilentlyContinue'
New-Item -ItemType directory -Path ${{ github.workspace }}\tools\
Invoke-WebRequest -Uri $url -OutFile '${{ github.workspace }}\tools\dmc.zip'
if ((Get-FileHash '${{ github.workspace }}\tools\dmc.zip' -Algorithm "SHA256").Hash -ne $sha256hash) {
exit 1
}
Expand-Archive '${{ github.workspace }}\tools\dmc.zip' -DestinationPath ${{ github.workspace }}\tools\
- name: '[Windows] Add VC toolset to PATH'
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: '[Windows] Set environment variables'
if: runner.os == 'Windows'
shell: bash
run: |
echo "VISUAL_STUDIO_LIB_NOT_DM=$(which lib.exe)" >> $GITHUB_ENV
echo "HOST_DMD=${{ env.DC }}" >> $GITHUB_ENV
echo "${{ github.workspace }}/tools/dm/bin/" >> $GITHUB_PATH
########################################
# Running the test suite #
########################################
- name: 'Run C++ test suite'
run: dub test