-
-
Notifications
You must be signed in to change notification settings - Fork 35
183 lines (159 loc) Β· 5.67 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
---
name: "CI"
on:
push:
branches:
- main
pull_request: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
DEBUG_OUTPUT_DIR: /tmp/debug
jobs:
fetch_ci_data:
name: π₯ Fetch CI data
runs-on: ubuntu-latest
outputs:
minimum-supported-ruby-version: ${{ steps.data.outputs.minimum-supported-ruby-version }}
minimum-supported-rust-version: ${{ steps.data.outputs.minimum-supported-rust-version }}
steps:
- id: data
run: |
curl -s https://raw.githubusercontent.com/oxidize-rb/rb-sys/$GITHUB_SHA/data/toolchains.json > toolchains.json
echo "minimum-supported-rust-version=$(jq -r '.policy["minimum-supported-rust-version"]' toolchains.json)" >> $GITHUB_OUTPUT
build_and_test:
name: π§ͺ Test
needs: fetch_ci_data
strategy:
fail-fast: false
matrix:
# Test against all versions supported by rubygems
ruby_version: ["2.4", "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "head"]
sys:
- os: ubuntu-latest
rust_toolchain: ${{ needs.fetch_ci_data.outputs.minimum-supported-rust-version }}
- os: ubuntu-latest
rust_toolchain: stable
- os: macos-latest
rust_toolchain: stable
- os: windows-2022
rust_toolchain: stable
include:
- ruby_version: mswin
sys:
os: windows-2022
rust_toolchain: stable-x86_64-pc-windows-msvc
runs-on: ${{ matrix.sys.os }}
steps:
- uses: actions/checkout@v3
- name: Setup debug info
shell: bash
run: script/ci/set-debug-env.sh
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
if: matrix.ruby_version != 'skip'
with:
cache-version: v2
ruby-version: ${{ matrix.ruby_version }}
rustup-toolchain: ${{ matrix.sys.rust_toolchain }}
bundler-cache: true
cargo-cache: true
- name: Bundle install
if: matrix.ruby_version == 'skip'
shell: bash
run: bundle install -j3
- name: Debug makefile
if: env.ACTIONS_STEP_DEBUG == 'true'
shell: bash
run: |
bundle exec rake debug:mkmf > $DEBUG_OUTPUT_DIR/Makefile
echo "::group::Print mkmf generated Makefile"
cat $DEBUG_OUTPUT_DIR/Makefile
echo "::endgroup::"
- name: π Examples test
shell: bash
env:
RB_SYS_CARGO_PROFILE: "release"
run: script/ci/upload-on-failure.sh "bundle exec rake test:examples" "examples-test" "./examples"
- name: π§ͺ Cargo test
shell: bash
run: bundle exec rake test:cargo
- name: π Gem test
run: bundle exec rake test:gem
- name: π¨ Smoke test
shell: bash
run: |
set -ex
gem update --system 3.3.22 > /dev/null
export RUBYOPT="-I$PWD/gem/lib"
pushd examples/rust_reverse
bundle exec rake build
gem install pkg/*.gem --verbose
../../script/ci/upload-on-failure.sh "gem install pkg/*.gem --verbose" "smoke-test" "./pkg"
ruby -rrust_reverse -e "puts RustReverse.reverse('olleh')" | grep hello
popd
- name: βοΈ Run clippy
run: cargo clippy
- name: π Run cargo fmt
if: matrix.sys.rust_toolchain == 'stable'
run: cargo fmt --check
- name: π Run Standard.rb
if: matrix.ruby_version == '3.1'
run: bundle exec standardrb --format github
- name: "𧱠Generate bindings"
if: env.ACTIONS_STEP_DEBUG == 'true'
run: bundle exec rake bindings:generate
- uses: actions/upload-artifact@v3
if: always()
with:
name: rb-sys-ci-debug-artifacts-${{ matrix.sys.os }}-${{ matrix.ruby_version }}
if-no-files-found: ignore
retention-days: 1
path: |
/tmp/bindings/**/*
${{ env.DEBUG_OUTPUT_DIR }}/**/*
build_and_test_static:
name: π Static
strategy:
fail-fast: false
matrix:
ruby_version: ["3.1.3"]
sys:
- os: ubuntu-latest
rust_toolchain: stable
runs-on: ${{ matrix.sys.os }}
steps:
- uses: actions/checkout@v3
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: none
rustup-toolchain: ${{ matrix.sys.rust_toolchain }}
cargo-cache: "sccache"
- name: Setup env
run: |
echo "PATH=/opt/rubies/${{ matrix.ruby_version }}/bin:$PATH" >> $GITHUB_ENV
echo "GEM_HOME=~/.gem/ruby/${{ matrix.ruby_version }}" >> $GITHUB_ENV
- name: β‘ Cache
uses: actions/cache@v3
with:
path: |
/opt/rubies/${{ matrix.ruby_version }}
~/.gem/ruby/${{ matrix.ruby_version }}
key: rb-sys-ruby-static-${{ matrix.sys.os }}-${{ matrix.ruby_version }}
- name: π Build static ruby
working-directory: /tmp
run: |
if [ -d /opt/rubies/${{matrix.ruby_version }} ]; then
echo "Ruby ${{ matrix.ruby_version }} already installed, skipping build"
else
git clone https://github.com/rbenv/ruby-build.git
PREFIX=/usr/local sudo ./ruby-build/install.sh
export MAKEFLAGS="-j$(nproc)"
export RUBY_CONFIGURE_OPTS="--disable-shared --disable-install-doc --disable-install-rdoc"
sudo ruby-build ${{ matrix.ruby_version }} /opt/rubies/${{ matrix.ruby_version }}
fi
- name: Bundle install
run: bundle install -j3
- name: π§ͺ Run tests
run: bundle exec rake test