diff --git a/.github/actions/test_ruby_gem_uploads/action.yaml b/.github/actions/test_ruby_gem_uploads/action.yaml index cdf20610..0eebc62d 100644 --- a/.github/actions/test_ruby_gem_uploads/action.yaml +++ b/.github/actions/test_ruby_gem_uploads/action.yaml @@ -41,6 +41,10 @@ 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 @@ -48,6 +52,7 @@ runs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 + if: inputs.alpine != 'true' with: ruby-version: ${{ inputs.ruby-version }} bundler-cache: true @@ -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: | @@ -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: | @@ -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: | @@ -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: | @@ -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: | @@ -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 diff --git a/.github/workflows/release_ruby_gem.yml b/.github/workflows/release_ruby_gem.yml index 41cf199b..cf9714db 100644 --- a/.github/workflows/release_ruby_gem.yml +++ b/.github/workflows/release_ruby_gem.yml @@ -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 @@ -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' @@ -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 @@ -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 diff --git a/rspec-trunk-flaky-tests/README.md b/rspec-trunk-flaky-tests/README.md index 9b54cbb8..9729f67f 100644 --- a/rspec-trunk-flaky-tests/README.md +++ b/rspec-trunk-flaky-tests/README.md @@ -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) @@ -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` @@ -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. diff --git a/rspec-trunk-flaky-tests/Rakefile b/rspec-trunk-flaky-tests/Rakefile index ee7bc4ce..004f2b82 100644 --- a/rspec-trunk-flaky-tests/Rakefile +++ b/rspec-trunk-flaky-tests/Rakefile @@ -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 diff --git a/rspec-trunk-flaky-tests/lib/rspec_trunk_flaky_tests.rb b/rspec-trunk-flaky-tests/lib/rspec_trunk_flaky_tests.rb index 2cfb671b..a8e053ba 100644 --- a/rspec-trunk-flaky-tests/lib/rspec_trunk_flaky_tests.rb +++ b/rspec-trunk-flaky-tests/lib/rspec_trunk_flaky_tests.rb @@ -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: diff --git a/rspec-trunk-flaky-tests/rspec_trunk_flaky_tests.gemspec b/rspec-trunk-flaky-tests/rspec_trunk_flaky_tests.gemspec index 7a7cce90..c4cc2ed9 100644 --- a/rspec-trunk-flaky-tests/rspec_trunk_flaky_tests.gemspec +++ b/rspec-trunk-flaky-tests/rspec_trunk_flaky_tests.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| # trunk-ignore(rubocop/Gemspec/RequiredRubyVersion) - 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)