debian-mirror-gitlab/.gitlab/ci/frontend.gitlab-ci.yml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

425 lines
12 KiB
YAML
Raw Normal View History

2020-06-23 00:09:42 +05:30
.compile-assets-base:
2020-07-28 23:09:34 +05:30
extends:
2021-04-29 21:17:54 +05:30
- .default-retry
- .default-before_script
2020-07-28 23:09:34 +05:30
- .assets-compile-cache
2023-05-27 22:25:52 +05:30
image: ${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}-node-16.14:rubygems-${RUBYGEMS_VERSION}-git-2.33-lfs-2.9-yarn-1.22-graphicsmagick-1.3.36
2020-07-28 23:09:34 +05:30
variables:
2021-04-29 21:17:54 +05:30
SETUP_DB: "false"
2020-07-28 23:09:34 +05:30
WEBPACK_VENDOR_DLL: "true"
2021-08-04 16:29:09 +05:30
# Disable warnings in browserslist which can break on backports
# https://github.com/browserslist/browserslist/blob/a287ec6/node.js#L367-L384
BROWSERSLIST_IGNORE_OLD_DATA: "true"
2022-10-11 01:57:18 +05:30
WEBPACK_COMPILE_LOG_PATH: "tmp/webpack-output.log"
2020-03-13 15:44:24 +05:30
stage: prepare
2020-06-23 00:09:42 +05:30
script:
2022-11-25 23:54:43 +05:30
- yarn_install_script
- export GITLAB_ASSETS_HASH=$(bin/rake gitlab:assets:hash_sum)
- 'echo "CACHE_ASSETS_AS_PACKAGE: ${CACHE_ASSETS_AS_PACKAGE}"'
# The new strategy to cache assets as generic packages is experimental and can be disabled by removing the `CACHE_ASSETS_AS_PACKAGE` variable
- |
if [[ "${CACHE_ASSETS_AS_PACKAGE}" == "true" ]]; then
source scripts/gitlab_component_helpers.sh
2023-01-13 00:05:48 +05:30
if ! gitlab_assets_archive_doesnt_exist; then
# We remove all assets from the native cache as they could pollute the fresh assets from the package
rm -rf public/assets/ app/assets/javascripts/locale/**/app.js
run_timed_command "download_and_extract_gitlab_assets"
fi
2022-11-25 23:54:43 +05:30
fi
- assets_compile_script
2023-03-04 22:38:38 +05:30
- echo -n "${GITLAB_ASSETS_HASH}" > "cached-assets-hash.txt"
2020-06-23 00:09:42 +05:30
compile-production-assets:
extends:
- .compile-assets-base
2023-04-23 21:23:45 +05:30
- .production
2020-06-23 00:09:42 +05:30
- .frontend:rules:compile-production-assets
2019-12-04 20:38:33 +05:30
artifacts:
name: webpack-report
expire_in: 31d
paths:
2020-05-24 23:13:21 +05:30
# These assets are used in multiple locations:
# - in `build-assets-image` job to create assets image for packaging systems
# - GitLab UI for integration tests: https://gitlab.com/gitlab-org/gitlab-ui/-/blob/e88493b3c855aea30bf60baee692a64606b0eb1e/.storybook/preview-head.pug#L1
2023-03-04 22:38:38 +05:30
- cached-assets-hash.txt
2020-06-23 00:09:42 +05:30
- public/assets/
2022-10-11 01:57:18 +05:30
- "${WEBPACK_COMPILE_LOG_PATH}"
2020-04-22 19:07:51 +05:30
when: always
2020-06-23 00:09:42 +05:30
after_script:
2019-09-04 21:01:54 +05:30
- rm -f /etc/apt/sources.list.d/google*.list # We don't need to update Chrome here
2019-07-31 22:56:46 +05:30
2023-06-20 00:43:36 +05:30
compile-production-assets as-if-foss:
2023-05-27 22:25:52 +05:30
extends:
2023-06-20 00:43:36 +05:30
- compile-production-assets
- .as-if-foss
- .frontend:rules:compile-production-assets-as-if-foss
2023-05-27 22:25:52 +05:30
2020-06-23 00:09:42 +05:30
compile-test-assets:
2020-03-13 15:44:24 +05:30
extends:
2020-06-23 00:09:42 +05:30
- .compile-assets-base
- .frontend:rules:compile-test-assets
2019-07-31 22:56:46 +05:30
artifacts:
expire_in: 7d
paths:
2020-06-23 00:09:42 +05:30
- public/assets/
- node_modules/@gitlab/svgs/dist/icons.json # app/helpers/icons_helper.rb uses this file
2022-10-11 01:57:18 +05:30
- "${WEBPACK_COMPILE_LOG_PATH}"
2020-04-22 19:07:51 +05:30
when: always
2019-09-30 21:07:59 +05:30
2020-06-23 00:09:42 +05:30
compile-test-assets as-if-foss:
2020-03-13 15:44:24 +05:30
extends:
2020-06-23 00:09:42 +05:30
- compile-test-assets
- .frontend:rules:compile-test-assets-as-if-foss
- .as-if-foss
2019-09-30 21:07:59 +05:30
2020-06-23 00:09:42 +05:30
update-assets-compile-production-cache:
2020-03-13 15:44:24 +05:30
extends:
2020-06-23 00:09:42 +05:30
- compile-production-assets
2021-06-08 01:23:25 +05:30
- .assets-compile-cache-push
2020-06-23 00:09:42 +05:30
- .shared:rules:update-cache
stage: prepare
artifacts: {} # This job's purpose is only to update the cache.
2019-12-21 20:55:43 +05:30
2020-06-23 00:09:42 +05:30
update-assets-compile-test-cache:
2020-03-13 15:44:24 +05:30
extends:
2020-06-23 00:09:42 +05:30
- compile-test-assets
2021-06-08 01:23:25 +05:30
- .assets-compile-cache-push
2020-06-23 00:09:42 +05:30
- .shared:rules:update-cache
stage: prepare
2022-11-25 23:54:43 +05:30
script:
- !reference [compile-test-assets, script]
- echo -n "${GITLAB_ASSETS_HASH}" > "cached-assets-hash.txt"
2020-06-23 00:09:42 +05:30
artifacts: {} # This job's purpose is only to update the cache.
2019-12-21 20:55:43 +05:30
2021-09-30 23:02:18 +05:30
update-storybook-yarn-cache:
extends:
- .default-retry
2022-11-25 23:54:43 +05:30
- .default-utils-before_script
2021-09-30 23:02:18 +05:30
- .storybook-yarn-cache-push
- .shared:rules:update-cache
stage: prepare
script:
2022-11-25 23:54:43 +05:30
- yarn_install_script
2021-09-30 23:02:18 +05:30
2023-06-20 00:43:36 +05:30
retrieve-frontend-fixtures:
variables:
SETUP_DB: "false"
extends:
- .default-retry
- .frontend:rules:default-frontend-jobs
stage: prepare
script:
- source scripts/utils.sh
- source scripts/gitlab_component_helpers.sh
- install_gitlab_gem
- export_fixtures_sha_for_download
- |
if check_fixtures_download; then
run_timed_command "download_and_extract_fixtures"
fi
artifacts:
paths:
- tmp/tests/frontend/
# Download fixtures only when a merge request contains changes to only JS files
# and fixtures are present in the package registry.
2020-04-08 14:13:33 +05:30
.frontend-fixtures-base:
2019-12-04 20:38:33 +05:30
extends:
2021-04-29 21:17:54 +05:30
- .default-retry
- .default-before_script
2020-05-24 23:13:21 +05:30
- .rails-cache
2023-06-20 00:43:36 +05:30
- .use-pg13
2020-04-08 14:13:33 +05:30
stage: fixtures
2023-06-20 00:43:36 +05:30
needs: ["setup-test-env", "retrieve-tests-metadata", "retrieve-frontend-fixtures"]
2020-06-23 00:09:42 +05:30
variables:
2023-06-20 00:43:36 +05:30
# Don't add `CRYSTALBALL: "false"` here as we're enabling Crystalball for scheduled pipelines (in `.gitlab-ci.yml`), so that we get coverage data
# for the `frontend fixture RSpec files` that will be added to the Crystalball mapping in `update-tests-metadata`.
# More information in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74003.
2020-07-28 23:09:34 +05:30
WEBPACK_VENDOR_DLL: "true"
2020-04-08 14:13:33 +05:30
script:
2023-06-20 00:43:36 +05:30
- source scripts/gitlab_component_helpers.sh
- |
2023-07-09 08:55:56 +05:30
if check_fixtures_reuse; then
echoinfo "INFO: Reusing frontend fixtures from 'retrieve-frontend-fixtures'."
2023-06-20 00:43:36 +05:30
exit 0
fi
2021-01-29 00:20:46 +05:30
- run_timed_command "gem install knapsack --no-document"
2023-07-09 08:55:56 +05:30
- section_start "gitaly-test-spawn" "Spawning Gitaly"; scripts/gitaly-test-spawn; section_end "gitaly-test-spawn"; # Do not use 'bundle exec' here
2021-01-29 00:20:46 +05:30
- source ./scripts/rspec_helpers.sh
2021-09-30 23:02:18 +05:30
- rspec_paralellized_job
2020-04-08 14:13:33 +05:30
artifacts:
name: frontend-fixtures
expire_in: 31d
when: always
paths:
- tmp/tests/frontend/
2021-01-29 00:20:46 +05:30
- knapsack/
2021-12-11 22:18:48 +05:30
- crystalball/
2020-04-08 14:13:33 +05:30
2021-11-18 22:05:49 +05:30
# Builds FOSS, and EE fixtures in the EE project.
# Builds FOSS fixtures in the FOSS project.
rspec-all frontend_fixture:
2020-04-08 14:13:33 +05:30
extends:
- .frontend-fixtures-base
- .frontend:rules:default-frontend-jobs
2021-11-18 22:05:49 +05:30
needs:
- !reference [.frontend-fixtures-base, needs]
- "compile-test-assets"
2023-04-23 21:23:45 +05:30
parallel: 7
2020-04-08 14:13:33 +05:30
2021-11-18 22:05:49 +05:30
# Builds FOSS fixtures in the EE project, with the `ee/` folder removed (due to `as-if-foss`).
rspec-all frontend_fixture as-if-foss:
2020-04-08 14:13:33 +05:30
extends:
- .frontend-fixtures-base
2022-08-27 11:52:29 +05:30
- .frontend:rules:frontend_fixture-as-if-foss
2020-04-08 14:13:33 +05:30
- .as-if-foss
2023-06-20 00:43:36 +05:30
variables:
# We explicitely disable Crystalball here so as even in scheduled pipelines we don't need it since it's already enabled for `rspec-all frontend_fixture` there.
CRYSTALBALL: "false"
WEBPACK_VENDOR_DLL: "true"
KNAPSACK_GENERATE_REPORT: ""
FLAKY_RSPEC_GENERATE_REPORT: ""
2021-11-18 22:05:49 +05:30
needs:
- !reference [.frontend-fixtures-base, needs]
- "compile-test-assets as-if-foss"
2020-04-08 14:13:33 +05:30
2023-05-27 22:25:52 +05:30
# Uploads EE fixtures in the EE project.
# Uploads FOSS fixtures in the FOSS project.
upload-frontend-fixtures:
extends:
- .frontend-fixtures-base
- .frontend:rules:upload-frontend-fixtures
stage: fixtures
needs: ["rspec-all frontend_fixture"]
script:
2023-06-20 00:43:36 +05:30
- source scripts/utils.sh
2023-05-27 22:25:52 +05:30
- source scripts/gitlab_component_helpers.sh
2023-06-20 00:43:36 +05:30
- export_fixtures_sha_for_upload
2023-05-27 22:25:52 +05:30
- 'fixtures_archive_doesnt_exist || { echoinfo "INFO: Exiting early as package exists."; exit 0; }'
- run_timed_command "create_fixtures_package"
- run_timed_command "upload_fixtures_package"
artifacts: {}
2021-04-17 20:07:23 +05:30
graphql-schema-dump:
variables:
SETUP_DB: "false"
extends:
- .default-retry
- .rails-cache
- .default-before_script
- .frontend:rules:default-frontend-jobs
stage: fixtures
needs: []
script:
- bundle exec rake gitlab:graphql:schema:dump
artifacts:
name: graphql-schema
paths:
- tmp/tests/graphql/gitlab_schema.graphql
- tmp/tests/graphql/gitlab_schema.json
2022-08-13 15:12:31 +05:30
graphql-schema-dump as-if-foss:
extends:
- graphql-schema-dump
2023-01-13 00:05:48 +05:30
- .frontend:rules:default-frontend-jobs-as-if-foss
2022-08-13 15:12:31 +05:30
- .as-if-foss
2020-06-23 00:09:42 +05:30
.frontend-test-base:
2020-04-08 14:13:33 +05:30
extends:
2021-04-29 21:17:54 +05:30
- .default-retry
2020-06-23 00:09:42 +05:30
- .yarn-cache
2021-08-04 16:29:09 +05:30
variables:
# Disable warnings in browserslist which can break on backports
# https://github.com/browserslist/browserslist/blob/a287ec6/node.js#L367-L384
BROWSERSLIST_IGNORE_OLD_DATA: "true"
2022-08-27 11:52:29 +05:30
USE_BUNDLE_INSTALL: "false"
SETUP_DB: "false"
2021-11-11 11:23:49 +05:30
before_script:
2022-08-27 11:52:29 +05:30
- !reference [.default-before_script, before_script]
2022-11-25 23:54:43 +05:30
- yarn_install_script
2019-12-21 20:55:43 +05:30
stage: test
2020-07-28 23:09:34 +05:30
2019-12-21 20:55:43 +05:30
.jest-base:
2020-06-23 00:09:42 +05:30
extends: .frontend-test-base
2019-07-31 22:56:46 +05:30
script:
2021-11-11 11:23:49 +05:30
- run_timed_command "yarn jest:ci"
2019-12-21 20:55:43 +05:30
jest:
2020-03-13 15:44:24 +05:30
extends:
- .jest-base
2021-11-11 11:23:49 +05:30
- .frontend:rules:jest
2021-11-18 22:05:49 +05:30
needs: ["rspec-all frontend_fixture"]
2019-07-31 22:56:46 +05:30
artifacts:
name: coverage-frontend
expire_in: 31d
when: always
paths:
2019-09-04 21:01:54 +05:30
- coverage-frontend/
- junit_jest.xml
2019-10-12 21:52:04 +05:30
- tmp/tests/frontend/
reports:
junit: junit_jest.xml
2023-04-23 21:23:45 +05:30
parallel: 7
2019-07-31 22:56:46 +05:30
2023-03-17 16:20:25 +05:30
jest predictive:
2021-11-11 11:23:49 +05:30
extends:
- jest
2023-03-17 16:20:25 +05:30
- .frontend:rules:jest:predictive
2021-11-18 22:05:49 +05:30
needs:
- !reference [jest, needs]
- "detect-tests"
2021-11-11 11:23:49 +05:30
script:
2023-03-17 16:20:25 +05:30
- if [[ -s "$RSPEC_CHANGED_FILES_PATH" ]] || [[ -s "$RSPEC_MATCHING_JS_FILES_PATH" ]]; then run_timed_command "yarn jest:ci:predictive"; fi
2022-10-11 01:57:18 +05:30
jest as-if-foss:
extends:
- .jest-base
- .frontend:rules:jest:as-if-foss
- .as-if-foss
needs: ["rspec-all frontend_fixture as-if-foss"]
2023-04-23 21:23:45 +05:30
parallel: 4
2021-11-11 11:23:49 +05:30
2023-03-17 16:20:25 +05:30
jest predictive as-if-foss:
2022-08-27 11:52:29 +05:30
extends:
- .jest-base
2023-03-17 16:20:25 +05:30
- .frontend:rules:jest:predictive:as-if-foss
2022-08-27 11:52:29 +05:30
- .as-if-foss
needs:
- "rspec-all frontend_fixture as-if-foss"
- "detect-tests"
script:
2023-03-17 16:20:25 +05:30
- if [[ -s "$RSPEC_CHANGED_FILES_PATH" ]] || [[ -s "$RSPEC_MATCHING_JS_FILES_PATH" ]]; then run_timed_command "yarn jest:ci:predictive"; fi
2022-08-27 11:52:29 +05:30
2020-05-24 23:13:21 +05:30
jest-integration:
extends:
2020-06-23 00:09:42 +05:30
- .frontend-test-base
2020-05-24 23:13:21 +05:30
- .frontend:rules:default-frontend-jobs
script:
2020-06-23 00:09:42 +05:30
- run_timed_command "yarn jest:integration --ci"
2023-06-20 00:43:36 +05:30
needs: ["rspec-all frontend_fixture", "graphql-schema-dump"]
2020-05-24 23:13:21 +05:30
2020-04-08 14:13:33 +05:30
coverage-frontend:
extends:
- .default-retry
2022-11-25 23:54:43 +05:30
- .default-utils-before_script
2020-05-24 23:13:21 +05:30
- .yarn-cache
2022-10-11 01:57:18 +05:30
- .frontend:rules:coverage-frontend
2021-11-11 11:23:49 +05:30
needs:
- job: "jest"
optional: true
2023-03-17 16:20:25 +05:30
- job: "jest predictive"
2021-11-11 11:23:49 +05:30
optional: true
2020-04-08 14:13:33 +05:30
stage: post-test
script:
2022-11-25 23:54:43 +05:30
- yarn_install_script
2020-06-23 00:09:42 +05:30
- run_timed_command "yarn node scripts/frontend/merge_coverage_frontend.js"
2021-03-08 18:12:59 +05:30
# Removing the individual coverage results, as we just merged them.
2022-10-11 01:57:18 +05:30
- if ls coverage-frontend/jest-* > /dev/null 2>&1; then
rm -r coverage-frontend/jest-*;
fi
2020-07-28 23:09:34 +05:30
coverage: '/^Statements\s*:\s*?(\d+(?:\.\d+)?)%/'
2020-04-08 14:13:33 +05:30
artifacts:
name: coverage-frontend
expire_in: 31d
paths:
- coverage-frontend/
2020-07-28 23:09:34 +05:30
reports:
2022-06-02 21:05:25 +05:30
coverage_report:
coverage_format: cobertura
path: coverage-frontend/cobertura-coverage.xml
2020-04-08 14:13:33 +05:30
2019-12-04 20:38:33 +05:30
webpack-dev-server:
extends:
- .default-retry
2022-11-25 23:54:43 +05:30
- .default-utils-before_script
2020-06-23 00:09:42 +05:30
- .yarn-cache
2020-03-13 15:44:24 +05:30
- .frontend:rules:default-frontend-jobs
2019-12-21 20:55:43 +05:30
stage: test
2020-05-24 23:13:21 +05:30
needs: []
2019-12-04 20:38:33 +05:30
variables:
WEBPACK_MEMORY_TEST: "true"
2020-01-01 13:55:28 +05:30
WEBPACK_VENDOR_DLL: "true"
2019-07-31 22:56:46 +05:30
script:
2022-11-25 23:54:43 +05:30
- yarn_install_script
2020-06-23 00:09:42 +05:30
- run_timed_command "retry yarn webpack-vendor"
- run_timed_command "node --expose-gc node_modules/.bin/webpack-dev-server --config config/webpack.config.js"
2020-01-01 13:55:28 +05:30
artifacts:
name: webpack-dev-server
expire_in: 31d
paths:
- webpack-dev-server.json
2020-06-23 00:09:42 +05:30
bundle-size-review:
extends:
- .default-retry
2022-11-25 23:54:43 +05:30
- .default-utils-before_script
2022-10-11 01:57:18 +05:30
- .assets-compile-cache
2020-06-23 00:09:42 +05:30
- .frontend:rules:bundle-size-review
2022-01-26 12:08:38 +05:30
image: ${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images:danger
2020-06-23 00:09:42 +05:30
stage: test
2022-10-11 01:57:18 +05:30
needs: []
2020-06-23 00:09:42 +05:30
script:
2022-11-25 23:54:43 +05:30
- yarn_install_script
2022-10-11 01:57:18 +05:30
- scripts/bundle_size_review
2020-06-23 00:09:42 +05:30
artifacts:
when: always
name: bundle-size-review
expire_in: 31d
paths:
2022-10-11 01:57:18 +05:30
- bundle-size-review/
2021-09-04 01:27:46 +05:30
.startup-css-check-base:
extends:
- .frontend-test-base
script:
- run_timed_command "yarn generate:startup_css"
- yarn check:startup_css
startup-css-check:
extends:
- .startup-css-check-base
- .frontend:rules:default-frontend-jobs
2023-06-20 00:43:36 +05:30
needs: ["compile-test-assets", "rspec-all frontend_fixture"]
2021-09-04 01:27:46 +05:30
startup-css-check as-if-foss:
extends:
- .startup-css-check-base
- .as-if-foss
- .frontend:rules:default-frontend-jobs-as-if-foss
needs:
- job: "compile-test-assets as-if-foss"
2021-11-18 22:05:49 +05:30
- job: "rspec-all frontend_fixture as-if-foss"
2021-09-30 23:02:18 +05:30
.compile-storybook-base:
extends:
- .frontend-test-base
- .storybook-yarn-cache
script:
2022-11-25 23:54:43 +05:30
- run_timed_command "retry yarn run storybook:install --frozen-lockfile"
- run_timed_command "yarn run storybook:build"
2021-11-18 22:05:49 +05:30
needs: ["graphql-schema-dump"]
2021-09-30 23:02:18 +05:30
compile-storybook:
extends:
- .compile-storybook-base
- .frontend:rules:default-frontend-jobs
2021-11-18 22:05:49 +05:30
needs:
- !reference [.compile-storybook-base, needs]
- job: "rspec-all frontend_fixture"
2021-09-30 23:02:18 +05:30
artifacts:
name: storybook
expire_in: 31d
when: always
paths:
- storybook/public
compile-storybook as-if-foss:
extends:
- .compile-storybook-base
- .as-if-foss
- .frontend:rules:default-frontend-jobs-as-if-foss
2021-11-18 22:05:49 +05:30
needs:
2023-01-13 00:05:48 +05:30
- job: "graphql-schema-dump as-if-foss"
2021-11-18 22:05:49 +05:30
- job: "rspec-all frontend_fixture as-if-foss"