Skip to content

Commit e743fad

Browse files
committed
updating ci for ffi
1 parent 0552b2f commit e743fad

File tree

3 files changed

+162
-36
lines changed

3 files changed

+162
-36
lines changed

.github/workflows/cd.yml

Lines changed: 130 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,130 @@
1-
name: CD
2-
3-
on:
4-
workflow_run:
5-
workflows: [CI]
6-
types: [completed]
7-
branches: [main]
8-
9-
jobs:
10-
call-workflow-from-shared-config:
11-
uses: rubyatscale/shared-config/.github/workflows/cd.yml@main
12-
secrets: inherit
1+
---
2+
name: CD
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
tags: ["v*"]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
ci-data:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
result: ${{ steps.fetch.outputs.result }}
18+
steps:
19+
- id: fetch
20+
uses: oxidize-rb/actions/fetch-ci-data@v1
21+
with:
22+
supported-ruby-platforms: |
23+
# Excluding:
24+
# `arm-linux`: Cranelift doesn't support 32-bit architectures
25+
# `x64-mingw32`: `x64-mingw-ucrt` should be used for Ruby 3.1+ (https://github.com/rake-compiler/rake-compiler-dock?tab=readme-ov-file#windows)
26+
# 3.0 is deprecated as stable ruby version according to:
27+
# https://github.com/oxidize-rb/actions/blob/main/fetch-ci-data/evaluate.rb#L54
28+
exclude: [arm-linux, x64-mingw32]
29+
stable-ruby-versions: |
30+
exclude: [head]
31+
32+
build:
33+
name: Build native gems
34+
needs: ci-data
35+
runs-on: ubuntu-latest
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
ruby-platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- uses: ruby/setup-ruby@v1
44+
with:
45+
ruby-version: "3.4"
46+
47+
- uses: oxidize-rb/actions/cross-gem@v1
48+
id: cross-gem
49+
with:
50+
platform: ${{ matrix.ruby-platform }}
51+
ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
52+
53+
- uses: actions/upload-artifact@v4
54+
with:
55+
name: cross-gem-${{ matrix.ruby-platform }}
56+
path: pkg/*-${{ matrix.ruby-platform }}.gem
57+
if-no-files-found: error
58+
59+
- name: Smoke gem install
60+
if: matrix.ruby-platform == 'ignore-for-now-x86_64-linux' # GitHub actions architecture
61+
run: |
62+
gem install pkg/fast_code_owners-*.gem --verbose
63+
script="puts FastCodeOwners::VERSION"
64+
ruby -rfast_code_owners -e "$script" | grep 0.1.0
65+
echo "✅ Successfully gem installed"
66+
67+
release:
68+
name: Release
69+
needs: build
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v4
73+
74+
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
75+
with:
76+
ruby-version: "3.4"
77+
bundler-cache: true
78+
cargo-cache: true
79+
cache-version: v1
80+
81+
- uses: actions/download-artifact@v4
82+
with:
83+
pattern: cross-gem-*
84+
merge-multiple: true
85+
path: pkg/
86+
87+
- name: Package source gem
88+
run: bundle exec rake pkg:ruby
89+
90+
- name: Ensure version matches the tag
91+
run: |
92+
GEM_VERSION=$(grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" lib/fast_code_owners/version.rb | head -n 1)
93+
if [ "v$GEM_VERSION" != "${{ github.ref_name }}" ]; then
94+
echo "Gem version does not match tag"
95+
echo " v$GEM_VERSION != ${{ github.ref_name }}"
96+
exit 1
97+
fi
98+
99+
- name: Push Gem
100+
working-directory: pkg/
101+
env:
102+
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
103+
run: |
104+
mkdir -p $HOME/.gem
105+
touch $HOME/.gem/credentials
106+
chmod 0600 $HOME/.gem/credentials
107+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
108+
ls -l
109+
for i in *.gem; do
110+
if [ -f "$i" ]; then
111+
if ! gem push "$i" >push.out; then
112+
gemerr=$?
113+
sed 's/^/::error:: /' push.out
114+
if ! grep -q "Repushing of gem" push.out; then
115+
exit $gemerr
116+
fi
117+
fi
118+
fi
119+
done
120+
121+
- name: Create GitHub release
122+
uses: ncipollo/release-action@v1
123+
with:
124+
allowUpdates: true
125+
generateReleaseNotes: true
126+
draft: true
127+
omitBodyDuringUpdate: true
128+
omitNameDuringUpdate: true
129+
omitPrereleaseDuringUpdate: true
130+
skipIfReleaseExists: true

.github/workflows/ci.yml

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,40 @@ on:
77
pull_request:
88

99
jobs:
10-
rspec:
10+
ci-data:
1111
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
ruby:
15-
- 3.1
16-
- 3.2
17-
- 3.3
18-
- 3.4
19-
env:
20-
BUNDLE_GEMFILE: Gemfile
21-
name: "RSpec tests: Ruby ${{ matrix.ruby }}"
12+
outputs:
13+
result: ${{ steps.fetch.outputs.result }}
2214
steps:
23-
- uses: actions/checkout@v4
24-
- name: Set up Ruby ${{ matrix.ruby }}
25-
uses: ruby/setup-ruby@v1
15+
- id: fetch
16+
uses: oxidize-rb/actions/fetch-ci-data@v1
2617
with:
27-
bundler-cache: true
28-
ruby-version: ${{ matrix.ruby }}
29-
- name: Run tests
30-
run: bundle exec rspec
18+
stable-ruby-versions: |
19+
# See https://github.com/bytecodealliance/wasmtime-rb/issues/286
20+
# for details.
21+
exclude: [head]
22+
rspec:
23+
runs-on: ${{ matrix.os }}
24+
needs: ci-data
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
os: ["ubuntu-latest", "macos-latest"]
29+
ruby: ${{ fromJSON(needs.ci-data.outputs.result).stable-ruby-versions }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
33+
with:
34+
ruby-version: ${{ matrix.ruby }}
35+
bundler-cache: true
36+
cargo-cache: true
37+
cache-version: v5
38+
39+
- name: Compile rust ext
40+
run: bundle exec rake compile:release
41+
42+
- name: Run ruby tests
43+
run: bundle exec rake spec
3144
static_type_check:
3245
name: "Type Check"
3346
runs-on: ubuntu-latest

lib/code_ownership.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def for_file(file)
3838
TeamFinder.for_file(file)
3939
end
4040

41-
sig { params(team: T.any(CodeTeams::Team, String)).returns(String) }
41+
sig { params(team: T.any(CodeTeams::Team, String)).returns(T::Array[String]) }
4242
def for_team(team)
4343
team = T.must(CodeTeams.find(team)) if team.is_a?(String)
4444
::RustCodeOwners.for_team(team.name)
@@ -47,11 +47,6 @@ def for_team(team)
4747
class InvalidCodeOwnershipConfigurationError < StandardError
4848
end
4949

50-
sig { params(filename: String).void }
51-
def self.remove_file_annotation!(filename)
52-
Private::OwnershipMappers::FileAnnotations.new.remove_file_annotation!(filename)
53-
end
54-
5550
sig do
5651
params(
5752
autocorrect: T::Boolean,

0 commit comments

Comments
 (0)