Skip to content

Commit

Permalink
ci(main): test include front coverage to sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
Marthym committed Aug 27, 2024
1 parent 0421988 commit 39060fd
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 12 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
run: mvn -B clean test

- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@v2.3.0 # Ex: v2.1.0, See the latest version at https://github.com/marketplace/actions/official-sonarqube-scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Psonar
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any

20 changes: 20 additions & 0 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: SonarCloud
on:
push:
branches:
- master
- develop
pull_request:
types: [opened, synchronize, reopened]

permissions:
pull-requests: read

jobs:
build:
name: analyse
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
6 changes: 3 additions & 3 deletions seaside/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.DS_Store
node_modules
/dist
/coverage

dist
coverage
.scannerwork

# local env files
.env.local
Expand Down
4 changes: 3 additions & 1 deletion seaside/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"dev": "vite",
"lint": "eslint --fix --ext .js,.vue --ignore-path .gitignore src",
"preview": "vite preview",
"test": "vitest"
"test": "vitest",
"coverage": "vitest run --coverage"
},
"dependencies": {
"@heroicons/vue": "2.1.5",
Expand All @@ -30,6 +31,7 @@
"@typescript-eslint/eslint-plugin": "8.0.1",
"@typescript-eslint/parser": "8.0.1",
"@vitejs/plugin-vue": "5.1.2",
"@vitest/coverage-v8": "2.0.5",
"@vue/test-utils": "2.4.6",
"autoprefixer": "10.4.20",
"eslint": "9.9.0",
Expand Down
15 changes: 14 additions & 1 deletion seaside/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</goals>
</execution>
<execution>
<id>Webpack build</id>
<id>Vite build</id>
<phase>generate-resources</phase>
<configuration>
<executable>yarn</executable>
Expand All @@ -122,6 +122,19 @@
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>Vitest Coverage</id>
<phase>generate-resources</phase>
<configuration>
<executable>yarn</executable>
<arguments>
<argument>coverage</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
Expand Down
14 changes: 14 additions & 0 deletions seaside/tests/unit/configuration/components/SettingsTabVue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { describe, expect, test, vi } from 'vitest';
import { mount } from '@vue/test-utils';
import SettingsTab from '@/configuration/components/SettingsTab.vue';
import { createI18n } from 'vue-i18n';
import { of } from 'rxjs';

vi.mock('@/security/services/UserSettingsService', () => {
return {
userSettingsGet: vi.fn().mockImplementation(() => of({})),
};
});

describe('SettingsTab', () => {
test('renders a div', () => {
Expand All @@ -11,7 +18,14 @@ describe('SettingsTab', () => {
};
const i18n = createI18n({
legacy: false,
messages: {
'en': {
'config.settings.form.preferredLocale': 'en',
'config.settings.form.action.save': 'Save',
},
},
});

const wrapper = mount(SettingsTab, {
global: {
plugins: [i18n],
Expand Down
2 changes: 1 addition & 1 deletion seaside/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"types": [
"webpack-env",
"node",
"jest",
"vitest/globals"
],
"paths": {
"@/*": [
Expand Down
4 changes: 4 additions & 0 deletions seaside/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export default defineConfig(configEnv => mergeConfig(
viteConfig(configEnv),
defineConfig({
test: {
global: true,
environment: 'jsdom',
coverage: {
reporter: ['text', 'lcov'],
},
},
}),
));
111 changes: 108 additions & 3 deletions seaside/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
dependencies:
"@babel/types" "^7.25.2"

"@babel/parser@^7.25.4":
version "7.25.4"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.25.4.tgz#af4f2df7d02440286b7de57b1c21acfb2a6f257a"
integrity sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==
dependencies:
"@babel/types" "^7.25.4"

"@babel/types@^7.25.2":
version "7.25.2"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.25.2.tgz#55fb231f7dc958cd69ea141a4c2997e819646125"
Expand All @@ -41,6 +48,20 @@
"@babel/helper-validator-identifier" "^7.24.7"
to-fast-properties "^2.0.0"

"@babel/types@^7.25.4":
version "7.25.4"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.25.4.tgz#6bcb46c72fdf1012a209d016c07f769e10adcb5f"
integrity sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==
dependencies:
"@babel/helper-string-parser" "^7.24.8"
"@babel/helper-validator-identifier" "^7.24.7"
to-fast-properties "^2.0.0"

"@bcoe/v8-coverage@^0.2.3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@esbuild/aix-ppc64@0.21.5":
version "0.21.5"
resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz#c7184a326533fcdf1b8ee0733e21c713b975575f"
Expand Down Expand Up @@ -250,6 +271,11 @@
wrap-ansi "^8.1.0"
wrap-ansi-cjs "npm:wrap-ansi@^7.0.0"

"@istanbuljs/schema@^0.1.2":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98"
integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==

"@jridgewell/gen-mapping@^0.3.2", "@jridgewell/gen-mapping@^0.3.5":
version "0.3.5"
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz#dcce6aff74bdf6dad1a95802b69b04a2fcb1fb36"
Expand All @@ -274,7 +300,7 @@
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a"
integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==

"@jridgewell/trace-mapping@^0.3.24":
"@jridgewell/trace-mapping@^0.3.23", "@jridgewell/trace-mapping@^0.3.24":
version "0.3.25"
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz#15f190e98895f3fc23276ee14bc76b675c2e50f0"
integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==
Expand Down Expand Up @@ -579,6 +605,24 @@
resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-5.1.2.tgz#f11091e0130eca6c1ca8cfb85ee71ea53b255d31"
integrity sha512-nY9IwH12qeiJqumTCLJLE7IiNx7HZ39cbHaysEUd+Myvbz9KAqd2yq+U01Kab1R/H1BmiyM2ShTYlNH32Fzo3A==

"@vitest/coverage-v8@2.0.5":
version "2.0.5"
resolved "https://registry.yarnpkg.com/@vitest/coverage-v8/-/coverage-v8-2.0.5.tgz#411961ce4fd1177a32b4dd74ab576ed3b859155e"
integrity sha512-qeFcySCg5FLO2bHHSa0tAZAOnAUbp4L6/A5JDuj9+bt53JREl8hpLjLHEWF0e/gWc8INVpJaqA7+Ene2rclpZg==
dependencies:
"@ampproject/remapping" "^2.3.0"
"@bcoe/v8-coverage" "^0.2.3"
debug "^4.3.5"
istanbul-lib-coverage "^3.2.2"
istanbul-lib-report "^3.0.1"
istanbul-lib-source-maps "^5.0.6"
istanbul-reports "^3.1.7"
magic-string "^0.30.10"
magicast "^0.3.4"
std-env "^3.7.0"
test-exclude "^7.0.1"
tinyrainbow "^1.2.0"

"@vitest/expect@2.0.5":
version "2.0.5"
resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-2.0.5.tgz#f3745a6a2c18acbea4d39f5935e913f40d26fa86"
Expand Down Expand Up @@ -1085,7 +1129,7 @@ de-indent@^1.0.2:
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
integrity sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==

debug@4, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5:
debug@4, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5:
version "4.3.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b"
integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==
Expand Down Expand Up @@ -1455,7 +1499,7 @@ glob-parent@^6.0.2:
dependencies:
is-glob "^4.0.3"

glob@^10.3.10, glob@^10.3.3:
glob@^10.3.10, glob@^10.3.3, glob@^10.4.1:
version "10.4.5"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956"
integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==
Expand Down Expand Up @@ -1513,6 +1557,11 @@ html-encoding-sniffer@^4.0.0:
dependencies:
whatwg-encoding "^3.1.1"

html-escaper@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453"
integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==

http-proxy-agent@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz#9a8b1f246866c028509486585f62b8f2c18c270e"
Expand Down Expand Up @@ -1620,6 +1669,37 @@ isexe@^2.0.0:
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==

istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz#2d166c4b0644d43a39f04bf6c2edd1e585f31756"
integrity sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==

istanbul-lib-report@^3.0.0, istanbul-lib-report@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d"
integrity sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==
dependencies:
istanbul-lib-coverage "^3.0.0"
make-dir "^4.0.0"
supports-color "^7.1.0"

istanbul-lib-source-maps@^5.0.6:
version "5.0.6"
resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz#acaef948df7747c8eb5fbf1265cb980f6353a441"
integrity sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==
dependencies:
"@jridgewell/trace-mapping" "^0.3.23"
debug "^4.1.1"
istanbul-lib-coverage "^3.0.0"

istanbul-reports@^3.1.7:
version "3.1.7"
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.7.tgz#daed12b9e1dca518e15c056e1e537e741280fa0b"
integrity sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==
dependencies:
html-escaper "^2.0.0"
istanbul-lib-report "^3.0.0"

jackspeak@^3.1.2:
version "3.4.3"
resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.3.tgz#8833a9d89ab4acde6188942bd1c53b6390ed5a8a"
Expand Down Expand Up @@ -1765,6 +1845,22 @@ magic-string@^0.30.10:
dependencies:
"@jridgewell/sourcemap-codec" "^1.5.0"

magicast@^0.3.4:
version "0.3.5"
resolved "https://registry.yarnpkg.com/magicast/-/magicast-0.3.5.tgz#8301c3c7d66704a0771eb1bad74274f0ec036739"
integrity sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==
dependencies:
"@babel/parser" "^7.25.4"
"@babel/types" "^7.25.4"
source-map-js "^1.2.0"

make-dir@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e"
integrity sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==
dependencies:
semver "^7.5.3"

md5-js-tools@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/md5-js-tools/-/md5-js-tools-1.0.2.tgz#6fd5b257596ea39e44c1e17f2dbc6673057e7c41"
Expand Down Expand Up @@ -2394,6 +2490,15 @@ tailwindcss@3.4.9:
resolve "^1.22.2"
sucrase "^3.32.0"

test-exclude@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-7.0.1.tgz#20b3ba4906ac20994e275bbcafd68d510264c2a2"
integrity sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==
dependencies:
"@istanbuljs/schema" "^0.1.2"
glob "^10.4.1"
minimatch "^9.0.4"

text-table@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
Expand Down
10 changes: 9 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
sonar.exclusions=seaside/src/locales/**
sonar.projectKey=Marthym_baywatch
sonar.javascript.lcov.reportPaths=seaside/coverage/lcov.info
sonar.organization=ght1pc9kc-fr
sonar.host.url=https://sonarcloud.io</sonar.host.url
sonar.coverage.jacoco.xmlReportPaths=**/jacoco.xml
sonar.coverage.exclusions=**/*.html,**/*.test.*
sonar.exclusions=**/*.html,seaside/src/locales/**,dist/**
sonar.java.binaries=**/classes
sonar.java.libraries=sandside/target/dependency

0 comments on commit 39060fd

Please sign in to comment.