Skip to content
Closed
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
43 changes: 42 additions & 1 deletion .github/actions/test_ruby_gem_uploads/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@ inputs:
knapsack-pro-test-suite-token-rspec:
description: Optional Knapsack Pro test suite token for RSpec
required: true
alpine:
description: Run the smoke specs inside a musl (Alpine) container via docker instead of on the host
required: false
default: "false"

runs:
using: composite
steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
if: inputs.alpine != 'true'
with:
ruby-version: ${{ inputs.ruby-version }}
bundler-cache: true
Expand All @@ -59,8 +64,40 @@ runs:
path: ${{ github.action_path }}
merge-multiple: true

- name: Run smoke specs in a musl (Alpine) container
if: inputs.alpine == 'true'
shell: bash
working-directory: ${{ github.action_path }}
env:
TRUNK_PUBLIC_API_ADDRESS: ${{ inputs.trunk-public-api-address }}
TRUNK_ORG_URL_SLUG: ${{ inputs.trunk-org-slug }}
TRUNK_API_TOKEN: ${{ inputs.trunk-token }}
TRUNK_TEST_COLLECTION_ID: ${{ inputs.test-collection-id }}
TRUNK_VARIANT: ${{ inputs.variant }}
run: |
set -euxo pipefail
GEM_FILE=$(ls rspec_trunk_flaky_tests-*.gem | head -n 1)
REL="${GITHUB_ACTION_PATH#"${GITHUB_WORKSPACE}"/}"

# Forward the (non-secret) GitHub CI context into the container.
env | grep -E '^GITHUB_' > "${RUNNER_TEMP}/ci.env" || true

docker run --rm \
--env-file "${RUNNER_TEMP}/ci.env" \
-e GEM_FILE="${GEM_FILE}" \
-e TRUNK_PUBLIC_API_ADDRESS -e TRUNK_ORG_URL_SLUG -e TRUNK_API_TOKEN \
-e TRUNK_TEST_COLLECTION_ID -e TRUNK_VARIANT \
-v "${GITHUB_WORKSPACE}:/work" -w "/work/${REL}" \
"ruby:${{ inputs.ruby-version }}-alpine" \
sh -euxc '
gem install rspec --no-document
gem install "./${GEM_FILE}" --local --no-document
rspec -Ispec spec/test_spec.rb spec/multiple_exception_spec.rb --format documentation
'

- name: Setup gem
id: setup-gem
if: inputs.alpine != 'true'
shell: bash
working-directory: ${{ github.action_path }}
run: |
Expand Down Expand Up @@ -89,6 +126,7 @@ runs:

- name: Run regular tests
id: run-regular-tests
if: inputs.alpine != 'true'
shell: bash
working-directory: ${{ github.action_path }}
run: |
Expand Down Expand Up @@ -117,6 +155,7 @@ runs:

- name: Run variant quarantine test without variant (should fail - not quarantined)
id: run-variant-test-no-variant
if: inputs.alpine != 'true'
shell: bash
working-directory: ${{ github.action_path }}
run: |
Expand All @@ -138,6 +177,7 @@ runs:

- name: Run variant quarantine test with variant (should pass - quarantined)
id: run-variant-test-with-variant
if: inputs.alpine != 'true'
shell: bash
working-directory: ${{ github.action_path }}
run: |
Expand All @@ -159,6 +199,7 @@ runs:

- name: Run quarantine lookup failure abort test (should fail fast, skip slow_test)
id: run-quarantine-abort-test
if: inputs.alpine != 'true'
shell: bash
working-directory: ${{ github.action_path }}
run: |
Expand All @@ -184,7 +225,7 @@ runs:

- name: Run knapsack_pro queue and verify a single local bundle
shell: bash
if: inputs.knapsack-pro-test-suite-token-rspec != ''
if: inputs.alpine != 'true' && inputs.knapsack-pro-test-suite-token-rspec != ''
working-directory: ${{ github.action_path }}
env:
KNAPSACK_PRO_TEST_DIR: spec
Expand Down
47 changes: 40 additions & 7 deletions .github/workflows/release_ruby_gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ jobs:
strategy:
matrix:
platform:
- x86_64-linux
- aarch64-linux
- x86_64-linux-gnu
- x86_64-linux-musl
- aarch64-linux-gnu
- aarch64-linux-musl
- arm64-darwin
- x86_64-darwin
- ruby
Expand Down Expand Up @@ -96,7 +98,7 @@ jobs:
with:
platform: ${{ matrix.platform }}
working-directory: rspec-trunk-flaky-tests
ruby-versions: 3.0,3.1,3.2,3.3,3.4,4.0
ruby-versions: 3.1,3.2,3.3,3.4,4.0

- name: Validate ruby platform gem
if: matrix.platform == 'ruby'
Expand All @@ -115,11 +117,11 @@ jobs:
needs: [ci-data, cross-gem]
strategy:
matrix:
ruby-version: ["3.0", "3.1", "3.2", "3.3", "3.4", "4.0"]
ruby-version: ["3.1", "3.2", "3.3", "3.4", "4.0"]
platform:
- name: x86_64-linux
- name: x86_64-linux-gnu
os: ubuntu-latest
- name: aarch64-linux
- name: aarch64-linux-gnu
os: ubuntu-24.04-arm
- name: arm64-darwin
os: macos-latest
Expand Down Expand Up @@ -154,9 +156,40 @@ jobs:
artifact-pattern: cross-gem-${{ matrix.platform.name }}
knapsack-pro-test-suite-token-rspec: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }}

