diff --git a/.github/workflows/database-e2e.sh b/.github/workflows/database-e2e.sh index 5bdb397e..4249d0ba 100755 --- a/.github/workflows/database-e2e.sh +++ b/.github/workflows/database-e2e.sh @@ -61,7 +61,17 @@ if [ "$JRUBY" = "true" ]; then fi cd testapp -bundle install + +# Retry, since on JRuby some gems fetch their jars from Maven Central during install, which CI +# can't always reach. +for attempt in 1 2 3; do + bundle install && break + if [ "$attempt" -eq 3 ]; then + exit 1 + fi + echo "bundle install failed (attempt $attempt of 3), retrying" + sleep 10 +done # Create database bundle exec hanami db create | tee create.log diff --git a/.github/workflows/database-e2e.yml b/.github/workflows/database-e2e.yml index 6c6e8ae3..8ba9f055 100644 --- a/.github/workflows/database-e2e.yml +++ b/.github/workflows/database-e2e.yml @@ -136,9 +136,28 @@ jobs: ;; esac - name: Set up Ruby - uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # zizmor: ignore[cache-poisoning] + uses: ruby/setup-ruby@20eb24b0d509e2b9ed9b6d42ddfeb992915e0564 # v1.341.0 # zizmor: ignore[cache-poisoning] with: - ruby-version: ${{ matrix.ruby }} + # JRuby 10.1.3.0 drops keyword arguments forwarded through `initialize(...)` between two + # prepended ruby2_keywords initializers, which breaks the DB provider. Unpin once + # https://github.com/jruby/jruby/issues/10026 is fixed. + ruby-version: ${{ matrix.ruby == 'jruby' && 'jruby-10.1.2.0' || matrix.ruby }} bundler-cache: true + # On JRuby, installing some gems (such as rbs) fetches their jars from Maven Central, which CI + # can't always reach. The jars are kept in the local Maven repository, so restoring it lets + # most runs skip the fetch. + - name: Restore Maven repository + if: matrix.ruby == 'jruby' + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ~/.m2/repository + key: maven-jruby-${{ matrix.db }}-${{ github.run_id }} + restore-keys: maven-jruby-${{ matrix.db }}- - name: Run database E2E script run: bash .github/workflows/database-e2e.sh + - name: Save Maven repository + if: matrix.ruby == 'jruby' && hashFiles('testapp/Gemfile.lock') != '' + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ~/.m2/repository + key: maven-jruby-${{ matrix.db }}-${{ hashFiles('testapp/Gemfile.lock') }}