-
Notifications
You must be signed in to change notification settings - Fork 2
422 lines (375 loc) · 15.1 KB
/
ci.yml
File metadata and controls
422 lines (375 loc) · 15.1 KB
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
name: CI
on:
release:
types:
- published
pull_request:
push:
branches:
- "main"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-and-test-ghidra:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d # v1.6.0
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: "Setup Ghidra"
run: |
just install-ghidra
echo "GHIDRA_INSTALL_DIR=$(pwd)/deps/ghidra" >> $GITHUB_ENV
- name: "Lint IRENE Ghidra"
run: |
just lint-irene3-ghidra
- name: "IRENE Ghidra tests"
shell: bash
env:
TOB_AMP_PASSPHRASE: ${{secrets.TOB_AMP_PASSPHRASE}}
run: |
Xvfb :99 -nolisten tcp &
export DISPLAY=:99
just test-irene3-ghidra
- name: "Tar test logs"
if: ${{ failure() }}
run: |
tar -cvf test-report.tar.gz irene-ghidra/build/reports/tests/
- name: "Upload test logs"
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: Test Report
path: test-report.tar.gz
- name: "Build IRENE Ghidra"
run: |
just install-irene3-ghidra
- name: "Upload IRENE Ghidra"
if: github.event.release
uses: actions/upload-artifact@v3
with:
name: IRENE3 Ghidra Rel
path: ./irene-ghidra/dist/ghidra*irene-ghidra.zip
build-decompiler:
strategy:
fail-fast: false
matrix:
image:
- { name: "ubuntu", tag: "22.04" }
llvm: ["17"]
cxxcommon_version: ["0.6.10"]
runs-on:
labels: gha-ubuntu-32
container:
image: ghcr.io/lifting-bits/cxx-common/vcpkg-builder-${{ matrix.image.name }}:${{ matrix.image.tag }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup the build paths
shell: bash
id: build_paths
run: |
rel_build_path="build"
rel_source_path="src"
rel_install_path="install"
rel_downloads_path="downloads"
rel_ccache_path="ccache"
rel_workspace_path="workspace"
mkdir -p ${rel_build_path} \
${rel_install_path} \
${rel_downloads_path} \
${rel_ccache_path} \
${rel_workspace_path}
echo "SOURCE=$(pwd)/${rel_source_path}" >> ${GITHUB_OUTPUT}
echo "REL_SOURCE=${rel_source_path}" >> ${GITHUB_OUTPUT}
echo "BUILD=$(pwd)/${rel_build_path}" >> ${GITHUB_OUTPUT}
echo "REL_BUILD=${rel_build_path}" >> ${GITHUB_OUTPUT}
echo "INSTALL=$(pwd)/${rel_install_path}" >> ${GITHUB_OUTPUT}
echo "DOWNLOADS=$(pwd)/${rel_downloads_path}" >> ${GITHUB_OUTPUT}
echo "CCACHE=$(pwd)/${rel_ccache_path}" >> ${GITHUB_OUTPUT}
echo "WORKSPACE=$(pwd)/${rel_workspace_path}" >> ${GITHUB_OUTPUT}
- name: Update the cache (downloads)
uses: actions/cache@v3
with:
path: ${{ steps.build_paths.outputs.DOWNLOADS }}
key: |
gitmodules_${{ matrix.image.name }}_${{ matrix.image.tag }}_${{ matrix.llvm }}_${{ matrix.cxxcommon_version }}_${{ github.sha }}
restore-keys: |
gitmodules_${{ matrix.image.name }}_${{ matrix.image.tag }}_${{ matrix.llvm }}_${{ matrix.cxxcommon_version }}_
- name: Update the cache (ccache)
uses: actions/cache@v3
with:
path: ${{ steps.build_paths.outputs.CCACHE }}
key: |
gitmodules_${{ matrix.image.name }}_${{ matrix.image.tag }}_${{ matrix.llvm }}_${{ matrix.cxxcommon_version }}_${{ github.sha }}
restore-keys: |
gitmodules_${{ matrix.image.name }}_${{ matrix.image.tag }}_${{ matrix.llvm }}_${{ matrix.cxxcommon_version }}_
- name: Clone the irene3 repository
uses: actions/checkout@v4
with:
path: ${{ steps.build_paths.outputs.REL_SOURCE }}/irene3
fetch-depth: 0
submodules: true
- name: Setup Git User for Applying Patches
# See this thread for more details https://github.community/t/github-actions-bot-email-address/17204/5
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Download the cxx-common ${{ matrix.cxxcommon_version}} package
shell: bash
id: cxxcommon_installer
working-directory: ${{ steps.build_paths.outputs.DOWNLOADS }}
run: |
folder_name="vcpkg_${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm-${{ matrix.llvm }}-liftingbits-llvm_amd64"
archive_name="${folder_name}.tar.xz"
url="https://github.com/lifting-bits/cxx-common/releases/download/v${{ matrix.cxxcommon_version}}/${archive_name}"
local_path="${{ steps.build_paths.outputs.DOWNLOADS }}/${archive_name}"
if [[ ! -f "${local_path}" ]] ; then
echo "Downloading: ${url}"
curl "${url}" -L -o "${local_path}"
ls -t ${{ steps.build_paths.outputs.DOWNLOADS }}/vcpkg_* | tail -n +2 | while read archive_file ; do
rm "${archive_file}"
done
fi
tar xf "${local_path}" \
-C "${{ steps.build_paths.outputs.INSTALL }}"
destination_path="${{ steps.build_paths.outputs.INSTALL }}/vcpkg"
mv "${{ steps.build_paths.outputs.INSTALL }}/${folder_name}" \
"${destination_path}"
echo "${destination_path}/installed/x64-linux-rel/tools/llvm-${{matrix.llvm}}" >> $GITHUB_PATH
echo "PATH=${destination_path}" >> ${GITHUB_OUTPUT}
- name: Select the build job count
shell: bash
id: build_job_count
run: |
echo "VALUE=$(($(nproc) + 1))" >> ${GITHUB_OUTPUT}
- name: Configure remill
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
mkdir remill_build && cd remill_build
cmake \
-DCMAKE_VERBOSE_MAKEFILE=true \
-DCMAKE_TOOLCHAIN_FILE="${{ steps.cxxcommon_installer.outputs.PATH }}/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET="x64-linux-rel" \
-G Ninja \
"${{ steps.build_paths.outputs.SOURCE }}/irene3/vendor/remill"
- name: Build remill
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
cmake --build remill_build \
-j ${{ steps.build_job_count.outputs.VALUE }}
- name: Install remill
id: remill_installer
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
export DESTDIR=${{ steps.build_paths.outputs.INSTALL }}/remill
cmake --build remill_build \
--target install
echo "PATH=${DESTDIR}" >> ${GITHUB_OUTPUT}
- name: Configure anvill
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
mkdir anvill_build && cd anvill_build
cmake \
-DCMAKE_TOOLCHAIN_FILE="${{ steps.cxxcommon_installer.outputs.PATH }}/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET="x64-linux-rel" \
-DCMAKE_VERBOSE_MAKEFILE=true \
-Dremill_DIR:PATH=${{ steps.remill_installer.outputs.PATH }}/usr/local/lib/cmake/remill \
-Dsleigh_DIR:PATH=${{ steps.remill_installer.outputs.PATH }}/usr/local/lib/cmake/sleigh \
-DANVILL_ENABLE_TESTS=true \
-DANVILL_ENABLE_INSTALL=true \
-G Ninja \
"${{ steps.build_paths.outputs.SOURCE }}/irene3/vendor/anvill"
- name: Build anvill
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
cmake \
--build anvill_build \
-j ${{ steps.build_job_count.outputs.VALUE }}
- name: Install anvill
id: anvill_installer
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
export DESTDIR=${{ steps.build_paths.outputs.INSTALL }}/anvill
cmake --build anvill_build \
--target install
echo "PATH=${DESTDIR}" >> ${GITHUB_OUTPUT}
- name: Configure gap
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
mkdir gap_build && cd gap_build
cmake \
-DCMAKE_TOOLCHAIN_FILE="${{ steps.cxxcommon_installer.outputs.PATH }}/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET="x64-linux-rel" \
-DVCPKG_MANIFEST_INSTALL=OFF \
-DGAP_ENABLE_TESTING=OFF \
-DGAP_ENABLE_EXAMPLES=OFF \
-DGAP_ENABLE_WARNINGS=OFF \
-G Ninja \
"${{ steps.build_paths.outputs.SOURCE }}/irene3/vendor/gap"
- name: Build gap
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
cmake \
--build gap_build \
-j ${{ steps.build_job_count.outputs.VALUE }}
- name: Install gap
id: gap_installer
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
export DESTDIR=${{ steps.build_paths.outputs.INSTALL }}/gap
cmake --build gap_build \
--target install
echo "PATH=${DESTDIR}" >> ${GITHUB_OUTPUT}
- name: Configure irene3
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
mkdir irene3_build && cd irene3_build
cmake \
-DCMAKE_TOOLCHAIN_FILE="${{ steps.cxxcommon_installer.outputs.PATH }}/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET="x64-linux-rel" \
-Dremill_DIR="${{ steps.build_paths.outputs.INSTALL }}/remill/usr/local/lib/cmake/remill/"\
-Dsleigh_DIR="${{ steps.build_paths.outputs.INSTALL }}/remill/usr/local/lib/cmake/sleigh/"\
-Danvill_DIR="${{ steps.build_paths.outputs.INSTALL }}/anvill/usr/local/lib/cmake/anvill/"\
-Dgap_DIR="${{ steps.build_paths.outputs.INSTALL }}/gap/usr/local/lib/cmake/gap/"\
-DIRENE3_ENABLE_INSTALL=true \
-G Ninja \
${{ steps.build_paths.outputs.SOURCE }}/irene3
- name: Build irene3
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
cmake --build irene3_build \
-j ${{ steps.build_job_count.outputs.VALUE }}
- name: Install irene3
id: irene3_installer
working-directory: ${{ steps.build_paths.outputs.BUILD }}
env:
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }}
run: |
export DESTDIR=${{ steps.build_paths.outputs.INSTALL }}/irene3
cmake --build irene3_build \
--target install
echo "PATH=${DESTDIR}" >> ${GITHUB_OUTPUT}
- name: Test irene3
shell: bash
working-directory: ${{ steps.build_paths.outputs.BUILD }}
run: |
env CTEST_OUTPUT_ON_FAILURE=1 cmake --build irene3_build --target test
build_docker:
runs-on:
labels: gha-ubuntu-32
strategy:
matrix:
ubuntu: ["22.04"]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/trailofbits/irene3/irene3-ubuntu${{ matrix.ubuntu }}-amd64
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Used to get commit message since PRs are on a merge commit
- name: Get commit message
run: |
echo 'COMMIT_MESSAGE<<EOF' >> "$GITHUB_ENV"
if [[ '${{ github.event_name }}' == 'push' ]]; then
echo "$(git log --format=%B -n 1 HEAD)" >> "$GITHUB_ENV"
elif [[ '${{ github.event_name }}' == 'pull_request' ]]; then
echo "$(git log --format=%B -n 1 HEAD^2)" >> "$GITHUB_ENV"
fi
echo "EOF" >> "$GITHUB_ENV"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and load image for testing first
- name: Build and load
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
load: true
tags: build-test
build-args: |
UBUNTU_VERSION=${{ matrix.ubuntu }}
# Test build-test tag
- name: Test Docker image
env:
TOB_AMP_PASSPHRASE: ${{secrets.TOB_AMP_PASSPHRASE}}
run: |
echo ::group::irene3-public
docker run --rm -v $(pwd):/workspace -w /workspace build-test /workspace/scripts/test-ci.py ./tests ./tests/test_spec.json --skip-decompile --check --outputfile out1.log
echo ::endgroup
./scripts/download_and_unpack_demo.sh
echo ::group::irene3-private
docker run --rm -v $(pwd):/workspace -w /workspace build-test /workspace/scripts/test-ci.py ./tests/demo ./tests/demo/test_spec.json --skip-decompile --check --outputfile out2.log
echo ::endgroup
- name: "Tar test logs"
if: ${{ failure() }}
run: |
tar -cvf test-out.tar.gz out*.log
- name: "Upload test logs"
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: Test Report
path: test-out.tar.gz
# Push with proper tag once test ran
- name: Build and push
uses: docker/build-push-action@v3
if: github.event.release
with:
context: .
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
build-args: |
UBUNTU_VERSION=${{ matrix.ubuntu }}
push: true