From 8f178499e9558ed5889f1cfbdfe676e913ed6222 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Mon, 14 Apr 2025 12:16:13 +0200 Subject: [PATCH 1/3] Run internal investigation once Makes it so that the main matrix only runs a single task --- .github/workflows/linting.yml | 12 ++++++++++++ .github/workflows/main.yml | 7 ++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 9876c082e..d977fad70 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -5,6 +5,17 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: + internal_investigation: + runs-on: ubuntu-latest + name: Internal Investigation + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby # Latest stable CRuby version + bundler-cache: true + - run: bundle exec rake internal_investigation + yamllint: name: Yamllint runs-on: ubuntu-latest @@ -18,6 +29,7 @@ jobs: yamllint_comment: true env: GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + mdformat: name: Mdformat runs-on: ubuntu-latest diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 88f234e1c..a74b15994 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,17 +35,14 @@ jobs: - "3.4" - ruby-head - jruby-9.4 - task: - - internal_investigation - - spec - name: "Ruby ${{ matrix.ruby }}: ${{ matrix.task }}" + name: "Ruby ${{ matrix.ruby }} - Spec" steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: "${{ matrix.ruby }}" bundler-cache: true - - run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }} + - run: NO_COVERAGE=true bundle exec rake spec coverage: runs-on: ubuntu-latest From c7a53929c5b588342d443927d8659d5791276e9c Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Mon, 14 Apr 2025 12:22:13 +0200 Subject: [PATCH 2/3] Move prism to the main workflow matrix rubocop-ast depends on prism, so no need to add it to the gemfile anymore --- .github/workflows/main.yml | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a74b15994..46563e225 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,7 +35,12 @@ jobs: - "3.4" - ruby-head - jruby-9.4 - name: "Ruby ${{ matrix.ruby }} - Spec" + parser_engine: + - parser_whitequark + include: + - ruby: "2.7" # Minimum version required for Prism to run. + parser_engine: parser_prism + name: "Ruby ${{ matrix.ruby }} - Spec (${{ matrix.parser_engine }})" steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 @@ -43,6 +48,8 @@ jobs: ruby-version: "${{ matrix.ruby }}" bundler-cache: true - run: NO_COVERAGE=true bundle exec rake spec + env: + PARSER_ENGINE: ${{ matrix.parser_engine }} coverage: runs-on: ubuntu-latest @@ -119,24 +126,3 @@ jobs: ruby-version: "3.4" bundler-cache: true - run: NO_COVERAGE=true bundle exec rake spec - - prism: - runs-on: ubuntu-latest - name: Prism - steps: - - uses: actions/checkout@v4 - - name: Use prism parser - run: | - cat << EOF > Gemfile.local - gem 'prism' - EOF - - name: set up Ruby - uses: ruby/setup-ruby@v1 - with: - # Specify the minimum Ruby version 2.7 required for Prism to run. - ruby-version: "2.7" - bundler-cache: true - - env: - NO_COVERAGE: true - PARSER_ENGINE: parser_prism - run: bundle exec rake spec From 4f918942c0bb43974b05fa2c3bd3906b690ceff7 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Mon, 14 Apr 2025 13:53:30 +0200 Subject: [PATCH 3/3] Merge coverage results parser and prism will differ in what they do, so merge them together. jruby doesn't seem to support coverage (maybe jruby bug?): > KeyError: key not found: :branch --- .github/workflows/main.yml | 21 +++++++++++++++++---- spec/spec_helper.rb | 2 +- tasks/coverage.rake | 10 ++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 tasks/coverage.rake diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46563e225..7265c67ec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,20 +47,33 @@ jobs: with: ruby-version: "${{ matrix.ruby }}" bundler-cache: true - - run: NO_COVERAGE=true bundle exec rake spec + - run: bundle exec rake spec env: PARSER_ENGINE: ${{ matrix.parser_engine }} + - name: Upload Coverage Artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-ubuntu-${{ matrix.ruby }}-${{ matrix.parser_engine }} + path: coverage/.resultset.json + include-hidden-files: true coverage: + name: Check Coverage + needs: main runs-on: ubuntu-latest - name: "Test coverage" + steps: - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + name: Download Coverage Artifacts + with: + pattern: coverage-* - uses: ruby/setup-ruby@v1 with: - ruby-version: "3.4" + ruby-version: ruby # Latest stable CRuby version bundler-cache: true - - run: bundle exec rake spec + + - run: bundle exec rake coverage:ci edge-rubocop: runs-on: ubuntu-latest diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b39d1e6fe..d3d11d700 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,7 @@ require 'rubocop' require 'rubocop/rspec/support' -require 'simplecov' unless ENV['NO_COVERAGE'] +require 'simplecov' unless ENV['NO_COVERAGE'] || RUBY_ENGINE == 'jruby' module SpecHelper ROOT = Pathname.new(__dir__).parent.freeze diff --git a/tasks/coverage.rake b/tasks/coverage.rake new file mode 100644 index 000000000..36b43e5f9 --- /dev/null +++ b/tasks/coverage.rake @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +namespace :coverage do + desc 'Report Coverage from merged CI runs' + task :ci do + require 'simplecov' + + SimpleCov.collate Dir['coverage-*/.resultset.json'] + end +end