-
Notifications
You must be signed in to change notification settings - Fork 21
235 lines (230 loc) · 8.32 KB
/
Copy pathtest-ffi.yml
File metadata and controls
235 lines (230 loc) · 8.32 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
name: Test FFI
on:
pull_request:
push:
branches:
- main
- mq-working-branch-*
schedule:
- cron: '0 6 * * *'
env:
CARGO_TERM_COLOR: always
jobs:
setup:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.set-packages.outputs.packages }}
packages-count: ${{ steps.set-packages.outputs.packages-count }}
crates-json: ${{ steps.set-packages.outputs.crates-json }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
fetch-depth: 0
- name: Get crates report
id: changed-crates
uses: ./.github/actions/crates-reporter
- name: Set FFI packages
id: set-packages
env:
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
CHANGED_CRATES_COUNT: ${{ steps.changed-crates.outputs.crates_count }}
AFFECTED_CRATES: ${{ steps.changed-crates.outputs.affected_crates }}
run: |
if [[ "$CHANGED_CRATES_STATUS" == "skipped" ]]; then
COUNT="1"
PACKAGES=""
CRATES_JSON=""
elif [[ "$CHANGED_CRATES_COUNT" == "0" ]]; then
COUNT="0"
PACKAGES=""
CRATES_JSON=""
else
FFI_CRATES=$(echo "$AFFECTED_CRATES" | jq '[.[] | select(endswith("-ffi"))]')
COUNT=$(echo "$FFI_CRATES" | jq 'length')
PACKAGES=$(echo "$FFI_CRATES" | jq -r 'map("-p " + .) | join(" ")')
CRATES_JSON="$FFI_CRATES"
fi
{
echo "packages-count=$COUNT"
echo "packages=$PACKAGES"
echo "crates-json<<EOF"
echo "$CRATES_JSON"
echo "EOF"
} >> $GITHUB_OUTPUT
ffi:
name: "FFI #${{ matrix.platform }}"
needs: setup
if: needs.setup.outputs.packages-count != '0'
runs-on: ${{ matrix.platform }}
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
strategy:
matrix:
platform: [windows-latest, ubuntu-latest, macos-15]
include:
- platform: "ubuntu-latest"
flags: "-C relocation-model=pic"
- platform: "macos-15"
flags: "-C relocation-model=pic"
- platform: "windows-latest"
flags: "-C target-feature=+crt-static"
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Setup output dir
shell: bash
run: |
WORKSPACE_PATH=${{ github.workspace }}
if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then
WORKSPACE_PATH=$(cygpath -ua '${{ github.workspace }}')
fi
echo "LIBDD_OUTPUT_FOLDER=$WORKSPACE_PATH/artifacts" >> $GITHUB_ENV
- name: Free Disk Space (Ubuntu only)
if: runner.os == 'Linux' && matrix.platform == 'ubuntu-latest'
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # 1.3.1
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: true
- id: rust-version
# rustup auto-installs the version pinned in rust-toolchain.toml on first invocation.
# On Windows run happens in a PowerShell, so start bash explicitly.
run: bash -c 'echo "version=$(rustc --version | cut -d" " -f2)" >> $GITHUB_OUTPUT'
- name: Install Go (macOS)
if: runner.os == 'macOS'
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: 'stable'
cache: false
- name: Cache [rust]
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
env:
RUSTFLAGS: "${{ matrix.flags }}"
with:
cache-targets: true # cache build artifacts
cache-bin: true # cache the ~/.cargo/bin directory
- name: "Generate profiling FFI"
shell: bash
env:
RUSTFLAGS: "${{ matrix.flags }}"
run: |
cargo run --bin release --release -- --out $LIBDD_OUTPUT_FOLDER
- name: 'Publish libdatadog'
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # 4.6.1
if: success() || failure()
with:
if-no-files-found: error
name: libdatadog.${{ matrix.platform }}
path: ${{ github.workspace }}/artifacts
retention-days: 1
- name: "(Windows) Test building Profiling C bindings - dynamic link vc runtime"
if: matrix.platform == 'windows-latest'
shell: bash
run: |
set -e
rm -rf examples/ffi/build_dll
mkdir examples/ffi/build_dll
cd examples/ffi/build_dll
cmake -S .. -DDatadog_ROOT=$LIBDD_OUTPUT_FOLDER -DVCRUNTIME_LINK_TYPE=DLL
cmake --build .
- name: "(Windows) Test building Profiling C bindings - static link vc runtime"
if: matrix.platform == 'windows-latest'
shell: bash
run: |
set -e
rm -rf examples/ffi/build_static
mkdir examples/ffi/build_static
cd examples/ffi/build_static
cmake -S .. -DDatadog_ROOT=$LIBDD_OUTPUT_FOLDER -DVCRUNTIME_LINK_TYPE=STATIC
cmake --build .
- name: "Test building Profiling C bindings"
shell: bash
if: matrix.platform != 'windows-latest'
run: |
set -e
mkdir examples/ffi/build
cd examples/ffi/build
# Add BUILD_SYMBOLIZER variable only for Linux platforms
if [[ "${{ matrix.platform }}" == "ubuntu-latest" ]]; then
cmake -S .. -DDatadog_ROOT=$LIBDD_OUTPUT_FOLDER -DBUILD_SYMBOLIZER=true
else
cmake -S .. -DDatadog_ROOT=$LIBDD_OUTPUT_FOLDER
fi
cmake --build .
- name: "Run FFI examples"
shell: bash
if: matrix.platform != 'windows-latest'
run: |
cargo ffi-test --skip-build
- name: "(Windows) Run FFI examples"
shell: bash
if: matrix.platform == 'windows-latest'
run: |
cargo ffi-test
- name: "Test building CXX bindings - Crashinfo (Unix)"
shell: bash
if: matrix.platform != 'windows-latest'
run: |
set -e
cd examples/cxx
./build-and-run-crashinfo.sh
- name: "Test building CXX bindings - Profiling (Unix)"
shell: bash
if: matrix.platform != 'windows-latest'
run: |
set -e
cd examples/cxx
./build-profiling.sh
- name: "Setup MSVC (Windows)"
if: matrix.platform == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1
- name: "Test building CXX bindings - Crashinfo (Windows)"
shell: pwsh
if: matrix.platform == 'windows-latest'
run: |
cd examples/cxx
.\build-and-run-crashinfo.ps1
- name: "Test building CXX bindings - Profiling (Windows)"
shell: pwsh
if: matrix.platform == 'windows-latest'
run: |
cd examples/cxx
.\build-profiling.ps1
ffi_bake:
strategy:
matrix:
target: [alpine-build] # debian-build-aarch64 is oom killed at the moment
name: "FFI ${{ matrix.target }} via docker bake"
needs: setup
if: needs.setup.outputs.packages-count != '0'
concurrency:
group: ci-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}-${{ matrix.target }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
runs-on:
labels: ubuntu-latest-16-cores
group: APM Larger Runners
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # 3.10.0
with:
buildkitd-config: .github/buildkitd-16-cores.toml
- name: Build and Generate FFI
uses: docker/bake-action@4ba453fbc2db7735392b93edf935aaf9b1e8f747 # 6.5.0
with:
targets: ${{ matrix.target }}
# Caching is useful, when it works. We are routinely hanging, maybe this:
# https://github.com/docker/buildx/issues/537
#set: |
# *.cache-from=type=gha,scope=${{ matrix.target }}
# *.cache-to=type=gha,mode=max,scope=${{ matrix.target }}