From 3884ee20a64e31c51b4d8bd02f1adc81de39cfc3 Mon Sep 17 00:00:00 2001 From: Georg Krause <mail@georg-krause.net> Date: Thu, 22 Apr 2021 15:57:15 +0200 Subject: [PATCH] Add unit test reporting and vulnerability scans to CI --- .gitlab-ci.yml | 12 +++++- front/package.json | 3 +- front/test-results.xml | 90 ++++++++++++++++++++++++++++++++++++++++++ front/yarn.lock | 37 ++++++++++++++++- 4 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 front/test-results.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0c6091657..25516f2947 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -142,9 +142,13 @@ test_api: - pip3 install -r requirements/local.txt - pip3 install -r requirements/test.txt script: - - pytest --cov=funkwhale_api tests/ + - pytest --cov=funkwhale_api --junit=report.xml tests/ tags: - docker + artifacts: + when: always + reports: + junit: report.xml test_front: interruptible: true @@ -166,6 +170,8 @@ test_front: name: "front_${CI_COMMIT_REF_NAME}" paths: - front/dist/ + reports: + junit: front/test-results.xml tags: - docker @@ -285,3 +291,7 @@ build_api: - tags@funkwhale/funkwhale - master@funkwhale/funkwhale - develop@funkwhale/funkwhale + +include: + - template: Security/Secret-Detection.gitlab-ci.yml + - template: Security/SAST.gitlab-ci.yml diff --git a/front/package.json b/front/package.json index dc918569ad..22c0f60681 100644 --- a/front/package.json +++ b/front/package.json @@ -7,7 +7,7 @@ "scripts": { "serve": "[ ! -d src/translations ] && npm run i18n-compile; vue-cli-service serve --port ${VUE_PORT:-8080} --host ${VUE_HOST:-0.0.0.0}", "build": "scripts/i18n-compile.sh && vue-cli-service build", - "test:unit": "vue-cli-service test:unit", + "test:unit": "vue-cli-service test:unit --reporter mocha-junit-reporter", "lint": "vue-cli-service lint", "i18n-compile": "scripts/i18n-compile.sh", "i18n-extract": "scripts/i18n-extract.sh", @@ -58,6 +58,7 @@ "eslint-plugin-vue": "^6.1.2", "glob-all": "^3.1.0", "mocha": "^5.2.0", + "mocha-junit-reporter": "^2.0.0", "moxios": "^0.4.0", "preload-webpack-plugin": "^3.0.0-beta.4", "purgecss-webpack-plugin": "^1.6.0", diff --git a/front/test-results.xml b/front/test-results.xml new file mode 100644 index 0000000000..f5657048db --- /dev/null +++ b/front/test-results.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8"?> +<testsuites name="Mocha Tests" time="0.0170" tests="27" failures="1"> + <testsuite name="Root Suite" timestamp="2021-04-22T13:53:41" tests="0" time="0.0000" failures="0"> + </testsuite> + <testsuite name="search" timestamp="2021-04-22T13:53:41" tests="3" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0030" failures="0"> + <testcase name="search normalizeQuery returns correct tokens" time="0.0010" classname="normalizeQuery returns correct tokens"> + </testcase> + <testcase name="search parseTokens can extract fields and values from tokens" time="0.0010" classname="parseTokens can extract fields and values from tokens"> + </testcase> + <testcase name="search compileTokens returns proper query string" time="0.0010" classname="compileTokens returns proper query string"> + </testcase> + </testsuite> + <testsuite name="utils" timestamp="2021-04-22T13:53:41" tests="0" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0"> + </testsuite> + <testsuite name="parseAPIErrors" timestamp="2021-04-22T13:53:41" tests="4" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0010" failures="0"> + <testcase name="utils parseAPIErrors handles flat structure" time="0.0010" classname="handles flat structure"> + </testcase> + <testcase name="utils parseAPIErrors handles flat structure with multiple errors per field" time="0.0000" classname="handles flat structure with multiple errors per field"> + </testcase> + <testcase name="utils parseAPIErrors translate field name" time="0.0000" classname="translate field name"> + </testcase> + <testcase name="utils parseAPIErrors handle nested fields" time="0.0000" classname="handle nested fields"> + </testcase> + </testsuite> + <testsuite name="Username" timestamp="2021-04-22T13:53:41" tests="1" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0040" failures="0"> + <testcase name="Username displays username" time="0.0040" classname="displays username"> + </testcase> + </testsuite> + <testsuite name="filters" timestamp="2021-04-22T13:53:41" tests="0" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0"> + </testsuite> + <testsuite name="truncate" timestamp="2021-04-22T13:53:41" tests="3" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0"> + <testcase name="filters truncate leave strings as it if correct size" time="0.0000" classname="leave strings as it if correct size"> + </testcase> + <testcase name="filters truncate returns shorter string with character" time="0.0000" classname="returns shorter string with character"> + </testcase> + <testcase name="filters truncate custom ellipsis" time="0.0000" classname="custom ellipsis"> + </testcase> + </testsuite> + <testsuite name="ago" timestamp="2021-04-22T13:53:41" tests="1" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0020" failures="0"> + <testcase name="filters ago works" time="0.0020" classname="works"> + </testcase> + </testsuite> + <testsuite name="year" timestamp="2021-04-22T13:53:41" tests="1" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0020" failures="0"> + <testcase name="filters year works" time="0.0020" classname="works"> + </testcase> + </testsuite> + <testsuite name="capitalize" timestamp="2021-04-22T13:53:41" tests="1" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0"> + <testcase name="filters capitalize works" time="0.0000" classname="works"> + </testcase> + </testsuite> + <testsuite name="store/auth" timestamp="2021-04-22T13:53:41" tests="0" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0"> + </testsuite> + <testsuite name="mutations" timestamp="2021-04-22T13:53:41" tests="7" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0020" failures="0"> + <testcase name="store/auth mutations profile" time="0.0010" classname="profile"> + </testcase> + <testcase name="store/auth mutations username" time="0.0000" classname="username"> + </testcase> + <testcase name="store/auth mutations authenticated true" time="0.0000" classname="authenticated true"> + </testcase> + <testcase name="store/auth mutations authenticated false" time="0.0010" classname="authenticated false"> + </testcase> + <testcase name="store/auth mutations token null" time="0.0000" classname="token null"> + </testcase> + <testcase name="store/auth mutations token real" time="0.0000" classname="token real"> + </testcase> + <testcase name="store/auth mutations permissions" time="0.0000" classname="permissions"> + </testcase> + </testsuite> + <testsuite name="getters" timestamp="2021-04-22T13:53:41" tests="1" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0"> + <testcase name="store/auth getters header" time="0.0000" classname="header"> + </testcase> + </testsuite> + <testsuite name="actions" timestamp="2021-04-22T13:53:41" tests="5" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0030" failures="1"> + <testcase name="store/auth actions logout" time="0.0000" classname="logout"> + </testcase> + <testcase name="store/auth actions check jwt null" time="0.0010" classname="check jwt null"> + </testcase> + <testcase name="store/auth actions login success" time="0.0010" classname="login success"> + </testcase> + <testcase name="store/auth actions login error" time="0.0010" classname="login error"> + </testcase> + <testcase name="store/auth actions fetchProfile" time="0.0000" classname="fetchProfile"> + </testcase> + <testcase name="store/auth actions fetchProfile" time="0.0000" classname="fetchProfile"> + <failure message="expected 'favorites/fetch' to equal 'ui/initSettings'" type="AssertionError"><![CDATA[AssertionError: expected 'favorites/fetch' to equal 'ui/initSettings' + at dispatch (dist/js/main.js:192702:34) + at /home/georg/workspace/funkwhale/front/dist/js/main.js:184555:11]]></failure> + </testcase> + </testsuite> +</testsuites> \ No newline at end of file diff --git a/front/yarn.lock b/front/yarn.lock index 0bf143cb31..9adb2ea820 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -2509,6 +2509,11 @@ chardet@^0.7.0: resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== +charenc@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" + integrity sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc= + check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" @@ -3036,6 +3041,11 @@ cross-spawn@^7.0.0: shebang-command "^2.0.0" which "^2.0.1" +crypt@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" + integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs= + crypto-browserify@^3.11.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" @@ -5272,7 +5282,7 @@ is-binary-path@~2.1.0: dependencies: binary-extensions "^2.0.0" -is-buffer@^1.1.5: +is-buffer@^1.1.5, is-buffer@~1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== @@ -6058,6 +6068,15 @@ md5.js@^1.3.4: inherits "^2.0.1" safe-buffer "^5.1.2" +md5@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/md5/-/md5-2.3.0.tgz#c3da9a6aae3a30b46b7b0c349b87b110dc3bda4f" + integrity sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g== + dependencies: + charenc "0.0.2" + crypt "0.0.2" + is-buffer "~1.1.6" + mdn-data@2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.4.tgz#699b3c38ac6f1d728091a64650b65d388502fd5b" @@ -6298,6 +6317,17 @@ mkdirp@^1.0.4: resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== +mocha-junit-reporter@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/mocha-junit-reporter/-/mocha-junit-reporter-2.0.0.tgz#3bf990fce7a42c0d2b718f188553a25d9f24b9a2" + integrity sha512-20HoWh2HEfhqmigfXOKUhZQyX23JImskc37ZOhIjBKoBEsb+4cAFRJpAVhFpnvsztLklW/gFVzsrobjLwmX4lA== + dependencies: + debug "^2.2.0" + md5 "^2.1.0" + mkdirp "~0.5.1" + strip-ansi "^4.0.0" + xml "^1.0.0" + mocha@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6" @@ -10069,6 +10099,11 @@ xml-name-validator@^3.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== +xml@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" + integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU= + xmlchars@^2.1.1: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" -- GitLab