diff --git a/.gitignore b/.gitignore index 8791c51f5..e8659535c 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ release/ *.po~ .weblate docker/production/.env +test-junit-report.xml +js/junit.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c976eaa3f..01e949201 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,7 +28,6 @@ variables: PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}" ARCH: "amd64" - cache: key: "${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" paths: @@ -45,9 +44,9 @@ cache: install: stage: install script: - - yarn --cwd "js" install --frozen-lockfile - - mix deps.get - - mix compile + - yarn --cwd "js" install --frozen-lockfile + - mix deps.get + - mix compile lint-elixir: stage: check @@ -70,16 +69,16 @@ lint-front: build-frontend: stage: build before_script: - - apt update - - apt install -y --no-install-recommends python build-essential webp imagemagick gifsicle jpegoptim optipng pngquant + - apt update + - apt install -y --no-install-recommends python build-essential webp imagemagick gifsicle jpegoptim optipng pngquant script: - - yarn --cwd "js" run build + - yarn --cwd "js" run build artifacts: expire_in: 5 days paths: - - priv/static + - priv/static needs: - - lint-front + - lint-front deps: stage: check @@ -104,13 +103,17 @@ exunit: - mix ecto.migrate script: - mix coveralls + artifacts: + when: always + reports: + junit: + - test-junit-report.xml + expire_in: 30 days jest: stage: test needs: - lint-front - before_script: - - yarn add --dev jest-junit script: - yarn --cwd "js" run test:unit --no-color --ci --reporters=default --reporters=jest-junit artifacts: @@ -119,7 +122,7 @@ jest: - js/coverage reports: junit: - - js/junit.xml + - js/junit.xml expire_in: 30 days # cypress: @@ -193,20 +196,20 @@ build-docker-tag: package-app: stage: package before_script: - - apt update - - apt install -y --no-install-recommends build-essential git cmake + - apt update + - apt install -y --no-install-recommends build-essential git cmake variables: MIX_ENV: "prod" script: - - mix local.hex --force - - mix local.rebar --force - - cp docker/production/releases.exs ./config/ - - mix phx.digest - - mix release + - mix local.hex --force + - mix local.rebar --force + - cp docker/production/releases.exs ./config/ + - mix phx.digest + - mix release artifacts: expire_in: 2 days paths: - - _build/prod/rel + - _build/prod/rel release-upload: stage: upload @@ -242,4 +245,3 @@ release-create: release-cli create --name "$CI_PROJECT_TITLE v$CI_COMMIT_TAG" \ --tag-name "$CI_COMMIT_TAG" \ --assets-link "{\"name\":\"${APP_ASSET}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${APP_VERSION}/${APP_ASSET}\"}" - diff --git a/config/test.exs b/config/test.exs index 8c4ac30d3..38f132bd4 100644 --- a/config/test.exs +++ b/config/test.exs @@ -59,6 +59,8 @@ config :mobilizon, Mobilizon.Web.Auth.Guardian, secret_key: "some secret" config :mobilizon, :activitypub, sign_object_fetches: false +config :junit_formatter, report_dir: "." + if System.get_env("DOCKER", "false") == "false" && File.exists?("./config/test.secret.exs") do import_config "test.secret.exs" end diff --git a/js/jest.config.js b/js/jest.config.js index b10500065..a87688fe7 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -7,6 +7,7 @@ module.exports = { "!get_union_json.ts", ], coverageReporters: ["html", "text", "text-summary"], + reporters: ["default", "jest-junit"], // The following should fix the issue with svgs and ?inline loader (see Logo.vue), but doesn't work // // transform: { diff --git a/js/package.json b/js/package.json index 4b9a6510f..047c40726 100644 --- a/js/package.json +++ b/js/package.json @@ -82,6 +82,7 @@ "eslint-config-prettier": "^7.0.0", "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-vue": "^7.0.0", + "jest-junit": "^12.0.0", "mock-apollo-client": "^0.4", "prettier": "2.2.1", "prettier-eslint": "^12.0.0", diff --git a/js/yarn.lock b/js/yarn.lock index c831fde31..9de09df89 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -7172,6 +7172,16 @@ jest-jasmine2@^24.9.0: pretty-format "^24.9.0" throat "^4.0.0" +jest-junit@^12.0.0: + version "12.0.0" + resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-12.0.0.tgz#3ebd4a6a84b50c4ab18323a8f7d9cceb9d845df6" + integrity sha512-+8K35LlboWiPuCnXSyiid7rFdxNlpCWWM20WEYe6IZH6psfUWKZmSpSRQ5tk0C0cBeDsvsnIzcef5mYhyJsbug== + dependencies: + mkdirp "^1.0.4" + strip-ansi "^5.2.0" + uuid "^3.3.3" + xml "^1.0.1" + jest-leak-detector@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-24.9.0.tgz#b665dea7c77100c5c4f7dfcb153b65cf07dcf96a" @@ -12115,7 +12125,7 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= -uuid@^3.3.2, uuid@^3.4.0: +uuid@^3.3.2, uuid@^3.3.3, uuid@^3.4.0: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== @@ -12859,6 +12869,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.1: + 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" diff --git a/mix.exs b/mix.exs index fba4764e3..2df43044c 100644 --- a/mix.exs +++ b/mix.exs @@ -146,7 +146,8 @@ defmodule Mobilizon.Mixfile do {:credo, "~> 1.5", only: [:dev, :test], runtime: false}, {:mock, "~> 0.3.4", only: :test}, {:elixir_feed_parser, "~> 2.1.0", only: :test}, - {:mox, "~> 1.0", only: :test} + {:mox, "~> 1.0", only: :test}, + {:junit_formatter, "~> 3.1", only: [:test]} ] ++ oauth_deps() end diff --git a/mix.lock b/mix.lock index f32177363..ffb98bd5f 100644 --- a/mix.lock +++ b/mix.lock @@ -85,6 +85,7 @@ "jose": {:hex, :jose, "1.11.1", "59da64010c69aad6cde2f5b9248b896b84472e99bd18f246085b7b9fe435dcdb", [:mix, :rebar3], [], "hexpm", "078f6c9fb3cd2f4cfafc972c814261a7d1e8d2b3685c0a76eb87e158efff1ac5"}, "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm", "fc3499fed7a726995aa659143a248534adc754ebd16ccd437cd93b649a95091f"}, "jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"}, + "junit_formatter": {:hex, :junit_formatter, "3.1.0", "3f69c61c5413750f9c45e367d77aabbeac9b395acf478d8e70b4ee9d1989c709", [:mix], [], "hexpm", "da52401a93f711fc4f77ffabdda68f9a16fcad5d96f5fce4ae606ab1d73b72f4"}, "linkify": {:hex, :linkify, "0.4.1", "f881eb3429ae88010cf736e6fb3eed406c187bcdd544902ec937496636b7c7b3", [:mix], [], "hexpm", "ce98693f54ae9ace59f2f7a8aed3de2ef311381a8ce7794804bd75484c371dda"}, "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, "makeup_elixir": {:hex, :makeup_elixir, "0.15.0", "98312c9f0d3730fde4049985a1105da5155bfe5c11e47bdc7406d88e01e4219b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "75ffa34ab1056b7e24844c90bfc62aaf6f3a37a15faa76b07bc5eba27e4a8b4a"}, diff --git a/test/test_helper.exs b/test/test_helper.exs index ee5409205..e0baa23b9 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,5 +1,5 @@ {:ok, _} = Application.ensure_all_started(:ex_machina) -ExUnit.configure(formatters: [ExUnit.CLIFormatter, ExUnitNotifier]) +ExUnit.configure(formatters: [JUnitFormatter, ExUnit.CLIFormatter, ExUnitNotifier]) ExUnit.start()