263 lines (242 loc) · 7.48 KB
/
ci.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
name: CI
on:
workflow_dispatch:
schedule:
- cron: "0 5 * * 3" # At 05:00 on Wednesday # https://crontab.guru/#0_5_*_*_3
push:
branches:
- master
tags:
- "*.*.*"
pull_request:
types: [opened, synchronize]
branches:
- "*"
permissions:
contents: read
jobs:
system-libffi:
# Run on latest MRI with explicit selection of system or builtin libffi
strategy:
fail-fast: false
matrix:
os: [ ubuntu, macos, windows ]
extconfopts: [ --disable-system-libffi, --enable-system-libffi ]
extconfopts2: [ --disable-libffi-alloc, --enable-libffi-alloc ]
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- if: matrix.os == 'macos'
run: brew install automake libffi pkg-config
- if: matrix.os == 'windows' && matrix.extconfopts == '--enable-system-libffi'
shell: cmd
run: ridk exec sh -c "pacman --sync --refresh --needed --noconfirm ${MINGW_PACKAGE_PREFIX}-libffi"
- run: bundle install
- run: bundle exec rake libffi
- run: bundle exec rake compile -- ${{ matrix.extconfopts }} ${{ matrix.extconfopts2 }}
env:
# work around misconfiguration of libffi on MacOS with homebrew
PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }}:/usr/local/opt/libffi/lib/pkgconfig
- run: bundle exec rake test FFI_TEST_GC=true
- run: bundle exec rake types_conf && git --no-pager diff
specs:
# Run all specs on all ruby implementations
# Use automatic libffi selection on MRI
strategy:
fail-fast: false
matrix:
os: [ ubuntu, macos, windows ]
ruby: [ 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, ruby-head, truffleruby-head, jruby-head ]
exclude:
- os: windows
ruby: truffleruby-head
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: brew install automake
if: matrix.os == 'macos'
- run: bundle install
- run: bundle exec rake libffi
- run: bundle exec rake compile
- if: matrix.os != 'windows'
run: bundle exec rake test FFI_TEST_GC=true
- run: bundle exec rake bench:all
if: ${{ matrix.ruby != 'truffleruby-head' && matrix.ruby != 'jruby-head' }}
env:
ITER: 10
gc_stress:
if: github.ref == 'refs/heads/master'
strategy:
fail-fast: false
matrix:
os: [ ubuntu ]
ruby: [ ruby-head ]
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: bundle install
- run: bundle exec rake libffi
- name: Play dice if we run the tests or don't
id: run_it
run: ruby -e "puts 'RUN_IT=true' if rand < 0.1" >> $GITHUB_OUTPUT
- name: Run all tests with GC.stress=true
if: steps.run_it.outputs.RUN_IT == 'true'
run: bundle exec rake compile test FFI_GC_STRESS=true
rcd_build:
name: build fat binary gems
strategy:
fail-fast: false
matrix:
platform:
- x86-mingw32
- x64-mingw-ucrt
- x64-mingw32
- x86-linux-gnu
- x86-linux-musl
- x86_64-linux-gnu
- x86_64-linux-musl
- x86_64-darwin
- arm64-darwin
- arm-linux-gnu
- arm-linux-musl
- aarch64-linux-gnu
- aarch64-linux-musl
runs-on: ubuntu-latest
env:
PLATFORM: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
- name: Build ffi.gem
run: |
bundle install
bundle exec rake libffi
bundle exec rake gem:${PLATFORM}
- name: Upload binary gem
uses: actions/upload-artifact@v4
with:
name: gem-${{ matrix.platform }}
path: pkg/*-*-*.gem
job_test_native:
name: native test
needs: rcd_build
strategy:
fail-fast: false
matrix:
os:
- windows
- macos
- ubuntu
ruby:
- "3.3"
- "3.2"
- "3.1"
- "3.0"
- "2.7"
- "2.6"
- "2.5"
include:
- os: windows
platform: x64-mingw32
- os: macos
platform: x86_64-darwin
- os: ubuntu
platform: x86_64-linux-gnu
- os: windows
ruby: "3.1"
platform: x64-mingw-ucrt
- os: windows
ruby: "3.2"
platform: x64-mingw-ucrt
- os: windows
ruby: "3.3"
platform: x64-mingw-ucrt
exclude:
- os: windows
ruby: "3.1"
- os: windows
ruby: "3.2"
- os: windows
ruby: "3.3"
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: ruby --version
- name: Download gem-${{matrix.platform}}
uses: actions/download-artifact@v4
with:
name: gem-${{ matrix.platform }}
- name: Update rubygems - ruby-3.0
if: matrix.ruby == '3.0'
run: |
gem install --no-doc rubygems-update -v 3.5.7
update_rubygems
- name: Update rubygems - ruby-2.6 to 2.7
if: matrix.ruby == '2.6' || matrix.ruby == '2.7'
run: |
gem install --no-doc rubygems-update -v 3.4.22
update_rubygems
- name: Update rubygems - ruby-2.5
if: matrix.ruby == '2.5'
run: |
gem install --no-doc rubygems-update -v 3.3.27
update_rubygems
- name: Install gem-${{matrix.platform}}
run: gem install --local *.gem --verbose
- name: Run tests
run: |
bundle install
ruby -rffi -S rake test
job_fat_binary_multiarch:
name: multiarch (${{matrix.platform}} on ${{matrix.from_image}} ${{matrix.image_platform}})
needs: rcd_build
strategy:
fail-fast: false
matrix:
include:
- from_image: centos
image_platform: linux/x86_64
gem_platform: x86_64-linux-gnu
dockerfile: centos
- from_image: navikey/raspbian-bullseye
image_platform: linux/arm
gem_platform: arm-linux-gnu
dockerfile: debian
- from_image: ubuntu
image_platform: linux/arm64/v8
gem_platform: aarch64-linux-gnu
dockerfile: debian
- from_image: alpine
image_platform: linux/386
gem_platform: x86-linux-musl
dockerfile: alpine
- from_image: alpine
image_platform: linux/arm/v6
gem_platform: arm-linux-musl
dockerfile: alpine
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download gem-${{matrix.gem_platform}}
uses: actions/download-artifact@v4
with:
name: gem-${{ matrix.gem_platform }}
- name: Build image and Run tests
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker build --rm --platform ${{matrix.image_platform}} --build-arg from_image=${{matrix.from_image}} -t ruby-test -f spec/env/Dockerfile.${{matrix.dockerfile}} .
docker run --rm -t --network=host -v `pwd`:/build ruby-test