diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c40d42e8d..cfa7db2e6b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,3 +26,9 @@ jobs: uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Sonar Scanner + uses: sonarsource/sonarcloud-github-action@master + if: success() && github.repository == 'directus/app-next' && github.event_name == 'push' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/jest.config.js b/jest.config.js index 3482034a64..cf7d3f20a3 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,5 +4,9 @@ module.exports = { coveragePathIgnorePatterns: ['/node_modules/', '/.jest/'], restoreMocks: true, clearMocks: true, - resetMocks: true + resetMocks: true, + reporters: ['default', ['jest-sonar', { + outputDirectory: "coverage", + outputName: "sonar.xml" + }]], }; diff --git a/package.json b/package.json index 6591f3d67f..62c58168aa 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "eslint-plugin-prettier": "^3.1.1", "eslint-plugin-vue": "^6.2.2", "html-loader": "^0.5.5", + "jest-sonar": "^0.2.5", "lint-staged": "^10.0.8", "mockdate": "^2.0.5", "prettier": "^1.19.1", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000000..3b807dfabf --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.organization=directus +sonar.projectKey=app-next + +sonar.sources=./src +sonar.tests=./src + +sonar.test.inclusions=./src/**/*.test.ts + +sonar.javascript.lcov.reportPaths=./coverage/lcov.info +sonar.testExecutionReportPaths=./coverage/sonar.xml + +sonar.pullrequest.provider=github +sonar.pullrequest.github.repository=directus/app-next diff --git a/yarn.lock b/yarn.lock index 49509d79dc..a912728668 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5515,16 +5515,16 @@ enhanced-resolve@^4.0.0, enhanced-resolve@^4.1.0: memory-fs "^0.5.0" tapable "^1.0.0" +entities@2.0.0, entities@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.0.tgz#68d6084cab1b079767540d80e56a39b423e4abf4" + integrity sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw== + entities@^1.1.1, entities@^1.1.2, entities@~1.1.1: version "1.1.2" resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56" integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w== -entities@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.0.tgz#68d6084cab1b079767540d80e56a39b423e4abf4" - integrity sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw== - env-ci@^2.1.0: version "2.6.0" resolved "https://registry.yarnpkg.com/env-ci/-/env-ci-2.6.0.tgz#3fc46537c972b4d3ab5f0b82d07dfc1491297662" @@ -8422,6 +8422,14 @@ jest-snapshot@^24.9.0: pretty-format "^24.9.0" semver "^6.2.0" +jest-sonar@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/jest-sonar/-/jest-sonar-0.2.5.tgz#378fad08f2b8375daa28143c370293e9242f6401" + integrity sha512-EcLc7NN1ZpzyS7R1BnD9lZ62bOS2+SaNa34ah8xpSUfgSP/mjA6lIhKfgodHeHcpB2OB28nB/5LTmhH0wbO0vQ== + dependencies: + entities "2.0.0" + strip-ansi "5.2.0" + jest-transform-stub@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/jest-transform-stub/-/jest-transform-stub-2.0.0.tgz#19018b0851f7568972147a5d60074b55f0225a7d"