diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3ccf0cf..a1101e9 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -60,3 +60,9 @@ jobs: token: ${{ secrets.PUSH_TO_PROTECTED_BRANCH }} branch: ${{ steps.vars.outputs.stage }} unprotect_reviews: true + + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 819051a..d9dba7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 with: @@ -20,6 +21,7 @@ jobs: - name: Install dependencies run: yarn + - name: Lint run: yarn lint @@ -29,12 +31,8 @@ jobs: - name: Build run: yarn build:prod - # - name: SonarCloud Scan - # uses: sonarsource/sonarcloud-github-action@master - # with: - # args: > - # -Dsonar.organization=${{ secrets.SONAR_ORG}} - # -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY}} - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: Upload code coverage + uses: actions/upload-artifact@v2 + with: + name: coverage + path: coverage/lcov.info diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml new file mode 100644 index 0000000..82b5592 --- /dev/null +++ b/.github/workflows/sonar.yml @@ -0,0 +1,26 @@ +name: SonarQube Analysis +on: + workflow_run: + workflows: [React Template CI] + types: [completed] + +jobs: + sonar-analysis: + name: SonarQube Analysis + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download code coverage artifact + uses: actions/download-artifact@v2 + with: + name: coverage + path: coverage/lcov.info + + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index be5168c..4cde920 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,11 +1,11 @@ sonar.organization=wednesday-solutions -sonar.projectKey=wednesday-solutions_react-template +sonar.projectKey=wednesday-solutions_react-graphql-ts-template_AY7GxkO6B2n8RRmGoU1i -sonar.language=js +sonar.language=ts sonar.sources=. sonar.tests=app sonar.exclusions=*./.storybook,*./internals,*./server -sonar.test.inclusions=**/*.test.js +sonar.test.inclusions=**/*.test.ts sonar.javascript.lcov.reportPaths=./coverage/lcov.info sonar.testExecutionReportPaths=./reports/test-report.xml sonar.sourceEncoding=UTF-8 \ No newline at end of file