From 4a381c155a8473428ed5a078c112e503c4539a69 Mon Sep 17 00:00:00 2001 From: Luciano Caravajal Date: Thu, 4 Aug 2022 16:14:14 -0300 Subject: [PATCH 1/5] Add sonar to ci-cd pipeline --- .github/workflows/ci-cd.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 86739af..797cb96 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -72,3 +72,33 @@ jobs: SOURCE_DIR: ./umd DEST_DIR: sdk ARGS: --acl public-read --follow-symlinks --cache-control max-age=31536000,public + + - name: SonarQube Scan (Push) + if: github.event_name == 'push' + uses: SonarSource/sonarcloud-github-action@v1.5 + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_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 }}" + - name: SonarQube Scan (Pull Request) + if: github.event_name == 'pull_request' + uses: SonarSource/sonarcloud-github-action@v1.5 + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_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.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 }} From 6903c1f05fdf1bf379b722f703295efcc072db45 Mon Sep 17 00:00:00 2001 From: Luciano Caravajal Date: Thu, 4 Aug 2022 18:10:43 -0300 Subject: [PATCH 2/5] Moved sonar to a different workflow --- .github/workflows/ci-cd.yml | 30 -------------- .github/workflows/sonar-scan.yml | 69 ++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/sonar-scan.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 797cb96..86739af 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -72,33 +72,3 @@ jobs: SOURCE_DIR: ./umd DEST_DIR: sdk ARGS: --acl public-read --follow-symlinks --cache-control max-age=31536000,public - - - name: SonarQube Scan (Push) - if: github.event_name == 'push' - uses: SonarSource/sonarcloud-github-action@v1.5 - env: - SONAR_TOKEN: ${{ secrets.SONARQUBE_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 }}" - - name: SonarQube Scan (Pull Request) - if: github.event_name == 'pull_request' - uses: SonarSource/sonarcloud-github-action@v1.5 - env: - SONAR_TOKEN: ${{ secrets.SONARQUBE_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.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 }} diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml new file mode 100644 index 0000000..623542f --- /dev/null +++ b/.github/workflows/sonar-scan.yml @@ -0,0 +1,69 @@ +name: ci-cd +on: + pull_request: + branches: + - main + - development + push: + branches: + - main + - development + +permissions: + contents: read + id-token: write + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up nodejs + uses: actions/setup-node@v2 + with: + node-version: '14' + cache: 'npm' + + - name: npm CI + run: npm ci + + - name: npm Check + run: npm run check + + - name: npm Build + run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") BUILD_COMMIT=${{ github.sha }} npm run build + + - name: SonarQube Scan (Push) + if: github.event_name == 'push' + uses: SonarSource/sonarcloud-github-action@v1.6 + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_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 }}" + - name: SonarQube Scan (Pull Request) + if: github.event_name == 'pull_request' + uses: SonarSource/sonarcloud-github-action@v1.5 + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_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.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 }} From 5f22d72d289092b1feb54749ea5e5628502820b2 Mon Sep 17 00:00:00 2001 From: Luciano Caravajal Date: Thu, 4 Aug 2022 18:12:10 -0300 Subject: [PATCH 3/5] Rename sonar workflow --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 623542f..7180a9e 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -1,4 +1,4 @@ -name: ci-cd +name: sonar-scan on: pull_request: branches: From 220499c2b0c2c0c7b9e67e560eba48f125eac94f Mon Sep 17 00:00:00 2001 From: Luciano Caravajal Date: Thu, 4 Aug 2022 18:37:37 -0300 Subject: [PATCH 4/5] Removed not required permissions --- .github/workflows/sonar-scan.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 7180a9e..3354a30 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -9,10 +9,6 @@ on: - main - development -permissions: - contents: read - id-token: write - jobs: build: name: Build From e2f499d9f51d076d0343151d4f5de88dd80da227 Mon Sep 17 00:00:00 2001 From: Luciano Caravajal Date: Thu, 4 Aug 2022 18:52:34 -0300 Subject: [PATCH 5/5] Update sonar github version --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 3354a30..7e428af 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -49,7 +49,7 @@ jobs: -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}" - name: SonarQube Scan (Pull Request) if: github.event_name == 'pull_request' - uses: SonarSource/sonarcloud-github-action@v1.5 + uses: SonarSource/sonarcloud-github-action@v1.6 env: SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} with: