Skip to content

Commit 73edde4

Browse files
CI: test with multiple Nim versions (#99)
* CI: test with multiple Nim versions
1 parent 908632a commit 73edde4

File tree

2 files changed

+113
-161
lines changed

2 files changed

+113
-161
lines changed

.github/workflows/ci.yml

Lines changed: 105 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: CI
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
workflow_dispatch:
38

49
# we dont run compression extension
510
# in regular CI because it is a
@@ -13,71 +18,46 @@ jobs:
1318
fail-fast: false
1419
max-parallel: 20
1520
matrix:
16-
branch: [v1.2.6]
1721
target:
1822
# Unit tests
1923
- os: linux
2024
cpu: amd64
21-
TEST_KIND: unit-tests
2225
- os: linux
2326
cpu: i386
24-
TEST_KIND: unit-tests
2527
- os: macos
2628
cpu: amd64
27-
TEST_KIND: unit-tests
28-
- os: windows
29-
cpu: i386
30-
TEST_KIND: unit-tests
3129
- os: windows
3230
cpu: amd64
33-
TEST_KIND: unit-tests
31+
#- os: windows
32+
#cpu: i386
33+
branch: [version-1-2, version-1-4, version-1-6, devel]
3434
include:
3535
- target:
3636
os: linux
37-
builder: ubuntu-20.04
37+
builder: ubuntu-18.04
38+
shell: bash
3839
- target:
3940
os: macos
4041
builder: macos-10.15
42+
shell: bash
4143
- target:
4244
os: windows
4345
builder: windows-2019
44-
name: "${{ matrix.target.os }}-${{ matrix.target.cpu }} (${{ matrix.branch }})"
46+
shell: msys2 {0}
47+
48+
defaults:
49+
run:
50+
shell: ${{ matrix.shell }}
51+
52+
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
4553
runs-on: ${{ matrix.builder }}
54+
continue-on-error: ${{ matrix.branch == 'version-1-6' || matrix.branch == 'devel' }}
4655
steps:
47-
- name: Checkout nim-websock
56+
- name: Checkout
4857
uses: actions/checkout@v2
4958
with:
50-
path: nim-websock
5159
submodules: true
5260

53-
- name: Derive environment variables
54-
shell: bash
55-
run: |
56-
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
57-
ARCH=64
58-
PLATFORM=x64
59-
else
60-
ARCH=32
61-
PLATFORM=x86
62-
fi
63-
echo "ARCH=$ARCH" >> $GITHUB_ENV
64-
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
65-
66-
ncpu=
67-
case '${{ runner.os }}' in
68-
'Linux')
69-
ncpu=$(nproc)
70-
;;
71-
'macOS')
72-
ncpu=$(sysctl -n hw.ncpu)
73-
;;
74-
'Windows')
75-
ncpu=$NUMBER_OF_PROCESSORS
76-
;;
77-
esac
78-
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
79-
echo "ncpu=$ncpu" >> $GITHUB_ENV
80-
8161
- name: Install build dependencies (Linux i386)
8262
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
8363
run: |
@@ -98,78 +78,62 @@ jobs:
9878
chmod 755 external/bin/gcc external/bin/g++
9979
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
10080
101-
- name: Install build dependencies (Windows)
102-
if: runner.os == 'Windows'
103-
shell: bash
104-
run: |
105-
mkdir external
106-
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
107-
arch=64
108-
else
109-
arch=32
110-
fi
111-
curl -L "https://nim-lang.org/download/mingw$arch.7z" -o "external/mingw$arch.7z"
112-
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
113-
7z x "external/mingw$arch.7z" -oexternal/
114-
7z x external/windeps.zip -oexternal/dlls
115-
echo '${{ github.workspace }}'"/external/mingw$arch/bin" >> $GITHUB_PATH
116-
echo '${{ github.workspace }}'"/external/dlls" >> $GITHUB_PATH
117-
118-
- name: Setup environment
119-
shell: bash
120-
run: echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
121-
122-
- name: Get latest Nim commit hash
123-
id: versions
124-
shell: bash
125-
run: |
126-
getHash() {
127-
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
128-
}
129-
nimHash=$(getHash nim-lang/Nim '${{ matrix.branch }}')
130-
csourcesHash=$(getHash nim-lang/csources)
131-
echo "::set-output name=nim::$nimHash"
132-
echo "::set-output name=csources::$csourcesHash"
133-
134-
- name: Restore prebuilt Nim from cache
135-
id: nim-cache
136-
uses: actions/cache@v1
81+
- name: MSYS2 (Windows i386)
82+
if: runner.os == 'Windows' && matrix.target.cpu == 'i386'
83+
uses: msys2/setup-msys2@v2
13784
with:
138-
path: nim
139-
key: "nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nim }}"
85+
path-type: inherit
86+
msystem: MINGW32
87+
install: >-
88+
base-devel
89+
git
90+
mingw-w64-i686-toolchain
91+
92+
- name: MSYS2 (Windows amd64)
93+
if: runner.os == 'Windows' && matrix.target.cpu == 'amd64'
94+
uses: msys2/setup-msys2@v2
95+
with:
96+
path-type: inherit
97+
install: >-
98+
base-devel
99+
git
100+
mingw-w64-x86_64-toolchain
140101
141-
- name: Restore prebuilt csources from cache
142-
if: steps.nim-cache.outputs.cache-hit != 'true'
143-
id: csources-cache
144-
uses: actions/cache@v1
102+
- name: Restore Nim DLLs dependencies (Windows) from cache
103+
if: runner.os == 'Windows'
104+
id: windows-dlls-cache
105+
uses: actions/cache@v2
145106
with:
146-
path: csources/bin
147-
key: "csources-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.csources }}"
107+
path: external/dlls-${{ matrix.target.cpu }}
108+
key: 'dlls-${{ matrix.target.cpu }}'
148109

