-
-
Notifications
You must be signed in to change notification settings - Fork 621
286 lines (284 loc) · 10.9 KB
/
linux-x86-64.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
name: 'Linux x86-64'
on: push
jobs:
linux-sdk:
runs-on: ubuntu-latest
container:
image: liefproject/manylinux_2_28_x86_64
env:
CCACHE_DIR: "/home/pylief/.ccache"
CXXFLAGS: "-ffunction-sections -fdata-sections -fvisibility-inlines-hidden -static-libstdc++ -static-libgcc"
CFLAGS: "-ffunction-sections -fdata-sections -static-libstdc++ -static-libgcc"
LDFLAGS: "-Wl,--gc-sections -Wl,--exclude-libs,ALL"
BUILD_DIR_STATIC: "/tmp/build/linux-x86-64/static-release"
BUILD_DIR_SHARED: "/tmp/build/linux-x86-64/shared-release"
CLICOLOR_FORCE: "1"
ACTIONS_RUNTIME_URL: "${{ env.ACTIONS_RUNTIME_URL }}"
ACTIONS_RUNTIME_TOKEN: "${{ env.ACTIONS_RUNTIME_TOKEN }}"
ACTIONS_CACHE_URL: "${{ env.ACTIONS_CACHE_URL }}"
options: --user 1001:1001
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Prepare ccache
shell: bash
run: |
mkdir -p /home/pylief/.ccache/tmp
- name: ccache cache files
uses: actions/cache@v4
with:
path: /home/pylief/.ccache
key: linux-x86-64-${{ runner.os }}-sdk-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-x86-64-${{ runner.os }}-sdk
- name: CMake - Static
shell: bash
run: |
mkdir -p ${BUILD_DIR_STATIC}
cmake -S $GITHUB_WORKSPACE -B ${BUILD_DIR_STATIC} -GNinja \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=off \
-DLIEF_INSTALL_COMPILED_EXAMPLES=on \
-DCMAKE_INSTALL_PREFIX=/install \
-DCMAKE_BUILD_TYPE=Release
- name: Compile - Static
shell: bash
run: |
cmake --build ${BUILD_DIR_STATIC} --target install
- name: CMake - Shared
shell: bash
run: |
mkdir -p ${BUILD_DIR_SHARED}
cmake -S $GITHUB_WORKSPACE -B ${BUILD_DIR_SHARED} -GNinja \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=on \
-DLIEF_INSTALL_COMPILED_EXAMPLES=off \
-DCMAKE_BUILD_TYPE=Release
- name: Compile - Shared
run: |
cmake --build ${BUILD_DIR_SHARED} --target all
- name: Package
run: |
cd /tmp/build/linux-x86-64
cpack --config $GITHUB_WORKSPACE/cmake/cpack.config.cmake
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v4
with:
name: linux-x86-64-sdk
path: /tmp/build/linux-x86-64/*.tar.gz
retention-days: 3
- name: 'Upload Install Artifact'
uses: actions/upload-artifact@v4
with:
name: linux-x86-64-install
path: /install
retention-days: 1
testing:
if: "!contains(github.event.commits[0].message, '[skip-test]')"
runs-on: ubuntu-latest
container:
image: liefproject/manylinux_2_28_x86_64
env:
PYTHON_BINARY: "/opt/python/cp38-cp38/bin/python3.8"
LIEF_SAMPLES_DIR: "/tmp/samples"
LIEF_BUILD_DIR: "/tmp/lief-build"
LIEF_VENV: "/tmp/venv"
CLICOLOR_FORCE: "1"
PYTEST_ADDOPTS: "--color=yes"
options: --user 1001:1001
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: ccache cache files
uses: actions/cache@v4
with:
path: ~/.ccache
key: linux-x86-64-${{ runner.os }}-test-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-x86-64-${{ runner.os }}-test
- name: Prepare Python virtual env
shell: bash
run: |
$PYTHON_BINARY -m venv ${LIEF_VENV}
source ${LIEF_VENV}/bin/activate
python -m pip install \
-r tests/requirements.txt \
-r api/python/build-requirements.txt
- name: Build & install LIEF
shell: bash
run: |
source ${LIEF_VENV}/bin/activate
export PYLIEF_CONF="${GITHUB_WORKSPACE}/scripts/docker/config/pylinux-test-x64.toml"
python -m pip -vvv install api/python
- name: Prepare test samples
shell: bash
run: |
source ${LIEF_VENV}/bin/activate
mkdir -p ${LIEF_SAMPLES_DIR}
python tests/dl_samples.py ${LIEF_SAMPLES_DIR}
- name: Run tests
timeout-minutes: 5
shell: bash
run: |
source ${LIEF_VENV}/bin/activate
python tests/run_pytest.py
python tests/run_tools_check.py ${LIEF_BUILD_DIR}/
ctest --output-on-failure --test-dir ${LIEF_BUILD_DIR}/
- name: Fuzzing [ls x86-64]
shell: bash
timeout-minutes: 20
run: |
source ${LIEF_VENV}/bin/activate
export PYTHONPATH="${GITHUB_WORKSPACE}/tests:$PYTHONPATH"
python tests/elf/fuzzing.py \
${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \
--input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_ls.bin -n 100
- name: Fuzzing [openssl x86-64]
shell: bash
timeout-minutes: 20
run: |
source ${LIEF_VENV}/bin/activate
export PYTHONPATH="${GITHUB_WORKSPACE}/tests:$PYTHONPATH"
python tests/elf/fuzzing.py \
${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \
--input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_openssl.bin -n 100
- name: Fuzzing [nm x86-64]
shell: bash
timeout-minutes: 20
run: |
source ${LIEF_VENV}/bin/activate
export PYTHONPATH="${GITHUB_WORKSPACE}/tests:$PYTHONPATH"
python tests/elf/fuzzing.py \
${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \
--input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_nm.bin -n 100
pywheels:
runs-on: ubuntu-latest
needs: linux-sdk
container:
image: liefproject/manylinux_2_28_x86_64
env:
CCACHE_DIR: "/home/pylief/.ccache"
CXXFLAGS: "-ffunction-sections -fdata-sections -fvisibility-inlines-hidden -static-libgcc"
CFLAGS: "-ffunction-sections -fdata-sections -static-libgcc"
LDFLAGS: "-Wl,--gc-sections -Wl,--exclude-libs,ALL"
CLICOLOR_FORCE: "1"
FORCE_COLOR: "1"
LIEF_BUILD_DIR: "/tmp/lief-build"
ACTIONS_RUNTIME_URL: "${{ env.ACTIONS_RUNTIME_URL }}"
ACTIONS_RUNTIME_TOKEN: "${{ env.ACTIONS_RUNTIME_TOKEN }}"
ACTIONS_CACHE_URL: "${{ env.ACTIONS_CACHE_URL }}"
options: --user 1001:1001
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Prepare ccache
shell: bash
run: |
mkdir -p /home/pylief/.ccache/tmp
- name: ccache cache files
uses: actions/cache@v4
with:
path: /home/pylief/.ccache
key: linux-x86-64-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-x86-64-${{ runner.os }}-${{ matrix.python-version }}
- name: Download LIEF install dir
uses: actions/download-artifact@v4
with:
name: linux-x86-64-install
path: /install
- name: Generate wheel
env:
PYTHON_VERSION: ${{ matrix.python-version }}
shell: bash
run: |
export PYLIEF_CONF=$GITHUB_WORKSPACE/scripts/docker/config/pylinux-x64.toml
PYTHON_VERSION_ALT=$(echo "${PYTHON_VERSION}" | sed 's/\.//') # Transform 3.8 -> 38
PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION}
$PYTHON_BINARY -m pip -vvv wheel --disable-pip-version-check \
--wheel-dir=$GITHUB_WORKSPACE/wheel_stage \
$GITHUB_WORKSPACE/api/python
- name: Run auditwheel
shell: bash
run: |
ls -alh $GITHUB_WORKSPACE/wheel_stage
find $GITHUB_WORKSPACE/wheel_stage -exec \
auditwheel repair -w $GITHUB_WORKSPACE/dist {} \;
ls -alh $GITHUB_WORKSPACE/dist
- name: 'Artifact'
uses: actions/upload-artifact@v4
with:
name: linux-x86-64-python${{ matrix.python-version }}-wheel
path: dist/*.whl
retention-days: 3
deploy:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [linux-sdk, pywheels]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: linux-x86-64-*
merge-multiple: true
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
run: ls -R
working-directory: ${{ runner.temp }}/artifacts
- name: Deploy
env:
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
shell: bash
run: |
docker run --rm \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP:/runner_tmp \
-e GITHUB_ACTIONS="true" \
-e GITHUB_WORKSPACE=$GITHUB_WORKSPACE \
-e GITHUB_REF=$GITHUB_REF \
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
liefproject/deploy \
python3 /src/.github/deploy.py /runner_tmp/artifacts
documentation:
needs: [deploy]
runs-on: ubuntu-latest
container:
image: liefproject/manylinux_2_28_x86_64
env:
CIRCLE_CI_URL: "https://circleci.com/api/v2/project/gh/lief-project/doc/pipeline"
CIRCLE_CI_TOKEN: ${{ secrets.CIRCLE_CI_TOKEN }}
steps:
- name: Trigger documentation
if: github.ref == 'refs/heads/main'
run: |
curl --request POST --url ${CIRCLE_CI_URL} \
--header "Circle-Token: ${CIRCLE_CI_TOKEN}" \
--header 'content-type: application/json' \
--data '{"parameters":{"lief-branch":"main"}}'