philnash/bitly

View on GitHub
.github/workflows/sonarcloud.yml

Summary

Maintainability
Test Coverage
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened]
name: SonarCloud Analysis
jobs:
  sonarcloud:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          # Disabling shallow clone is recommended for improving relevancy of reporting
          fetch-depth: 0
      - name: Set up Ruby ${{ matrix.ruby }}
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.1"
      - name: "Install dependencies"
        run: bundle install
      - name: Run tests for coverage
        run: bundle exec rspec
        env:
          COVERAGE: json
      - name: fix code coverage paths
        working-directory: ./coverage
        run: |
          sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.json
      - name: SonarCloud Scan
        uses: sonarsource/sonarcloud-github-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}