-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (173 loc) · 5.89 KB
/
statsig-ffi.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
name: Statsig FFI
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
build-linux:
strategy:
fail-fast: false
matrix:
config:
- target: amazonlinux2-arm64
platform: linux/arm64
runner: statsig-ubuntu-arm64
- target: amazonlinux2023-arm64
platform: linux/arm64
runner: statsig-ubuntu-arm64
- target: amazonlinux2-x86_64
platform: linux/amd64
runner: ubuntu-latest
- target: amazonlinux2023-x86_64
platform: linux/amd64
runner: ubuntu-latest
runs-on: ${{ matrix.config.runner }}
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Cache Cargo Build
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: "Login to Docker Hub"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Compute Dockerfile Hash"
id: compute_hash
run: |
md5hash=$(md5sum tools/docker/Dockerfile.${{ matrix.config.target }} | awk '{ print $1 }')
echo "md5hash: $md5hash"
imagetag="statsig/core-sdk-compiler:${{ matrix.config.target }}-$md5hash"
echo "IMAGE_TAG=$imagetag" >> $GITHUB_ENV
echo "IMAGE_TAG: $imagetag"
- name: "Check if Docker Image Exists"
id: check_image
run: |
echo "Looking for Docker image: ${{ env.IMAGE_TAG }}"
if docker manifest inspect $IMAGE_TAG > /dev/null 2>&1; then
echo "Image exists."
echo "NEEDS_BUILD=false" >> $GITHUB_ENV
else
echo "Image does not exist."
echo "NEEDS_BUILD=true" >> $GITHUB_ENV
fi
# [Build] If DockerHub does not contain our image --------------------------------
- name: "[Build] Setup QEMU"
if: env.NEEDS_BUILD == 'true'
uses: docker/setup-qemu-action@v3
- name: "[Build] Setup Docker Build Requirements"
if: env.NEEDS_BUILD == 'true'
uses: docker/setup-buildx-action@v3
- name: "[Build] Build Docker Image"
if: env.NEEDS_BUILD == 'true'
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.config.platform }}
file: tools/docker/Dockerfile.${{ matrix.config.target }}
push: true
tags: |
${{ env.IMAGE_TAG }}
statsig/core-sdk-compiler:${{ matrix.config.target }}-latest
# [Build] end --------------------------------
- name: "Load Docker Image"
run: |
docker pull --platform ${{ matrix.config.platform }} ${{ env.IMAGE_TAG }}
docker tag ${{ env.IMAGE_TAG }} statsig/core-sdk-compiler:${{ matrix.config.target }}
- name: Build
shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"'
run: |
./tools/docker/build_${{ matrix.config.target }}.sh
./tools/docker/build_${{ matrix.config.target }}.sh --release-mode
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: statsig-ffi-${{ matrix.config.target }}
path: |
target/**/release/libstatsig_ffi.so
target/**/debug/libstatsig_ffi.so
if-no-files-found: error
build-windows:
runs-on: windows-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
target:
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc
- i686-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Cache Cargo Build
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust Targets
run: |
rustup target add ${{ matrix.target }}
- name: Build
run: |
cargo build -p statsig_ffi --target ${{ matrix.target }}
cargo build -p statsig_ffi --target ${{ matrix.target }} --release
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: statsig-ffi-${{ matrix.target }}
path: |
target/**/release/statsig_ffi.dll
target/**/debug/statsig_ffi.dll
target/**/debug/statsig_ffi.pdb
if-no-files-found: error
build-macos:
runs-on: macos-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
target:
- aarch64-apple-darwin
- x86_64-apple-darwin
steps:
- uses: actions/checkout@v4
- name: Cache Cargo Build
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust Targets
run: |
rustup target add ${{ matrix.target }}
- name: Build
run: |
cargo build -p statsig_ffi --target=${{ matrix.target }}
cargo build -p statsig_ffi --target=${{ matrix.target }} --release
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: statsig-ffi-${{ matrix.target }}
path: |
target/**/release/libstatsig_ffi.dylib
target/**/debug/libstatsig_ffi.dylib
if-no-files-found: error