149-
- name: Checkout Nim csources
110+
- name: Install DLLs dependencies (Windows)
150111
if: >
151-
steps.csources-cache.outputs.cache-hit != 'true' &&
152-
steps.nim-cache.outputs.cache-hit != 'true'
153-
uses: actions/checkout@v2
154-
with:
155-
repository: nim-lang/csources
156-
path: csources
157-
ref: ${{ steps.versions.outputs.csources }}
112+
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
113+
runner.os == 'Windows'
114+
run: |
115+
DLLPATH=external/dlls-${{ matrix.target.cpu }}
116+
mkdir -p external
117+
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
118+
7z x -y external/windeps.zip -o"$DLLPATH"
158119
159-
- name: Checkout Nim
160-
if: steps.nim-cache.outputs.cache-hit != 'true'
161-
uses: actions/checkout@v2
162-
with:
163-
repository: nim-lang/Nim
164-
path: nim
165-
ref: ${{ steps.versions.outputs.nim }}
120+
- name: Path to cached dependencies (Windows)
121+
if: >
122+
runner.os == 'Windows'
123+
run: |
124+
echo '${{ github.workspace }}'"/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
166125
167-
- name: Build Nim and associated tools
168-
if: steps.nim-cache.outputs.cache-hit != 'true'
169-
shell: bash
126+
- name: Derive environment variables
170127
run: |
128+
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
129+
PLATFORM=x64
130+
else
131+
PLATFORM=x86
132+
fi
133+
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
134+
171135
ncpu=
172-
ext=
136+
MAKE_CMD="make"
173137
case '${{ runner.os }}' in
174138
'Linux')
175139
ncpu=$(nproc)
@@ -179,31 +143,29 @@ jobs:
179143
;;
180144
'Windows')
181145
ncpu=$NUMBER_OF_PROCESSORS
182-
ext=.exe
146+
MAKE_CMD="mingw32-make"
183147
;;
184148
esac
185149
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
186-
if [[ ! -e csources/bin/nim$ext ]]; then
187-
make -C csources -j $ncpu CC=gcc ucpu='${{ matrix.target.cpu }}'
188-
else
189-
echo 'Using prebuilt csources'
190-
fi
191-
cp -v csources/bin/nim$ext nim/bin
192-
cd nim
193-
nim c koch
194-
./koch boot -d:release
195-
./koch tools -d:release
196-
# clean up to save cache space
197-
rm koch
198-
rm -rf nimcache
199-
rm -rf dist
200-
rm -rf .git
201-
202-
- name: Run nim-websock tests
203-
shell: bash
150+
echo "ncpu=$ncpu" >> $GITHUB_ENV
151+
echo "MAKE_CMD=${MAKE_CMD}" >> $GITHUB_ENV
152+
153+
- name: Build Nim and Nimble
154+
run: |
155+
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
156+
env MAKE="${MAKE_CMD} -j${ncpu}" ARCH_OVERRIDE=${PLATFORM} NIM_COMMIT=${{ matrix.branch }} \
157+
QUICK_AND_DIRTY_COMPILER=1 QUICK_AND_DIRTY_NIMBLE=1 CC=gcc \
158+
bash build_nim.sh nim csources dist/nimble NimBinaries
159+
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
160+
161+
- name: Run tests
204162
run: |
205-
export UCPU="$cpu"
206-
cd nim-websock
163+
if [[ "${{ matrix.target.os }}" == "windows" ]]; then
164+
# https://github.com/status-im/nimbus-eth2/issues/3121
165+
export NIMFLAGS="-d:nimRawSetjmp"
166+
fi
167+
nim --version
168+
nimble --version
207169
nimble install -y --depsOnly
208170
nimble test
209171
@@ -217,36 +179,24 @@ jobs:
217179
max-parallel: 20
218180
matrix:
219181
websock: [ws, wsc, wss, wssc]
182+
branch: [version-1-2, version-1-4, version-1-6, devel]
183+
184+
defaults:
185+
run:
186+
shell: bash
220187

