n13org/jekyll-kw-stackexchange

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
name: CI
on: 
  push:
    branches:
      - "*"
    tags-ignore:
      - "*"
  pull_request:
    branches:
      - "*"
    tags-ignore:
      - "*"
jobs:  
  # pre-build:
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@v2
  #     - name: Set up Ruby 3.1
  #       uses: actions/setup-ruby@v1
  #       with:
  #         ruby-version: 3.1
  #     - name: bundle install
  #       run: |
  #         gem install bundler
  #         bundle install --jobs 4 --retry 3
  build:
    # needs: pre-build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - name: Set up Ruby 3.1
      uses: actions/setup-ruby@v1
      with:
        ruby-version: 3.1
    - name: bundle install
      run: |
        gem install bundler
        bundle install --jobs 4 --retry 3
    - name: Run Test
      run: bundle exec rake test
    # - uses: actions/checkout@v2
    #   with:
    #     fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
    # https://community.sonarsource.com/t/sonarcloud-ruby-coverage-not-working/39985/7
    - 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
      # with: 
      #   projectBaseDir: ${GITHUB_WORKSPACE}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}