From 1d43f9f5907acfb257bc3c3b5e5bf2aaa159103d Mon Sep 17 00:00:00 2001 From: Lukas Eipert Date: Mon, 26 Aug 2019 10:22:04 +0200 Subject: [PATCH 1/4] ci: Dogfood Directed Acyclic Graphs GitLab released Directed Acyclic Graphs with 12.2. Theoretically this could help improve build time by running jobs as soon as dependencies are fulfilled: https://docs.gitlab.com/ee/ci/directed_acyclic_graph/ --- .gitlab-ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9b460f3ec..e69c7b38ab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,7 +42,7 @@ build: lint: extends: .yarn_install - dependencies: [] + needs: [] stage: build-and-check script: - yarn eslint @@ -58,7 +58,8 @@ visual: extends: .yarn_install tags: - gitlab-org # This allows us to use higher performance runners - dependencies: [] + needs: + - build_docker_image stage: build-and-check script: - if ${CSS_URL}; then CSS_URL=${CSS_URL} yarn test; else yarn test; fi @@ -83,7 +84,7 @@ update_snapshots: review: stage: deploy - dependencies: + needs: - build script: - rsync -av --delete public /srv/nginx/pages/$CI_COMMIT_REF_SLUG @@ -101,8 +102,8 @@ review: - deploy review_stop: - dependencies: [] stage: deploy + needs: [] script: - rm -rf public /srv/nginx/pages/$CI_COMMIT_REF_SLUG when: manual @@ -120,7 +121,7 @@ review_stop: pages: stage: deploy - dependencies: + needs: - build script: - echo "Deploying to Pages" @@ -133,7 +134,7 @@ pages: upload_artifacts: extends: .yarn_install stage: release - dependencies: [] + needs: [] script: - yarn build - yarn pack --filename gitlab-ui.$CI_COMMIT_REF_SLUG.tgz @@ -148,7 +149,7 @@ upload_artifacts: publish: extends: .yarn_install stage: release - dependencies: [] + needs: [] script: - yarn build - $(yarn bin)/semantic-release -- GitLab From 1fa8f0e8259b0ffb9db44c34fff51eba4e7baaf0 Mon Sep 17 00:00:00 2001 From: Lukas Eipert Date: Mon, 26 Aug 2019 10:48:40 +0200 Subject: [PATCH 2/4] ci: Move build logic to build step At the moment we build (`yarn build`) the rolled up version of GitLab UI in two build jobs: - publish - upload_artifacts This moves this to the common "build" job and let's both of those jobs depend on it. This should help us safe compute time in both cases. --- .gitlab-ci.yml | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e69c7b38ab..088522b993 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ stages: - pre-build - build-and-check - deploy - - release + - publish .yarn_install: image: $PUPPETEER_IMAGE @@ -34,11 +34,13 @@ build: stage: build-and-check script: - yarn storybook-static + - yarn build - mkdir public - mv storybook/* public artifacts: paths: - public + - dist lint: extends: .yarn_install @@ -133,25 +135,34 @@ pages: upload_artifacts: extends: .yarn_install - stage: release - needs: [] + stage: deploy + variables: + TAR_ARCHIVE_NAME: gitlab-ui.$CI_COMMIT_REF_SLUG.tgz + needs: + - build script: - - yarn build - - yarn pack --filename gitlab-ui.$CI_COMMIT_REF_SLUG.tgz - - echo "The package.json dependency URL is https://gitlab.com/gitlab-org/gitlab-ui/-/jobs/$CI_JOB_ID/artifacts/raw/gitlab-ui.$CI_COMMIT_REF_SLUG.tgz" + - yarn pack --filename $TAR_ARCHIVE_NAME + - echo "The package.json dependency URL is $CI_PROJECT_URL/-/jobs/$CI_JOB_ID/artifacts/raw/$TAR_ARCHIVE_NAME" artifacts: when: always paths: - - gitlab-ui.$CI_COMMIT_REF_SLUG.tgz + - $TAR_ARCHIVE_NAME only: - /.+/@gitlab-org/gitlab-ui -publish: + +publish_to_npm: extends: .yarn_install - stage: release - needs: [] + # We need to run `publish` after pages, so that pages will get deployed + # properly, as the publish-to-npm step will create a new commit and this + # could lead to a side-effect where pages don't get published because of + # the commit being made before `pages` had a chance to run + stage: publish + # This job doesn't use the DAG feature, because we don't want it to + # run in case another job in the previous stages fails + dependencies: + - build script: - - yarn build - $(yarn bin)/semantic-release only: - master@gitlab-org/gitlab-ui -- GitLab From b8cb2695eaac0acaa7c64c920204b09b2c108792 Mon Sep 17 00:00:00 2001 From: Lukas Eipert Date: Mon, 26 Aug 2019 10:56:55 +0200 Subject: [PATCH 3/4] ci: Use gitlab-org runner for the build step The gitlab-org runners have higher performance, so this should help us running pipelines faster --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 088522b993..ed2016446a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,6 +31,8 @@ build_docker_image: build: extends: .yarn_install + tags: + - gitlab-org # This allows us to use higher performance runners stage: build-and-check script: - yarn storybook-static -- GitLab From 7e20896a0d6232a119c20d7c930e1b7bc51196b0 Mon Sep 17 00:00:00 2001 From: Lukas Eipert Date: Mon, 26 Aug 2019 11:13:16 +0200 Subject: [PATCH 4/4] ci: Only use puppeteer image when needed We only need to use the puppeteer image for the visual tests. In all other node jobs we can use the much smaller node image directly. --- .gitlab-ci.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ed2016446a..e7a8083042 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,8 +8,15 @@ stages: - deploy - publish -.yarn_install: +.puppeteer: image: $PUPPETEER_IMAGE + +.node: + image: node:12 + variables: + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true' + +.yarn_install: before_script: - yarn install @@ -30,7 +37,7 @@ build_docker_image: - ./build-docker.sh build: - extends: .yarn_install + extends: [.node, .yarn_install] tags: - gitlab-org # This allows us to use higher performance runners stage: build-and-check @@ -45,7 +52,7 @@ build: - dist lint: - extends: .yarn_install + extends: [.node, .yarn_install] needs: [] stage: build-and-check script: @@ -59,7 +66,7 @@ lint: || echo "No Vue component contains