From 9e4d4dc5c2ae818f5396c33cd7bb41337b8428be Mon Sep 17 00:00:00 2001 From: getlarge Date: Mon, 10 Mar 2025 20:27:35 +0100 Subject: [PATCH 1/4] ci: enhance CI workflow with SonarCloud scan and concurrency settings --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++ .github/workflows/sonar-project.properties | 11 +++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/sonar-project.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fe9b70..3bd907e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,10 @@ permissions: actions: read contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-ci + cancel-in-progress: true + jobs: main: runs-on: ubuntu-latest @@ -31,6 +35,12 @@ jobs: - run: npx nx format:check - run: npx nx affected -t lint test build + - name: Upload coverage reports + uses: actions/upload-artifact@v4 + with: + name: coverage + path: coverage + e2e: needs: main strategy: @@ -53,3 +63,44 @@ jobs: - uses: nrwl/nx-set-shas@v4 - run: npx nx affected:e2e + + scan: + needs: [main, e2e] + runs-on: ubuntu-latest + timeout-minutes: 10 + + strategy: + matrix: + node-version: [22.x] + + steps: + - name: Check out repository code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Get current version + id: package-version + uses: martinbeentjes/npm-get-version-action@main + with: + path: nx-node-sea/package.json + + - name: Retrieve coverage + uses: actions/download-artifact@v4 + with: + name: coverage-${{ matrix.node-version }} + path: ./coverage + + - name: SonarCloud Scan + uses: SonarSource/sonarqube-scan-action@v5.0.0 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: https://sonarcloud.io + with: + args: > + -Dsonar.projectVersion=${{ steps.package-version.outputs.current-version }} diff --git a/.github/workflows/sonar-project.properties b/.github/workflows/sonar-project.properties new file mode 100644 index 0000000..3015787 --- /dev/null +++ b/.github/workflows/sonar-project.properties @@ -0,0 +1,11 @@ +sonar.organization=getlarge +sonar.projectKey=getlarge_nx-node-sea +sonar.projectName=nx-node-sea +sonar.language=ts +sonar.sourceEncoding=UTF-8 +sonar.sources=packages +sonar.test=packages +sonar.inclusions=packages/**/*.ts +sonar.test.inclusions=packages/**/test/*.spec.ts,packages/**/test/*.e2e-spec.ts +sonar.exclusions=packages/**/dist/*,packages/**/node_modules/*, +sonar.javascript.lcov.reportPaths=coverage/packages/**/lcov.info From f45dc204c17f6843c1a822c3053360c28919173e Mon Sep 17 00:00:00 2001 From: getlarge Date: Mon, 10 Mar 2025 20:47:51 +0100 Subject: [PATCH 2/4] ci: comment out coverage report upload and retrieval steps in CI workflow --- .github/workflows/ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bd907e..31342b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,11 +35,11 @@ jobs: - run: npx nx format:check - run: npx nx affected -t lint test build - - name: Upload coverage reports - uses: actions/upload-artifact@v4 - with: - name: coverage - path: coverage + # - name: Upload coverage reports + # uses: actions/upload-artifact@v4 + # with: + # name: coverage + # path: coverage e2e: needs: main @@ -90,11 +90,11 @@ jobs: with: path: nx-node-sea/package.json - - name: Retrieve coverage - uses: actions/download-artifact@v4 - with: - name: coverage-${{ matrix.node-version }} - path: ./coverage + # - name: Retrieve coverage + # uses: actions/download-artifact@v4 + # with: + # name: coverage-${{ matrix.node-version }} + # path: ./coverage - name: SonarCloud Scan uses: SonarSource/sonarqube-scan-action@v5.0.0 From d93656b07c0dc80d61e45c695e43cfa3a21b61e4 Mon Sep 17 00:00:00 2001 From: getlarge Date: Mon, 10 Mar 2025 20:59:10 +0100 Subject: [PATCH 3/4] ci: add SonarQube configuration for project analysis --- sonar-project.properties | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..3015787 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,11 @@ +sonar.organization=getlarge +sonar.projectKey=getlarge_nx-node-sea +sonar.projectName=nx-node-sea +sonar.language=ts +sonar.sourceEncoding=UTF-8 +sonar.sources=packages +sonar.test=packages +sonar.inclusions=packages/**/*.ts +sonar.test.inclusions=packages/**/test/*.spec.ts,packages/**/test/*.e2e-spec.ts +sonar.exclusions=packages/**/dist/*,packages/**/node_modules/*, +sonar.javascript.lcov.reportPaths=coverage/packages/**/lcov.info From 19fafca5300ca4342532300dd395ddb05d495e01 Mon Sep 17 00:00:00 2001 From: getlarge Date: Mon, 10 Mar 2025 21:32:26 +0100 Subject: [PATCH 4/4] ci: use sonar scan automatic analysis --- .github/workflows/ci.yml | 41 ---------------------- .github/workflows/sonar-project.properties | 11 ------ 2 files changed, 52 deletions(-) delete mode 100644 .github/workflows/sonar-project.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 31342b6..4bcce2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,44 +63,3 @@ jobs: - uses: nrwl/nx-set-shas@v4 - run: npx nx affected:e2e - - scan: - needs: [main, e2e] - runs-on: ubuntu-latest - timeout-minutes: 10 - - strategy: - matrix: - node-version: [22.x] - - steps: - - name: Check out repository code - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - - name: Get current version - id: package-version - uses: martinbeentjes/npm-get-version-action@main - with: - path: nx-node-sea/package.json - - # - name: Retrieve coverage - # uses: actions/download-artifact@v4 - # with: - # name: coverage-${{ matrix.node-version }} - # path: ./coverage - - - name: SonarCloud Scan - uses: SonarSource/sonarqube-scan-action@v5.0.0 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: https://sonarcloud.io - with: - args: > - -Dsonar.projectVersion=${{ steps.package-version.outputs.current-version }} diff --git a/.github/workflows/sonar-project.properties b/.github/workflows/sonar-project.properties deleted file mode 100644 index 3015787..0000000 --- a/.github/workflows/sonar-project.properties +++ /dev/null @@ -1,11 +0,0 @@ -sonar.organization=getlarge -sonar.projectKey=getlarge_nx-node-sea -sonar.projectName=nx-node-sea -sonar.language=ts -sonar.sourceEncoding=UTF-8 -sonar.sources=packages -sonar.test=packages -sonar.inclusions=packages/**/*.ts -sonar.test.inclusions=packages/**/test/*.spec.ts,packages/**/test/*.e2e-spec.ts -sonar.exclusions=packages/**/dist/*,packages/**/node_modules/*, -sonar.javascript.lcov.reportPaths=coverage/packages/**/lcov.info