Merge pull request #866 from varvet/kbs/add-rubocop-back #269
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Main | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| # `github.ref` points to the *merge commit* when running tests on a pull request, which will be a commit | |
| # that doesn't exists in our code base. Since this workflow triggers from a PR, we use the HEAD SHA instead. | |
| # | |
| # NOTE: These both used to be used by Code Climate (cc-test-reporter), superseded by qlty.sh | |
| GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
| GIT_BRANCH: ${{ github.head_ref }} | |
| jobs: | |
| matrix-test: | |
| runs-on: ubuntu-latest | |
| continue-on-error: ${{ matrix.allow-failure || false }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ruby-version: | |
| - "3.2" | |
| - "3.3" | |
| - "3.4" | |
| - "jruby-9.3.15" | |
| - "jruby" | |
| include: # HEAD-versions | |
| - ruby-version: "head" | |
| allow-failure: true | |
| - ruby-version: "jruby-head" | |
| allow-failure: true | |
| - ruby-version: "truffleruby-head" | |
| allow-failure: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| rubygems: latest | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| - name: Run tests | |
| run: bundle exec rspec | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| rubygems: latest | |
| ruby-version: "ruby" | |
| bundler-cache: true | |
| - name: Run tests | |
| run: bundle exec rspec | |
| env: | |
| COVERAGE: 1 | |
| - name: Upload coverage results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| include-hidden-files: true | |
| name: coverage-results | |
| path: coverage | |
| retention-days: 1 | |
| coverage-upload: | |
| permissions: | |
| id-token: write # Required for OIDC | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download coverage results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: coverage-results | |
| path: coverage | |
| - name: Upload code coverage to qlty.sh | |
| uses: qltysh/qlty-action/coverage@v2 | |
| with: | |
| oidc: true | |
| format: simplecov | |
| files: coverage/.resultset.json | |
| coverage-check: | |
| permissions: | |
| contents: read | |
| checks: write | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download coverage results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: coverage-results | |
| path: coverage | |
| - uses: joshmfrankel/simplecov-check-action@be89e11889202cc59efb14aab2a7091622fa9aad | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| minimum_suite_coverage: 100 | |
| minimum_file_coverage: 100 | |
| coverage_json_path: coverage/simplecov-check-action.json | |
| rubocop: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| rubygems: default | |
| ruby-version: "ruby" | |
| bundler-cache: false | |
| - run: bundle install | |
| - name: Run RuboCop | |
| run: bundle exec rubocop | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| rubygems: default | |
| ruby-version: "ruby" | |
| bundler-cache: false | |
| - run: bundle install | |
| - run: rake yard | |
| required-checks: | |
| runs-on: ubuntu-latest | |
| if: ${{ always() }} | |
| needs: | |
| - test | |
| - matrix-test | |
| - docs | |
| - rubocop | |
| steps: | |
| - name: failure | |
| if: ${{ failure() || contains(needs.*.result, 'failure') }} | |
| run: exit 1 | |
| - name: success | |
| run: exit 0 |