Skip to content

Commit a95503e

Browse files
authored
Introduce Github Actions CI (#510)
* Introduce Github Actions CI * env variable fix * Drop Travis and Appveyor, update readme * Fix blas installs and skip Windows 32-bit * change how windows deps are installed * setup datasets cache for MNIST * windows dep - yet another try * try again * update msys2 to have latest packages * can we get lapack at least? * give up on windows for now
1 parent 8514e78 commit a95503e

4 files changed

Lines changed: 296 additions & 146 deletions

File tree

.appveyor.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
name: Arraymancer CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
10+
jobs:
11+
build:
12+
strategy:
13+
fail-fast: false
14+
max-parallel: 20
15+
matrix:
16+
branch: [version-1-0, version-1-2, version-1-4] # [devel]
17+
target:
18+
- os: linux
19+
cpu: amd64
20+
# TODO: https://github.com/mratsim/Arraymancer/issues/511
21+
# - os: linux
22+
# cpu: i386
23+
- os: macos
24+
cpu: amd64
25+
# TODO: install openblas or lapack
26+
# - os: windows
27+
# cpu: amd64
28+
# - os: windows
29+
# cpu: i386
30+
test_lang: [c] # cpp not configured
31+
include:
32+
- target:
33+
os: linux
34+
builder: ubuntu-18.04
35+
shell: bash
36+
- target:
37+
os: macos
38+
builder: macos-10.15
39+
shell: bash
40+
# - target:
41+
# os: windows
42+
# builder: windows-2019
43+
# shell: msys2 {0}
44+
45+
defaults:
46+
run:
47+
shell: ${{ matrix.shell }}
48+
49+
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.test_lang }} (${{ matrix.branch }})'
50+
runs-on: ${{ matrix.builder }}
51+
steps:
52+
- name: Get branch name
53+
shell: bash
54+
run: |
55+
if [[ '${{ github.event_name }}' == 'pull_request' ]]; then
56+
echo "##[set-output name=branch_name;]$(echo ${GITHUB_HEAD_REF})"
57+
echo "Branch found (PR): ${GITHUB_HEAD_REF}"
58+
else
59+
echo "##[set-output name=branch_name;]$(echo ${GITHUB_REF#refs/heads/})"
60+
echo "Branch found (not PR): ${GITHUB_REF#refs/heads/}"
61+
fi
62+
id: get_branch
63+
64+
- name: Cancel Previous Runs (except master)
65+
if: >
66+
steps.get_branch.outputs.branch_name != 'master'
67+
uses: styfle/cancel-workflow-action@0.5.0
68+
with:
69+
access_token: ${{ github.token }}
70+
71+
- name: Checkout arraymancer
72+
uses: actions/checkout@v2
73+
with:
74+
path: arraymancer
75+
submodules: true
76+
77+
- name: Install build dependencies (Linux i386)
78+
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
79+
run: |
80+
sudo dpkg --add-architecture i386
81+
sudo apt-fast update -qq
82+
sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \
83+
--no-install-recommends -yq gcc-multilib g++-multilib \
84+
libssl-dev:i386
85+
mkdir -p external/bin
86+
cat << EOF > external/bin/gcc
87+
#!/bin/bash
88+
exec $(which gcc) -m32 "\$@"
89+
EOF
90+
cat << EOF > external/bin/g++
91+
#!/bin/bash
92+
exec $(which g++) -m32 "\$@"
93+
EOF
94+
chmod 755 external/bin/gcc external/bin/g++
95+
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
96+
97+
- name: MSYS2 (Windows i386)
98+
if: runner.os == 'Windows' && matrix.target.cpu == 'i386'
99+
uses: msys2/setup-msys2@v2
100+
with:
101+
path-type: inherit
102+
msystem: MINGW32
103+
# update: true
104+
install: >-
105+
base-devel
106+
git
107+
mingw-w64-i686-toolchain
108+
109+
- name: MSYS2 (Windows amd64)
110+
if: runner.os == 'Windows' && matrix.target.cpu == 'amd64'
111+
uses: msys2/setup-msys2@v2
112+
with:
113+
path-type: inherit
114+
# update: true
115+
install: >-
116+
base-devel
117+
git
118+
mingw-w64-x86_64-toolchain
119+
120+
- name: Restore Nim DLLs dependencies (Windows) from cache
121+
if: runner.os == 'Windows'
122+
id: windows-dlls-cache
123+
uses: actions/cache@v2
124+
with:
125+
path: external/dlls
126+
key: 'dlls'
127+
128+
- name: Install DLL dependencies (Windows)
129+
if: >
130+
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
131+
runner.os == 'Windows'
132+
run: |
133+
mkdir external
134+
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
135+
7z x external/windeps.zip -oexternal/dlls
136+
137+
- name: Path to cached dependencies (Windows)
138+
if: >
139+
runner.os == 'Windows'
140+
run: |
141+
echo '${{ github.workspace }}'"/external/dlls" >> $GITHUB_PATH
142+
143+
- name: Derive environment variables
144+
run: |
145+
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
146+
PLATFORM=x64
147+
else
148+
PLATFORM=x86
149+
fi
150+
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
151+
152+
if [[ '${{ matrix.target.os }}' == 'windows' ]]; then
153+
MAKE_CMD="mingw32-make"
154+
else
155+
MAKE_CMD="make"
156+
fi
157+
echo "MAKE_CMD=$MAKE_CMD" >> $GITHUB_ENV
158+
159+
ncpu=''
160+
case '${{ runner.os }}' in
161+
'Linux')
162+
ncpu=$(nproc)
163+
;;
164+
'macOS')
165+
ncpu=$(sysctl -n hw.ncpu)
166+
;;
167+
'Windows')
168+
ncpu=${NUMBER_OF_PROCESSORS}
169+
;;
170+
esac
171+
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
172+
echo "ncpu=${ncpu}" >> $GITHUB_ENV
173+
174+
- name: Setup environment
175+
shell: bash
176+
run: echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
177+
178+
- name: Get latest Nim commit hash
179+
id: versions
180+
shell: bash
181+
run: |
182+
getHash() {
183+
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
184+
}
185+
nimHash=$(getHash nim-lang/Nim '${{ matrix.branch }}')
186+
csourcesHash=$(getHash nim-lang/csources)
187+
echo "::set-output name=nim::$nimHash"
188+
echo "::set-output name=csources::$csourcesHash"
189+
190+
- name: Restore prebuilt Nim from cache
191+
id: nim-cache
192+
uses: actions/cache@v1
193+
with:
194+
path: nim
195+
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nim }}'
196+
197+
- name: Restore prebuilt csources from cache
198+
if: steps.nim-cache.outputs.cache-hit != 'true'
199+
id: csources-cache
200+
uses: actions/cache@v1
201+
with:
202+
path: csources/bin
203+
key: 'csources-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.csources }}'
204+
205+
- name: Checkout Nim csources
206+
if: >
207+
steps.csources-cache.outputs.cache-hit != 'true' &&
208+
steps.nim-cache.outputs.cache-hit != 'true'
209+
uses: actions/checkout@v2
210+
with:
211+
repository: nim-lang/csources
212+
path: csources
213+
ref: ${{ steps.versions.outputs.csources }}
214+
215+
- name: Checkout Nim
216+
if: steps.nim-cache.outputs.cache-hit != 'true'
217+
uses: actions/checkout@v2
218+
with:
219+
repository: nim-lang/Nim
220+
path: nim
221+
ref: ${{ steps.versions.outputs.nim }}
222+
223+
- name: Build Nim and associated tools
224+
if: steps.nim-cache.outputs.cache-hit != 'true'
225+
shell: bash
226+
run: |
227+
ncpu=
228+
ext=
229+
case '${{ runner.os }}' in
230+
'Linux')
231+
ncpu=$(nproc)
232+
;;
233+
'macOS')
234+
ncpu=$(sysctl -n hw.ncpu)
235+
;;
236+
'Windows')
237+
ncpu=$NUMBER_OF_PROCESSORS
238+
ext=.exe
239+
;;
240+
esac
241+
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
242+
if [[ ! -e csources/bin/nim$ext ]]; then
243+
make -C csources -j $ncpu CC=gcc ucpu='${{ matrix.target.cpu }}'
244+
else
245+
echo 'Using prebuilt csources'
246+
fi
247+
cp -v csources/bin/nim$ext nim/bin
248+
cd nim
249+
nim c koch
250+
./koch boot -d:release
251+
./koch tools -d:release
252+
# clean up to save cache space
253+
rm koch
254+
rm -rf nimcache
255+
rm -rf dist
256+
rm -rf .git
257+
258+
- name: Install dependencies (Linux 32-bit)
259+
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
260+
run: |
261+
sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \
262+
--no-install-recommends -yq \
263+
libopenblas-dev:i386
264+
265+
# Apple Accelerate installed by default
266+
# - name: Install dependencies (macOS)
267+
# if: runner.os == 'macOS'
268+
# run: brew install openblas
269+
270+
- name: Install dependencies (Windows)
271+
if: runner.os == 'Windows' && matrix.target.cpu == 'amd64'
272+
shell: msys2 {0}
273+
run: |
274+
pacman -S --needed --noconfirm mingw-w64-x86_64-​lapack
275+
276+
- name: Install dependencies (Windows)
277+
if: runner.os == 'Windows' && matrix.target.cpu == 'i386'
278+
shell: msys2 {0}
279+
run: |
280+
pacman -S --needed --noconfirm mingw-w64-i686-​lapack
281+
282+
- name: Restore datasets cache
283+
id: datasets-cache
284+
uses: actions/cache@v1
285+
with:
286+
path: ~/.cache/arraymancer
287+
key: 'datasets'
288+
289+
- name: Run Arraymancer tests
290+
working-directory: arraymancer
291+
run: |
292+
export ARRAYMANCER_TEST_LANG=${{ matrix.test_lang }}
293+
nimble install -y --depsOnly
294+
# Run the tests.
295+
nimble test

0 commit comments

Comments
 (0)