221188
steps:
222-
- name: Checkout nim-websock
189+
- name: Checkout
223190
uses: actions/checkout@v2
224191
with:
225-
path: nim-websock
226192
submodules: true
227193

228-
- name: Get latest nimbus-build-system commit hash
229-
id: versions
230-
shell: bash
231-
run: |
232-
getHash() {
233-
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
234-
}
235-
nbsHash=$(getHash status-im/nimbus-build-system)
236-
echo "::set-output name=nimbus_build_system::$nbsHash"
237-
238-
- name: Restore prebuilt Nim from cache
239-
id: nim-cache
240-
uses: actions/cache@v2
241-
with:
242-
path: NimBinaries
243-
key: 'NimBinaries-${{ steps.versions.outputs.nimbus_build_system }}'
244-
245-
- name: Build Nim and associated tools
246-
shell: bash
194+
- name: Build Nim and Nimble
247195
run: |
248196
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
249-
env MAKE="make -j2" ARCH_OVERRIDE=x64 CC=gcc bash build_nim.sh nim csources dist/nimble NimBinaries
197+
env MAKE="make -j$(nproc)" NIM_COMMIT=${{ matrix.branch }} \
198+
QUICK_AND_DIRTY_COMPILER=1 QUICK_AND_DIRTY_NIMBLE=1 CC=gcc \
199+
bash build_nim.sh nim csources dist/nimble NimBinaries
250200
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
251201
252202
- name: Setup Python version
@@ -262,13 +212,11 @@ jobs:
262212
virtualenv --python=/usr/bin/python2 autobahn
263213
source autobahn/bin/activate
264214
pip install autobahntestsuite
265-
cd nim-websock
266215
nimble install -y --depsOnly
267216
268217
- name: Generate index.html
269218
if: matrix.websock == 'ws'
270219
run: |
271-
cd nim-websock
272220
mkdir autobahn/reports
273221
sed -i "s/COMMIT_SHA_SHORT/${GITHUB_SHA::7}/g" autobahn/index.md
274222
sed -i "s/COMMIT_SHA/$GITHUB_SHA/g" autobahn/index.md
@@ -279,7 +227,6 @@ jobs:
279227
source autobahn/bin/activate
280228
case '${{ matrix.websock }}' in
281229
ws)
282-
cd nim-websock
283230
nim c -d:release examples/server.nim
284231
examples/server &
285232
server=$!
@@ -288,7 +235,6 @@ jobs:
288235
wstest --mode fuzzingclient --spec fuzzingclient.json
289236
;;
290237
wsc)
291-
cd nim-websock
292238
nim c -d:tls -d:release -o:examples/tls_server examples/server.nim
293239
examples/tls_server &
294240
server=$!
@@ -297,7 +243,7 @@ jobs:
297243
wstest --mode fuzzingclient --spec fuzzingclient_tls.json
298244
;;
299245
wss)
300-
cd nim-websock/autobahn
246+
cd autobahn
301247
wstest --webport=0 --mode fuzzingserver --spec fuzzingserver.json &
302248
server=$!
303249
@@ -306,7 +252,7 @@ jobs:
306252
examples/autobahn_client
307253
;;
308254
wssc)
309-
cd nim-websock/autobahn
255+
cd autobahn
310256
wstest --webport=0 --mode fuzzingserver --spec fuzzingserver_tls.json &
311257
server=$!
312258
@@ -322,15 +268,19 @@ jobs:
322268
uses: actions/upload-artifact@v2
323269
with:
324270
name: autobahn-report
325-
path: ./nim-websock/autobahn/reports
271+
path: ./autobahn/reports
326272

327273
deploy-test:
328274
if: github.event_name == 'push'
329275
name: "Deplay Autobahn results"
330276
needs: autobahn-test
331277
runs-on: ubuntu-latest
332-
steps:
333278

279+
defaults:
280+
run:
281+
shell: bash
282+
283+
steps:
334284
- name: Download Autobahn reports
335285
uses: actions/download-artifact@v2
336286
with:

0 commit comments

Comments
 (0)