# Validate the musl gems inside Alpine (ruby/setup-ruby has no Alpine support).
test-musl-gem:
name: Test ${{ matrix.platform.name }} gem on Alpine (ruby ${{ matrix.ruby-version }})
runs-on: ${{ matrix.platform.os }}
needs: cross-gem
strategy:
fail-fast: false
matrix:
ruby-version: ["3.4"]
platform:
- name: x86_64-linux-musl
os: ubuntu-latest
- name: aarch64-linux-musl
os: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4

- name: Test musl gem uploads → analytics-cli-ruby-gem (staging)
uses: ./.github/actions/test_ruby_gem_uploads
with:
alpine: "true"
ruby-version: ${{ matrix.ruby-version }}
trunk-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
trunk-public-api-address: https://api.trunk-staging.io
trunk-org-slug: trunk-staging-org
test-collection-id: T5yKSn9h
platform: ${{ matrix.platform.name }}
variant: ${{ matrix.platform.name }}
artifact-pattern: cross-gem-${{ matrix.platform.name }}
knapsack-pro-test-suite-token-rspec: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }}

publish_ruby_gem:
runs-on: ubuntu-latest
needs: test-ruby-gem
needs: [test-ruby-gem, test-musl-gem]
steps:
- uses: actions/checkout@v4

Expand Down
14 changes: 8 additions & 6 deletions rspec-trunk-flaky-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The gem includes a native Rust extension (`rspec_trunk_flaky_tests`) that provid

## Prerequisites

- Ruby 3.0 or later
- Ruby 3.1 or later
- Bundler
- Rust and Cargo (for building the native extension)
- `rb-sys` gem (installed automatically via dependencies)
Expand Down Expand Up @@ -57,13 +57,15 @@ The gem will be built and available in `pkg/`.
Build the native extension for a specific platform:

```bash
bundle exec rake native[x86_64-linux]
bundle exec rake native[x86_64-linux-gnu]
```

Supported platforms:

- `x86_64-linux`
- `aarch64-linux`
- `x86_64-linux-gnu`
- `x86_64-linux-musl` (Alpine and other musl-based distros)
- `aarch64-linux-gnu`
- `aarch64-linux-musl` (Alpine and other musl-based distros)
- `arm64-darwin`
- `x86_64-darwin`

Expand Down Expand Up @@ -249,8 +251,8 @@ To release a new version:
1. Trigger the workflow manually via GitHub Actions UI or API
2. Provide the release tag (version number) as input
3. The workflow will:
- Build the gem for all supported platforms (`x86_64-linux`, `aarch64-linux`, `arm64-darwin`, `x86_64-darwin`)
- Test the gem on all platforms with Ruby versions 3.0, 3.1, 3.2, 3.3, and 3.4
- Build the gem for all supported platforms (`x86_64-linux-gnu`, `x86_64-linux-musl`, `aarch64-linux-gnu`, `aarch64-linux-musl`, `arm64-darwin`, `x86_64-darwin`)
- Test the gem on all platforms with Ruby versions 3.1, 3.2, 3.3, 3.4, and 4.0
- Publish the gem to RubyGems if all tests pass

The workflow automatically handles cross-compilation, testing, and publishing for all supported platforms.
6 changes: 3 additions & 3 deletions rspec-trunk-flaky-tests/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ end
desc 'Build native extension for a provided platform'
task :native, [:platform] do |_t, platform:|
Dir.chdir '..' do
if platform == 'x86_64-linux'
sh 'bundle', 'exec', 'rb-sys-dock', '--platform', platform, '--build', '--directory', 'rspec-trunk-flaky-tests', '--ruby-versions', '3.0,3.1,3.2,3.3,3.4,4.0', '--', 'sudo yum install -y perl-IPC-Cmd'
if %w[x86_64-linux-gnu x86_64-linux].include?(platform)
sh 'bundle', 'exec', 'rb-sys-dock', '--platform', platform, '--build', '--directory', 'rspec-trunk-flaky-tests', '--ruby-versions', '3.1,3.2,3.3,3.4,4.0', '--', 'sudo yum install -y perl-IPC-Cmd'
else
sh 'bundle', 'exec', 'rb-sys-dock', '--platform', platform, '--build', '--directory', 'rspec-trunk-flaky-tests', '--ruby-versions', '3.0,3.1,3.2,3.3,3.4,4.0'
sh 'bundle', 'exec', 'rb-sys-dock', '--platform', platform, '--build', '--directory', 'rspec-trunk-flaky-tests', '--ruby-versions', '3.1,3.2,3.3,3.4,4.0'
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion rspec-trunk-flaky-tests/lib/rspec_trunk_flaky_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
this dependency. It does not include a precompiled native extension.

Precompiled native gems are available for:
x86_64-linux, aarch64-linux, arm64-darwin, x86_64-darwin
x86_64-linux-gnu, x86_64-linux-musl, aarch64-linux-gnu,
aarch64-linux-musl, arm64-darwin, x86_64-darwin

If you are on a supported platform and seeing this error, make sure
bundler is selecting the native variant for your platform:
Expand Down
2 changes: 1 addition & 1 deletion rspec-trunk-flaky-tests/rspec_trunk_flaky_tests.gemspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

Gem::Specification.new do |s|
# trunk-ignore(rubocop/Gemspec/RequiredRubyVersion)

Check notice on line 4 in rspec-trunk-flaky-tests/rspec_trunk_flaky_tests.gemspec

View workflow job for this annotation

GitHub Actions / Trunk Check

trunk(ignore-does-nothing)

[new] trunk-ignore(rubocop/Gemspec/RequiredRubyVersion) is not suppressing a lint issue
s.required_ruby_version = '>= 3.0'
s.required_ruby_version = '>= 3.1'
s.name = 'rspec_trunk_flaky_tests'
s.version = '0.0.0'
# trunk-ignore(rubocop/Layout/LineLength)
Expand Down
Loading