From 9bcd257d62d565138821aea4b23c98ec43e5f2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Daniel=20Fad=C3=B3n?= Date: Wed, 5 Apr 2023 11:11:29 -0300 Subject: [PATCH] Simplify sonarqube workflow --- .github/workflows/{ci-cd.yml => ci.yml} | 49 +++++++++-------------- .github/workflows/update-license-year.yml | 2 +- .gitignore | 1 + sonar-project.properties | 9 +++++ 4 files changed, 31 insertions(+), 30 deletions(-) rename .github/workflows/{ci-cd.yml => ci.yml} (67%) create mode 100644 sonar-project.properties diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci.yml similarity index 67% rename from .github/workflows/ci-cd.yml rename to .github/workflows/ci.yml index 2269d28..c6a4fe1 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci.yml @@ -1,15 +1,16 @@ -name: ci-cd +name: ci + on: + push: + branches: + - '**' pull_request: branches: - master - development - push: - branches: - - '*' concurrency: - group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.run_number || github.event.pull_request.number }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} cancel-in-progress: true permissions: @@ -44,41 +45,39 @@ jobs: - name: npm build run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") BUILD_COMMIT=${{ github.sha }} npm run build + - name: Set VERSION env + run: echo "VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV + - name: SonarQube Scan (Push) - if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master') }} - uses: SonarSource/sonarcloud-github-action@v1.8 + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development') + uses: SonarSource/sonarcloud-github-action@v1.9 env: SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: projectBaseDir: . args: > -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} - -Dsonar.projectName=${{ github.event.repository.name }} - -Dsonar.projectKey=${{ github.event.repository.name }} - -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info - -Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions" - -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}" + -Dsonar.projectVersion=${{ env.VERSION }} + -Dsonar.branch.name=${{ github.ref_name }} - name: SonarQube Scan (Pull Request) if: github.event_name == 'pull_request' - uses: SonarSource/sonarcloud-github-action@v1.8 + uses: SonarSource/sonarcloud-github-action@v1.9 env: SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: projectBaseDir: . args: > -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} - -Dsonar.projectName=${{ github.event.repository.name }} - -Dsonar.projectKey=${{ github.event.repository.name }} - -Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions" - -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}" - -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info + -Dsonar.projectVersion=${{ env.VERSION }} -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} -Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }} - name: Store assets - if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master') }} + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development') uses: actions/upload-artifact@v3 with: name: assets @@ -89,19 +88,15 @@ jobs: name: Upload assets runs-on: ubuntu-latest needs: build - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }} + if: github.event_name == 'push' && github.ref == 'refs/heads/development' strategy: matrix: environment: - stage - #- stage-eu include: - environment: stage account_id: "079419646996" bucket: split-public-stage - # - environment: stage-eu - # account_id: "901851837056" - # bucket: split-public-stage-eu-west-1 steps: - name: Download assets @@ -132,19 +127,15 @@ jobs: name: Upload assets runs-on: ubuntu-latest needs: build - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + if: github.event_name == 'push' && github.ref == 'refs/heads/master' strategy: matrix: environment: - prod - #- prod-eu include: - environment: prod account_id: "825951051969" bucket: split-public - # - environment: prod-eu - # account_id: "842946900133" - # bucket: split-public-eu-west-1 steps: - name: Download assets diff --git a/.github/workflows/update-license-year.yml b/.github/workflows/update-license-year.yml index 9e58254..13aaac8 100644 --- a/.github/workflows/update-license-year.yml +++ b/.github/workflows/update-license-year.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 diff --git a/.gitignore b/.gitignore index 8e9b3d9..568cd2b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /es /umd /coverage +.scannerwork diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..48fa58f --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,9 @@ +sonar.projectName=react-client +sonar.projectKey=react-client +sonar.sources=src +sonar.inclusions=**/*.ts,**/*.tsx +sonar.tests=src +sonar.test.inclusions=**/*.test.ts,**/*.test.tsx +sonar.javascript.lcov.reportPaths=coverage/lcov.info +sonar.links.ci=https://github.com/splitio/react-client +sonar.links.scm=https://github.com/splitio/react-client/actions