name: jruby-bundler

on:
  pull_request:

  push:
    branches:
      - 3.5

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

permissions:  # added using https://github.com/step-security/secure-workflows
  contents: read

defaults:
  run:
    shell: bash

jobs:
  jruby_bundler:
    name: Bundler on JRuby (${{ matrix.os.name }})
    runs-on: ${{ matrix.os.value }}

    env:
      RGV: ..

    strategy:
      fail-fast: false
      matrix:
        os:
          - { name: Ubuntu, value: ubuntu-24.04 }
          - { name: Windows, value: windows-2022 }

    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
      - name: Setup ruby
        uses: ruby/setup-ruby@7d3497fd78c07c0d84ebafa58d8dac60cd1f0763 # v1.199.0
        with:
          ruby-version: jruby-9.4.8.0
          bundler: none
      - name: Setup java
        uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
        with:
          distribution: temurin
          java-version: 19.0.2
        if: matrix.os.name != 'Ubuntu'
      - name: Prepare dependencies
        run: |
          bin/rake spec:parallel_deps
      - name: Run Test
        run: |
          bin/parallel_rspec --tag jruby_only --tag jruby
        working-directory: ./bundler
        if: matrix.os.name == 'Ubuntu'
      - name: Install local bundler
        run: |
          bin/rake bundler:install:local
        if: matrix.os.name == 'Ubuntu'
      - name: Run a warbler project
        run: |
          cd bundler/spec/realworld/fixtures/warbler
          bundle install
          bundle exec warble
          java -jar warbler.jar
        if: matrix.os.name == 'Ubuntu'
