-
Notifications
You must be signed in to change notification settings - Fork 29
474 lines (412 loc) · 19.2 KB
/
build.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
name: build
on:
push:
branches:
- master
pull_request:
branches:
- '**'
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
qt_version: "6.2.1" # only used by build-macos
ccache_basedir: ${{ github.workspace }}
ccache_dir: "${{ github.workspace }}/.ccache"
ccache_compilercheck: content
ccache_compress: 'true'
ccache_compresslevel: 9
ccache_maxsize: 200M
ccache_cmake: -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache
MKL_URL: "https://data.statmt.org/romang/marian-regression-tests/ci/mkl-2020.1-windows-static.zip" # Used on Windows only
VCPKG_DEFAULT_TRIPLET: "x64-windows-static" # Used on Windows only
VCPKG_BUILD_TYPE: "release" # Used on windows
jobs:
build-macos:
strategy:
matrix:
include:
- name: "macOS Monterey 12 avx"
os: macos-12
arch: "core-avx-i"
- name: "macOS Big Sur 11.0 avx"
os: macos-11.0
arch: "core-avx-i"
- name: "macOS Big Sur 11.0 x86-64"
os: macos-11.0
arch: "x86-64"
- name: "macOS Monterey 12 avx"
os: macos-12
arch: "core-avx-i"
- name: "macOS Monterey 12 x86-64"
os: macos-12
arch: "x86-64"
# avx2 build is not any faster, since the critical codepath (intgemm) already uses the most optimal codepath for the user's PC
# - name: "macOS Catalina 10.15 avx2"
# os: macos-10.15
# arch: "core-avx2"
# - name: "macOS Big Sur 11.0 avx2"
# os: macos-11.0
# arch: "core-avx2"
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Dependencies # This qt6 build and we suppose apple accelerate was installed, but we can use openblas as a fallback until this is merged.
run: |
brew update
brew install protobuf coreutils libarchive ccache
- name: Cache Qt
id: cache-qt
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/qt/"
key: qt-${{ matrix.os }}-${{ env.qt_version }}
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
cached: ${{ steps.cache-qt.outputs.cache-hit }}
version: ${{ env.qt_version }}
dir: "${{ github.workspace }}/qt/"
- name: Generate ccache_vars for ccache based on machine
shell: bash
id: ccache_vars
run: |-
echo "::set-output name=hash::$(echo ${{ env.ccache_compilercheck }})"
echo "::set-output name=timestamp::$(date '+%Y-%m-%dT%H.%M.%S')"
- name: Cache-op for build-cache through ccache
uses: actions/cache@v3
with:
path: ${{ env.ccache_dir }}
key: ccache-${{ matrix.os }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}-${{ steps.ccache_vars.outputs.timestamp }}
restore-keys: |-
ccache-${{ matrix.os }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}
ccache-${{ matrix.os }}-${{ steps.ccache_vars.outputs.hash }}
ccache-${{ matrix.os }}
- name: ccache environment setup
run: |-
echo "CCACHE_COMPILER_CHECK=${{ env.ccache_compilercheck }}" >> $GITHUB_ENV
echo "CCACHE_BASEDIR=${{ env.ccache_basedir }}" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=${{ env.ccache_compress }}" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=${{ env.ccache_compresslevel }}" >> $GITHUB_ENV
echo "CCACHE_DIR=${{ env.ccache_dir }}" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=${{ env.ccache_maxsize }}" >> $GITHUB_ENV
- name: ccache prolog
run: |-
ccache -s # Print current cache stats
ccache -z # Zero cache entry
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: |-
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_ARCH=${{ matrix.arch }} ${{ env.ccache_cmake }}
cmake $GITHUB_WORKSPACE -LAH
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE -j3 --target translateLocally-bin translateLocally.dmg
- name: ccache epilog
run: 'ccache -s # Print current cache stats'
- name: Output test # @TODO some more complicated test, perhaps a unit test
if: ${{matrix.arch == 'core-avx-i'}} #MacOS machines are avx so they can't run avx2 steps.
working-directory: ${{github.workspace}}/build
shell: bash
run: ./translateLocally --version
- name: Produce DMG and Sign # This overrides the previous dmg # We follow https://localazy.com/blog/how-to-automatically-sign-macos-apps-using-github-actions
working-directory: ${{github.workspace}}/build # it should be secure as those can't leak unless we accept a PR with a bad workflow.
shell: bash
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PST: ${{ secrets.NOTARIZE_PST }}
APPLE_DEVELOPER_ID: ${{ secrets.APPLE_DEVELOPER_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
security create-keychain -p 1234asdf my.new.keychain
security default-keychain -s my.new.keychain
security unlock-keychain -p 1234asdf my.new.keychain
security import certificate.p12 -k my.new.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k 1234asdf my.new.keychain
../dist/macdmg.sh ${{github.workspace}}/build
- name: Encode the arch in the .dmg file # as we build with march=native now, record our MARCH
working-directory: ${{github.workspace}}/build
shell: bash
run: |
mv translateLocally.dmg translateLocally.${{ matrix.os }}.${{ matrix.arch }}.dmg
ls *.dmg
- uses: actions/upload-artifact@v3
with:
name: translateLocally.latest.${{ matrix.os }}.${{ matrix.arch }}.dmg
path: ${{github.workspace}}/build/translateLocally.*.dmg
build-ubuntu:
strategy:
matrix:
include:
- name: "Ubuntu 22.04 avx"
os: ubuntu-22.04
arch: "core-avx-i"
qtdeps: "libxkbcommon-x11-dev libvulkan-dev libgl1-mesa-dev qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools qt6-translations-l10n libqt6svg6-dev"
- name: "Ubuntu 20.04 avx"
os: ubuntu-20.04
arch: "core-avx-i"
qtdeps: "qttools5-dev qtbase5-dev libqt5svg5-dev"
- name: "Ubuntu 20.04 x86-64"
os: ubuntu-20.04
arch: "x86-64"
qtdeps: "qttools5-dev qtbase5-dev libqt5svg5-dev"
# avx2 build is not any faster, since the critical codepath (intgemm) already uses the most optimal codepath for the user's PC
# - name: "Ubuntu 18.04 avx2"
# os: ubuntu-18.04
# arch: "core-avx2"
# - name: "Ubuntu 20.04 avx2"
# os: ubuntu-20.04
# arch: "core-avx2"
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libpcre++-dev libarchive-dev libpcre2-dev ccache libunwind-dev libgoogle-perftools-dev ${{ matrix.qtdeps }}
# https://software.intel.com/content/www/us/en/develop/articles/installing-intel-free-libs-and-python-apt-repo.html
- name: Install MKL
run: |
wget -qO- "https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB" | sudo apt-key add -
sudo sh -c "echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list"
sudo apt-get update -o Dir::Etc::sourcelist="/etc/apt/sources.list.d/intel-mkl.list"
sudo apt-get install -y --no-install-recommends intel-mkl-64bit-2020.0-088
- name: Generate ccache_vars for ccache based on machine
shell: bash
id: ccache_vars
run: |-
echo "::set-output name=hash::$(echo ${{ env.ccache_compilercheck }})"
echo "::set-output name=timestamp::$(date '+%Y-%m-%dT%H.%M.%S')"
- name: Cache-op for build-cache through ccache
uses: actions/cache@v3
with:
path: ${{ env.ccache_dir }}
key: ccache-${{ matrix.os }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}-${{ steps.ccache_vars.outputs.timestamp }}
restore-keys: |-
ccache-${{ matrix.os }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}
ccache-${{ matrix.os }}-${{ steps.ccache_vars.outputs.hash }}
ccache-${{ matrix.os }}
- name: ccache environment setup
run: |-
echo "CCACHE_COMPILER_CHECK=${{ env.ccache_compilercheck }}" >> $GITHUB_ENV
echo "CCACHE_BASEDIR=${{ env.ccache_basedir }}" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=${{ env.ccache_compress }}" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=${{ env.ccache_compresslevel }}" >> $GITHUB_ENV
echo "CCACHE_DIR=${{ env.ccache_dir }}" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=${{ env.ccache_maxsize }}" >> $GITHUB_ENV
- name: ccache prolog
run: |-
ccache -s # Print current cache stats
ccache -z # Zero cache entry
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_ARCH=${{ matrix.arch }} -DCMAKE_INSTALL_PREFIX=/usr ${{ env.ccache_cmake }}
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE -j2
- name: ccache epilog
run: 'ccache -s # Print current cache stats'
- name: Output test # @TODO some more complicated test, perhaps a unit test
working-directory: ${{github.workspace}}/build
shell: bash
run: ./translateLocally --version
- name: Package # Produce a .deb file using cpack
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cpack
ls deb/*.deb
dpkg -I deb/*.deb
- uses: actions/upload-artifact@v3
with:
name: translateLocally.latest.${{ matrix.os }}.${{ matrix.arch }}.deb
path: ${{github.workspace}}/build/deb/*.deb
build-arm:
strategy:
matrix:
include:
- name: "Ubuntu 22.04 ARM"
os: ubuntu-22.04
arch: "aarch64"
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Dependencies
run: sudo apt-get install -y libxkbcommon-x11-dev libpcre++-dev libvulkan-dev libgl1-mesa-dev qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools qt6-translations-l10n libqt6svg6-dev libarchive-dev libpcre2-dev
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE
- name: Fix Arm build
# Not sure what the path is here but it should be something like
run: $GITHUB_WORKSPACE/cmake/fix_ruy_build.sh $GITHUB_WORKSPACE ${{github.workspace}}/build
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . -j4
- name: Output test # @TODO some more complicated test, perhaps a unit test
working-directory: ${{github.workspace}}/build
shell: bash
run: ./translateLocally --version
- name: Package # Produce a .deb file using cpack
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cpack
ls deb/*.deb
dpkg -I deb/*.deb
- uses: actions/upload-artifact@v3
with:
name: translateLocally.latest.${{ matrix.os }}.${{ matrix.arch }}.deb
path: ${{github.workspace}}/build/deb/*.deb
build-windows:
strategy:
matrix:
include:
- name: "Windows 2019 avx"
os: windows-2019
arch: "core-avx-i"
- name: "Windows 2022 avx"
os: windows-2022
arch: "core-avx-i"
- name: "Windows 2019 x86-64"
os: windows-2019
arch: "x86-64"
# avx2 build is not any faster, since the critical codepath (intgemm) already uses the most optimal codepath for the user's PC
# - name: "Windows 2019 avx2"
# os: windows-2019
# arch: "core-avx2"
# - name: "Windows 2022 avx2"
# os: windows-2022
# arch: "core-avx2"
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Download MKL
run: |
# Wget retries downloading files and is faster than Invoke-WebRequest
C:\msys64\usr\bin\wget.exe -nv ${{ env.MKL_URL }} -O mkl.zip
Expand-Archive -Force mkl.zip ${{ github.workspace }}\mkl
# Set MKLROOT environment variable so that CMake can find MKL
echo "MKLROOT=${{ github.workspace }}\mkl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: powershell
- name: Cache vcpkg
uses: actions/cache@v3
env:
cache-name: cache-vcpkg
with:
path: C:\vcpkg\installed # cache only the latest installed packages
key: ${{ matrix.os }}-build-${{ env.cache-name }}
restore-keys: |-
${{ matrix.os }}-build-${{ env.cache-name }}
${{ matrix.os }}-build
- name: Disable debug vcpkg build
shell: powershell
working-directory: C:\vcpkg\triplets
run: |
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8' # Powershell murders me.
echo "set(VCPKG_BUILD_TYPE release)" | Tee-Object -FilePath x64-windows-static.cmake -Append
echo "set(VCPKG_BUILD_TYPE release)" | Tee-Object -FilePath x64-windows.cmake -Append
cat x64-windows-static.cmake
cat x64-windows.cmake
- name: Install dependencies with vcpkg
working-directory: C:\vcpkg
run: |
$Env:VCPKG_BUILD_TYPE = 'release'
$Env:VCPKG_DEFAULT_TRIPLET = 'x64-windows-static' # QT6 version, linguist tools not working yet: qtbase:x64-windows-static qttools:x64-windows-static qtsvg:x64-windows-static
.\vcpkg install protobuf:x64-windows-static pcre2:x64-windows-static zlib:x64-windows-static libarchive:x64-windows-static qt5-base:x64-windows-static qt5-tools:x64-windows-static qt5-svg:x64-windows-static
.\vcpkg upgrade --no-dry-run # In case there are new builds available after cache restoration
shell: powershell
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure
working-directory: ${{github.workspace}}/build #@TODO figure out how variables are accessed from power shell, as they seem to not be read.
run: cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_STATIC_LIBS=ON -DBUILD_ARCH=${{ matrix.arch }} -DVCPKG_TARGET_TRIPLET='x64-windows-static' -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
shell: powershell
- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build . --config Release -j3
shell: powershell
- name: Test and add architecture information to the build
working-directory: ${{github.workspace}}/build/Release
run: |
./translateLocally.exe --help
mv translateLocally.exe translateLocally.${{ matrix.os }}.${{ matrix.arch }}.exe
shell: powershell
- uses: actions/upload-artifact@v3
with:
name: translateLocally.latest.${{ matrix.os }}.${{ matrix.arch }}.exe
path: ${{github.workspace}}/build/Release/*.exe
# Try to upload a release using https://github.com/marvinpinto/actions/issues/177#issuecomment-917605585 as a model
release:
name: Release build
runs-on: ubuntu-latest
needs: [build-macos, build-ubuntu, build-windows]
if: github.ref == 'refs/heads/master'
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Update GitHub prerelease
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: latest
prerelease: true
title: "Latest Build"
files: |
/home/runner/work/translateLocally/translateLocally/*.dmg/*.dmg
/home/runner/work/translateLocally/translateLocally/*.deb/*.deb
/home/runner/work/translateLocally/translateLocally/*.exe/*.exe