|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - master |
| 5 | + pull_request: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + services: |
| 13 | + redis: |
| 14 | + image: redis |
| 15 | + ports: |
| 16 | + - 6379:6379 |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v2 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Set up Ruby |
| 24 | + uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6 |
| 25 | + with: |
| 26 | + ruby-version: 2.5 |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: bundle install |
| 30 | + |
| 31 | + - name: Run tests |
| 32 | + run: bundle exec rake |
| 33 | + |
| 34 | + - name: Fix code coverage paths |
| 35 | + working-directory: ./coverage |
| 36 | + run: | |
| 37 | + sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' .resultset.json |
| 38 | + ruby -rjson -e 'sqube = JSON.load(File.read(".resultset.json"))["RSpec"]["coverage"].transform_values {|lines| lines["lines"]}; total = { "RSpec" => { "coverage" => sqube, "timestamp" => Time.now.to_i }}; puts JSON.dump(total)' > .resultset.sonarqube.json |
| 39 | +
|
| 40 | +
|
| 41 | + - name: SonarQube Scan (Push) |
| 42 | + if: github.event_name == 'push' |
| 43 | + uses: SonarSource/sonarcloud-github-action@v1.5 |
| 44 | + env: |
| 45 | + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} |
| 46 | + with: |
| 47 | + projectBaseDir: . |
| 48 | + args: > |
| 49 | + -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} |
| 50 | + -Dsonar.projectName=${{ github.event.repository.name }} |
| 51 | + -Dsonar.projectKey=${{ github.event.repository.name }} |
| 52 | + -Dsonar.ruby.coverage.reportPaths=coverage/.resultset.sonarqube.json |
| 53 | + -Dsonar.c.file.suffixes=- |
| 54 | + -Dsonar.cpp.file.suffixes=- |
| 55 | + -Dsonar.objc.file.suffixes=- |
| 56 | + -Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions" |
| 57 | + -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}" |
| 58 | +
|
| 59 | + - name: SonarQube Scan (Pull Request) |
| 60 | + if: github.event_name == 'pull_request' |
| 61 | + uses: SonarSource/sonarcloud-github-action@v1.5 |
| 62 | + env: |
| 63 | + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} |
| 64 | + with: |
| 65 | + projectBaseDir: . |
| 66 | + args: > |
| 67 | + -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} |
| 68 | + -Dsonar.projectName=${{ github.event.repository.name }} |
| 69 | + -Dsonar.projectKey=${{ github.event.repository.name }} |
| 70 | + -Dsonar.ruby.coverage.reportPaths=coverage/.resultset.sonarqube.json |
| 71 | + -Dsonar.c.file.suffixes=- |
| 72 | + -Dsonar.cpp.file.suffixes=- |
| 73 | + -Dsonar.objc.file.suffixes=- |
| 74 | + -Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions" |
| 75 | + -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}" |
| 76 | + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} |
| 77 | + -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} |
| 78 | + -Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }} |
0 commit comments