diff --git a/.github/workflows/test-resources-pull-request.yml b/.github/workflows/test-resources-pull-request.yml index f064f9eb..42766d86 100644 --- a/.github/workflows/test-resources-pull-request.yml +++ b/.github/workflows/test-resources-pull-request.yml @@ -51,3 +51,20 @@ jobs: - name: Validate SAM template run: sam validate --lint + + - name: Run SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@383f7e52eae3ab0510c3cb0e7d9d150bbaeab838 # master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + projectBaseDir: test-resources + + - name: Run SonarQube Quality Gate check + uses: Sonarsource/sonarqube-quality-gate-action@8406f4f1edaffef38e9fb9c53eb292fc1d7684fa # master + # Force to fail step after specific time + timeout-minutes: 5 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + scanMetadataReportFile: test-resources/.scannerwork/report-task.txt diff --git a/test-resources/package.json b/test-resources/package.json index 3eb82e0d..53633217 100644 --- a/test-resources/package.json +++ b/test-resources/package.json @@ -8,7 +8,7 @@ "deploy": "cd ../helper-scripts && ./deploy_test_resources.sh", "format": "./node_modules/.bin/prettier --write '**/*.ts'", "format:check": "./node_modules/.bin/prettier --check '**/*.ts'", - "lint": "./node_modules/.bin/eslint ./dequeue", + "lint": "./node_modules/.bin/eslint ./src/dequeue", "test:unit": "./node_modules/.bin/jest --testPathPattern=dequeue/ --silent" }, "engines": { diff --git a/test-resources/sonar-project.properties b/test-resources/sonar-project.properties new file mode 100644 index 00000000..6e1dba87 --- /dev/null +++ b/test-resources/sonar-project.properties @@ -0,0 +1,8 @@ +sonar.projectKey=mobile-id-check-async-test-resources +sonar.organization=govuk-one-login + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=src +sonar.javascript.lcov.reportPaths=coverage/lcov.info +sonar.language=ts +sonar.exclusions=**/*.test.ts diff --git a/test-resources/dequeue/dequeueHandler.test.ts b/test-resources/src/dequeue/dequeueHandler.test.ts similarity index 100% rename from test-resources/dequeue/dequeueHandler.test.ts rename to test-resources/src/dequeue/dequeueHandler.test.ts diff --git a/test-resources/dequeue/dequeueHandler.ts b/test-resources/src/dequeue/dequeueHandler.ts similarity index 100% rename from test-resources/dequeue/dequeueHandler.ts rename to test-resources/src/dequeue/dequeueHandler.ts diff --git a/test-resources/template.yaml b/test-resources/template.yaml index 1a787730..84e5f85b 100644 --- a/test-resources/template.yaml +++ b/test-resources/template.yaml @@ -49,7 +49,7 @@ Resources: Target: es2022 Sourcemap: false EntryPoints: - - dequeue/dequeueHandler.ts + - src/dequeue/dequeueHandler.ts Properties: FunctionName: !Sub ${AWS::StackName}-dequeue Runtime: nodejs20.x