-
Notifications
You must be signed in to change notification settings - Fork 33
206 lines (185 loc) · 7.68 KB
/
build-test-lin-wsl.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
on:
workflow_call:
inputs:
runner:
type: string
description: 'runner where this job will run'
required: true
flav:
type: string
description: 'flavour of the build: Windows/linux_x64/linux_arm64'
required: true
buildConf:
type: string
description: 'build configuration e.g. Release/Debug etc.'
default: 'RelWithDebInfo'
required: false
is-selfhosted:
type: boolean
description: 'self hosted runners do not need to use cache'
required: true
skip-test:
type: boolean
description: 'should test steps be skipped'
default: false
required: false
cuda:
type: string
description: 'ON/OFF based on this runner support cuda'
required: true
prep-cmd:
type: string
description: 'commands required to be run on a builder to prep it for build'
default: 'sudo apt-get update -qq && sudo apt-get -y install ca-certificates curl zip unzip tar autoconf automake autopoint build-essential flex git-core libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libsoup-gnome2.4-dev libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libncurses5-dev libncursesw5-dev ninja-build pkg-config texinfo wget yasm zlib1g-dev nasm gperf bison python3 python3-pip dos2unix libx11-dev libgles2-mesa-dev && pip3 install meson'
required: false
prep-check-cmd:
type: string
description: 'command to check if the builder is ready'
default: 'cmake --version ; ninja --version ; gcc --version ; git --version; pwsh --version ||true '
#pwsh is required on self hosted runners: see here: https://learn.microsoft.com/en-us/powershell/scripting/install/install-other-linux?view=powershell-7.2#installation-using-a-binary-archive-file
required: false
bootstrap-cmd:
type: string
description: 'commands required to boot strap builder after code checkout'
default: './vcpkg/bootstrap-vcpkg.sh'
required: false
is-prep-phase:
type: boolean
description: 'this workflow is called for a prep phase: it will split vcpkg install into 2 portions to cache and save'
default: false
required: false
cache-path:
type: string
description: 'the folder which needs to be cached e.g. .cache/vcpkg'
default: ${{ '~/.cache/vcpkg/archives' }}
required: false
cmake-conf-cmd:
type: string
description: 'command needed for installing and configuring cmake'
default: 'PATH=/usr/local/cuda/bin:$PATH ; cmake -B . -DENABLE_WINDOWS=OFF -DENABLE_LINUX=ON ../base'
required: false
nProc:
type: number
description: 'number of threads to be used by cmake/make'
default: 6
required: false
nTestTimeoutMins:
type: number
description: 'number of mins of timeout for tests run'
default: 20
required: false
jobs:
build:
env:
TEST_EXE: build/aprapipesut
CMAKE_TC_FILE: '../vcpkg/scripts/buildsystems/vcpkg.cmake' # Note: naming this variable as CMAKE_TOOLCHAIN_FILE can cause havoc!!!
runs-on: ${{ inputs.runner }}
steps:
- name: Prepare WSL Image
uses: Vampire/setup-wsl@v1
with:
distribution: Ubuntu-20.04
- name: Prepare builder
run: |
${{ inputs.prep-cmd }}
apt purge cmake || true
pip3 install cmake --upgrade || echo 'did not update cmake'
${{ inputs.prep-check-cmd }}
shell: wsl-bash {0}
- name: Check builder for CUDA
if: ${{ contains(inputs.cuda,'ON')}}
run: |
(PATH=/usr/local/cuda/bin:$PATH && nvcc --version) || echo 'please install cuda and add /usr/local/cuda/bin into path'
test -f /usr/local/cuda/include/cudnn.h || echo 'install cudnn as described in the readme.md'
shell: wsl-bash {0}
- name: Cleanup workspace on self hosted runners
if: inputs.is-selfhosted
run: 'Remove-Item -Recurse -Force *'
shell: pwsh
continue-on-error: true
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: 'recursive'
lfs: true
fetch-depth: 0
- name: List Submodules
run: |
git config --global --add safe.directory "*"
git submodule status > submodule_ver.txt
cat submodule_ver.txt
git rev-list --all --count
- name: Run VCPKG bootstrap
run: ${{ inputs.bootstrap-cmd }}
shell: wsl-bash {0}
- name: Remove CUDA from vcpkg if we are in nocuda
if: ${{ contains(inputs.cuda,'OFF')}}
working-directory: ${{github.workspace}}/base
run: .\fix-vcpkg-json.ps1 -removeCUDA
shell: pwsh
- name: Remove OpenCV from vcpkg during prep phase
if: inputs.is-prep-phase
working-directory: ${{github.workspace}}/base
run: .\fix-vcpkg-json.ps1 -removeOpenCV
shell: pwsh
# - name: cache init on container build
# if: ${{ job.container != null }} # we are running on a cloud hosted container... move the cache "initially"
# run: |
# cp -R /root/.cache /github/home/ || true
# ls ${{ inputs.cache-path }} || true
# continue-on-error: true
- name: Cache dependencies for fast cloud build
id: cache-all
uses: actions/cache@v3
with:
path: |
${{ inputs.cache-path }}
key: ${{ inputs.flav }}-4-${{ hashFiles( 'base/vcpkg.json', 'vcpkg/baseline.json', 'submodule_ver.txt') }}
restore-keys: ${{ inputs.flav }}-
- name: On WSL prep the thirdparty build scripts
working-directory: ${{github.workspace}}/thirdparty
run: |
shell: wsl-bash {0}
- name: Make build folder
run: mkdir -p build
continue-on-error: true
- name: Configure CMake Common
working-directory: ${{github.workspace}}/build
run: '${{ inputs.cmake-conf-cmd }} -DCMAKE_TOOLCHAIN_FILE=${{env.CMAKE_TC_FILE}} -DCMAKE_BUILD_TYPE=${{inputs.buildConf}} -DENABLE_CUDA=${{inputs.cuda}}'
continue-on-error: ${{inputs.is-prep-phase}} # in prep phase we expect an error here due to missing OpenCV
shell: wsl-bash {0}
- name: Build
if: ${{!inputs.is-prep-phase}}
working-directory: ${{github.workspace}}/build
run: cmake --build . --config ${{inputs.buildConf}} -j ${{ inputs.nProc }}
shell: wsl-bash {0}
- name: List Test cases
if: ${{!inputs.is-prep-phase}}
run: |
ldd ${{env.TEST_EXE}} | tee >(grep 'not found') || true
${{env.TEST_EXE}} --list_content > tests.txt || true
timeout-minutes: 1
shell: wsl-bash {0}
- name: Run Tests
if: ${{!inputs.is-prep-phase && !inputs.skip-test}}
run: |
${{env.TEST_EXE}} --log_format=JUNIT --log_sink=CI_test_result_${{inputs.flav}}.xml -p -l all || echo 'test execution returned error'
timeout-minutes: ${{ inputs.nTestTimeoutMins}}
shell: wsl-bash {0}
- name: Upload Test Results
if: ${{ always() }}
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: TestResults_${{ inputs.flav }}
path: |
CI_test_result_${{inputs.flav}}.xml
${{ github.workspace }}/data/SaveOrCompareFail/**
- name: Upload build logs
if: ${{ failure() }} # only upload logs when we have a failure above
uses: actions/upload-artifact@v3
with:
name: BuildLogs_${{ inputs.flav }}
path: |
${{ github.workspace }}/vcpkg/buildtrees/**/*.log
${{ github.workspace }}/vcpkg/buildtrees/**/*.txt