Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 130 additions & 12 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,130 @@
name: CD

on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]

jobs:
call-workflow-from-shared-config:
uses: rubyatscale/shared-config/.github/workflows/cd.yml@main
secrets: inherit
---
name: CD

on:
workflow_dispatch:
push:
tags: ["v*"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci-data:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.fetch.outputs.result }}
steps:
- id: fetch
uses: oxidize-rb/actions/fetch-ci-data@v1
with:
supported-ruby-platforms: |
# Excluding:
# `arm-linux`: Cranelift doesn't support 32-bit architectures
# `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)
# 3.0 is deprecated as stable ruby version according to:
# https://github.com/oxidize-rb/actions/blob/main/fetch-ci-data/evaluate.rb#L54
exclude: [arm-linux, x64-mingw32]
stable-ruby-versions: |
exclude: [head]

build:
name: Build native gems
needs: ci-data
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"

- uses: oxidize-rb/actions/cross-gem@v1
id: cross-gem
with:
platform: ${{ matrix.ruby-platform }}
ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}

- uses: actions/upload-artifact@v4
with:
name: cross-gem-${{ matrix.ruby-platform }}
path: pkg/*-${{ matrix.ruby-platform }}.gem
if-no-files-found: error

- name: Smoke gem install
if: matrix.ruby-platform == 'ignore-for-now-x86_64-linux' # GitHub actions architecture
run: |
gem install pkg/fast_code_owners-*.gem --verbose
script="puts FastCodeOwners::VERSION"
ruby -rfast_code_owners -e "$script" | grep 0.1.0
echo "✅ Successfully gem installed"

release:
name: Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: "3.4"
bundler-cache: true
cargo-cache: true
cache-version: v1

- uses: actions/download-artifact@v4
with:
pattern: cross-gem-*
merge-multiple: true
path: pkg/

- name: Package source gem
run: bundle exec rake pkg:ruby

- name: Ensure version matches the tag
run: |
GEM_VERSION=$(grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" lib/fast_code_owners/version.rb | head -n 1)
if [ "v$GEM_VERSION" != "${{ github.ref_name }}" ]; then
echo "Gem version does not match tag"
echo " v$GEM_VERSION != ${{ github.ref_name }}"
exit 1
fi

- name: Push Gem
working-directory: pkg/
env:
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
ls -l
for i in *.gem; do
if [ -f "$i" ]; then
if ! gem push "$i" >push.out; then
gemerr=$?
sed 's/^/::error:: /' push.out
if ! grep -q "Repushing of gem" push.out; then
exit $gemerr
fi
fi
fi
done

- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
generateReleaseNotes: true
draft: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
skipIfReleaseExists: true
49 changes: 31 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,40 @@ on:
pull_request:

jobs:
rspec:
ci-data:
runs-on: ubuntu-latest
strategy:
matrix:
ruby:
- 3.1
- 3.2
- 3.3
- 3.4
env:
BUNDLE_GEMFILE: Gemfile
name: "RSpec tests: Ruby ${{ matrix.ruby }}"
outputs:
result: ${{ steps.fetch.outputs.result }}
steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
- id: fetch
uses: oxidize-rb/actions/fetch-ci-data@v1
with:
bundler-cache: true
ruby-version: ${{ matrix.ruby }}
- name: Run tests
run: bundle exec rspec
stable-ruby-versions: |
# See https://github.com/bytecodealliance/wasmtime-rb/issues/286
# for details.
exclude: [head]
rspec:
runs-on: ${{ matrix.os }}
needs: ci-data
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
ruby: ${{ fromJSON(needs.ci-data.outputs.result).stable-ruby-versions }}
steps:
- uses: actions/checkout@v4
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
cargo-cache: true
cache-version: v5

- name: Compile rust ext
run: bundle exec rake compile:release

- name: Run ruby tests
run: bundle exec rake spec
static_type_check:
name: "Type Check"
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/pkg/
/spec/reports/
/tmp/
/target/
/vendor

Gemfile.lock

Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.2
3.4.5
Loading
Loading