GitLabプロジェクトのパイプライン

https://gitlab.com/gitlab-org/gitlabhttps://gitlab.com/gitlab-org/gitlab-foss のパイプライン(およびdev インスタンスのミラー)は、通常の.gitlab-ci.ymlで設定されます。 は、メンテナンスしやすいように.gitlab/ci/の下にファイルを含んでいます。

私たちは GitLabCI/CD の機能やベストプラクティスを可能な限りドッグフード化しようと努力しています。

概要

パイプラインの種類

rules:needs: キーワードを多用しているため、4つの主なパイプラインタイプがあり、以下に説明します。 複数の変更タイプを含むMRでは、複数のタイプのジョブを含むパイプラインがあることに注意してください(例えば、ドキュメントのみのパイプラインとコードのみのパイプラインの組み合わせ)。

医師専用のMRパイプライン

リファレンスパイプライン:https://gitlab.com/gitlab-org/gitlab/pipelines/135236627

graph LR subgraph "No needed jobs"; 1-1["danger-review (3.5 minutes)"]; click 1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8100542&udv=0" 1-50["docs lint (6.75 minutes)"]; click 1-50 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356757&udv=0" end

コード専用MRパイプライン

リファレンスパイプライン:https://gitlab.com/gitlab-org/gitlab/pipelines/136295694

graph RL; classDef criticalPath fill:#f66; subgraph "No needed jobs"; 1-1["danger-review (3.5 minutes)"]; click 1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8100542&udv=0" 1-2["build-qa-image (3.4 minutes)"]; click 1-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914325&udv=0" 1-3["compile-test-assets (9.06 minutes)"]; click 1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914317&udv=0" 1-4["compile-test-assets as-if-foss (8.35 minutes)"]; click 1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356616&udv=0" 1-5["compile-production-assets (22 minutes)"]; click 1-5 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914312&udv=0" 1-6["setup-test-env (8.22 minutes)"]; click 1-6 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914315&udv=0" 1-7["review-stop-failed-deployment"]; 1-8["dependency_scanning"]; 1-9["qa:internal, qa:internal-as-if-foss"]; 1-11["qa:selectors, qa:selectors-as-if-foss"]; 1-14["retrieve-tests-metadata (1.5 minutes)"]; click 1-14 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356697&udv=0" 1-15["code_quality"]; 1-16["brakeman-sast"]; 1-17["eslint-sast"]; 1-18["kubesec-sast"]; 1-19["nodejs-scan-sast"]; 1-20["secrets-sast"]; 1-21["static-analysis (17 minutes)"]; click 1-21 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914471&udv=0" class 1-3 criticalPath; class 1-6 criticalPath; end 2_1-1["graphql-reference-verify (5 minutes)"]; click 2_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356715&udv=0" 2_1-2["memory-static (4.75 minutes)"]; click 2_1-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356721&udv=0" 2_1-3["run-dev-fixtures (5 minutes)"]; click 2_1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356729&udv=0" 2_1-4["run-dev-fixtures-ee (5 minutes)"]; click 2_1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356731&udv=0" subgraph "Needs `setup-test-env`"; 2_1-1 & 2_1-2 & 2_1-3 & 2_1-4 --> 1-6; end 2_2-2["frontend-fixtures (17.2 minutes)"]; class 2_2-2 criticalPath; click 2_2-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910143&udv=0" 2_2-3["frontend-fixtures-as-if-foss (8.75 minutes)"]; click 2_2-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910154&udv=0" 2_2-4["memory-on-boot (7.19 minutes)"]; click 2_2-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356727&udv=0" 2_2-5["webpack-dev-server (6.1 minutes)"]; click 2_2-5 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8404303&udv=0" subgraph "Needs `setup-test-env` & `compile-test-assets`"; 2_2-2 & 2_2-4 & 2_2-5 --> 1-6 & 1-3; 2_2-3 --> 1-6 & 1-4; end 2_3-1["build-assets-image (2.5 minutes)"]; subgraph "Needs `compile-production-assets`"; 2_3-1 --> 1-5 end 2_4-1["package-and-qa (manual)"]; subgraph "Needs `build-qa-image`"; 2_4-1 --> 1-2; click 2_4-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914305&udv=0" end 2_5-1["rspec & db jobs (12-22 minutes)"]; subgraph "Needs `compile-test-assets`, `setup-test-env`, & `retrieve-tests-metadata`"; 2_5-1 --> 1-3 & 1-6 & 1-14; class 2_5-1 criticalPath; click 2_5-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations" end 3_1-1["jest (15 minutes)"]; class 3_1-1 criticalPath; click 3_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914204&udv=0" 3_1-2["karma (8 minutes)"]; click 3_1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914200&udv=0" 3_1-3["jest-as-if-foss (19.7 minutes)"]; click 3_1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914205&udv=0" 3_1-4["karma-as-if-foss (7.5 minutes)"]; click 3_1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914203&udv=0" subgraph "Needs `frontend-fixtures`"; 3_1-1 & 3_1-2 --> 2_2-2; 3_1-3 & 3_1-4 --> 2_2-3; end 3_2-1["rspec:coverage (6.5 minutes)"]; subgraph "Depends on `rspec` jobs"; 3_2-1 -.->|"(don't use needs because of limitations)"| 2_5-1; class 3_2-1 criticalPath; click 3_2-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7248745&udv=0" end 4_1-1["coverage-frontend (3.6 minutes)"]; subgraph "Needs `jest`"; 4_1-1 --> 3_1-1; class 4_1-1 criticalPath; click 4_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910777&udv=0" end

フロントエンドのみのMRパイプライン

リファレンスパイプライン:https://gitlab.com/gitlab-org/gitlab/pipelines/134661039

graph RL; classDef criticalPath fill:#f66; subgraph "No needed jobs"; 1-1["danger-review (3.5 minutes)"]; click 1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8100542&udv=0" 1-2["build-qa-image (3.4 minutes)"]; click 1-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914325&udv=0" 1-3["compile-test-assets (9.06 minutes)"]; click 1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914317&udv=0" 1-4["compile-test-assets as-if-foss (8.35 minutes)"]; click 1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356616&udv=0" 1-5["compile-production-assets (22 minutes)"]; click 1-5 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914312&udv=0" 1-6["setup-test-env (8.22 minutes)"]; click 1-6 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914315&udv=0" 1-7["review-stop-failed-deployment"]; 1-8["dependency_scanning"]; 1-9["qa:internal, qa:internal-as-if-foss"]; 1-11["qa:selectors, qa:selectors-as-if-foss"]; 1-14["retrieve-tests-metadata (1.5 minutes)"]; click 1-14 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356697&udv=0" 1-15["code_quality"]; 1-16["brakeman-sast"]; 1-17["eslint-sast"]; 1-18["kubesec-sast"]; 1-19["nodejs-scan-sast"]; 1-20["secrets-sast"]; 1-21["static-analysis (17 minutes)"]; click 1-21 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914471&udv=0" class 1-3 criticalPath; class 1-5 criticalPath; class 1-6 criticalPath; end 2_1-1["graphql-reference-verify (5 minutes)"]; click 2_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356715&udv=0" 2_1-2["memory-static (4.75 minutes)"]; click 2_1-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356721&udv=0" 2_1-3["run-dev-fixtures (5 minutes)"]; click 2_1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356729&udv=0" 2_1-4["run-dev-fixtures-ee (5 minutes)"]; click 2_1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356731&udv=0" subgraph "Needs `setup-test-env`"; 2_1-1 & 2_1-2 & 2_1-3 & 2_1-4 --> 1-6; end 2_2-2["frontend-fixtures (17.2 minutes)"]; class 2_2-2 criticalPath; click 2_2-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910143&udv=0" 2_2-3["frontend-fixtures-as-if-foss (8.75 minutes)"]; click 2_2-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910154&udv=0" 2_2-4["memory-on-boot (7.19 minutes)"]; click 2_2-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356727&udv=0" 2_2-5["webpack-dev-server (6.1 minutes)"]; click 2_2-5 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8404303&udv=0" subgraph "Needs `setup-test-env` & `compile-test-assets`"; 2_2-2 & 2_2-4 & 2_2-5 --> 1-6 & 1-3; 2_2-3 --> 1-6 & 1-4; end 2_3-1["build-assets-image (2.5 minutes)"]; class 2_3-1 criticalPath; subgraph "Needs `compile-production-assets`"; 2_3-1 --> 1-5 end 2_4-1["package-and-qa (manual)"]; subgraph "Needs `build-qa-image` & `build-assets-image`"; 2_4-1 --> 1-2 & 2_3-1; click 2_4-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914305&udv=0" end 2_5-1["rspec & db jobs (12-22 minutes)"]; subgraph "Needs `compile-test-assets`, `setup-test-env, & `retrieve-tests-metadata`"; 2_5-1 --> 1-3 & 1-6 & 1-14; class 2_5-1 criticalPath; click 2_5-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations" end 2_6-1["review-build-cng (27.3 minutes)"]; subgraph "Needs `build-assets-image`"; 2_6-1 --> 2_3-1; class 2_6-1 criticalPath; click 2_6-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914314&udv=0" end 3_1-1["jest (15 minutes)"]; class 3_1-1 criticalPath; click 3_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914204&udv=0" 3_1-2["karma (8 minutes)"]; click 3_1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914200&udv=0" 3_1-3["jest-as-if-foss (19.7 minutes)"]; click 3_1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914205&udv=0" 3_1-4["karma-as-if-foss (7.5 minutes)"]; click 3_1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914203&udv=0" subgraph "Needs `frontend-fixtures`"; 3_1-1 & 3_1-3 --> 2_2-2; 3_1-2 & 3_1-4 --> 2_2-3; end 3_2-1["rspec:coverage (6.5 minutes)"]; subgraph "Depends on `rspec` jobs"; 3_2-1 -.->|"(don't use needs because of limitations)"| 2_5-1; class 3_2-1 criticalPath; click 3_2-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7248745&udv=0" end 4_1-1["coverage-frontend (3.6 minutes)"]; subgraph "Needs `jest`"; 4_1-1 --> 3_1-1; class 4_1-1 criticalPath; click 4_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910777&udv=0" end 3_3-1["review-deploy (6 minutes)"]; subgraph "Played by `review-build-cng`"; 3_3-1 --> 2_6-1; class 3_3-1 criticalPath; click 3_3-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6721130&udv=0" end 4_2-1["review-qa-smoke (8 minutes)"]; click 4_2-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6729805&udv=0" 4_2-2["review-performance (4 minutes)"]; click 4_2-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356817&udv=0" 4_2-3["dast (18 minutes)"]; click 4_2-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356819&udv=0" class 4_2-3 criticalPath; subgraph "Played by `review-deploy`"; 4_2-1 & 4_2-2 & 4_2-3 -.->|"(don't use needs because of limitations)"| 3_3-1; end

QAのみのMRパイプライン

リファレンスパイプライン:https://gitlab.com/gitlab-org/gitlab/pipelines/134645109

graph RL; classDef criticalPath fill:#f66; subgraph "No needed jobs"; 1-1["danger-review (3.5 minutes)"]; click 1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8100542&udv=0" 1-2["build-qa-image (3.4 minutes)"]; click 1-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914325&udv=0" 1-3["compile-test-assets (9.06 minutes)"]; click 1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914317&udv=0" 1-4["compile-test-assets as-if-foss (8.35 minutes)"]; click 1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356616&udv=0" 1-5["compile-production-assets (22 minutes)"]; click 1-5 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914312&udv=0" 1-6["setup-test-env (8.22 minutes)"]; click 1-6 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914315&udv=0" 1-7["review-stop-failed-deployment"]; 1-8["dependency_scanning"]; 1-9["qa:internal, qa:internal-as-if-foss"]; 1-11["qa:selectors, qa:selectors-as-if-foss"]; 1-14["retrieve-tests-metadata (1.5 minutes)"]; click 1-14 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356697&udv=0" 1-15["code_quality"]; 1-16["brakeman-sast"]; 1-17["eslint-sast"]; 1-18["kubesec-sast"]; 1-19["nodejs-scan-sast"]; 1-20["secrets-sast"]; 1-21["static-analysis (17 minutes)"]; click 1-21 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914471&udv=0" class 1-5 criticalPath; end 2_1-1["graphql-reference-verify (5 minutes)"]; click 2_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356715&udv=0" subgraph "Needs `setup-test-env`"; 2_1-1 --> 1-6; end 2_3-1["build-assets-image (2.5 minutes)"]; subgraph "Needs `compile-production-assets`"; 2_3-1 --> 1-5 class 2_3-1 criticalPath; end 2_4-1["package-and-qa (108 minutes)"]; subgraph "Needs `build-qa-image` & `build-assets-image`"; 2_4-1 --> 1-2 & 2_3-1; class 2_4-1 criticalPath; click 2_4-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914305&udv=0" end

workflow:rules

workflow:rules キーワード を使用して、パイプラインを作成するかどうかを決定するデフォルトルールを定義しています。

これらのルールはhttps://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab-ci.yml、以下のように定義されています:

  1. $FORCE_GITLAB_CI が設定されている場合は、パイプラインを作成します。
  2. マージリクエストの場合は、パイプラインを作成します。
  3. master ブランチでは、パイプラインを作成します (これには、スケジュール、プッシュ、マージなどが含まれます)。
  4. タグについては、パイプラインを作成します。
  5. $GITLAB_INTERNAL が設定されていない場合は、パイプラインを作成しないでください。
  6. 安定版ブランチ、自動デプロイブランチ、セキュリティブランチでは、パイプラインを作成します。
  7. それ以外の場合(MRのいないブランチをプッシュする場合など)には、パイプラインは作成されません。

PostgreSQLのバージョンテスト

現在のバージョンのテスト

どこで? PostgreSQL バージョン
MR一覧 11
master (非定期パイプライン) 11
2時間おきパイプライン 11
nightly 予定パイプライン 11, 12

長期計画

Omnibus GitLabに同梱されているPostgreSQLのバージョンに従います:

PostgreSQL バージョン 13.0(2020年5月) 13.1(2020年6月) 13.2(2020年7月) 13.3(2020年8月) 13.4, 13.5 13.6(2020年11月) 14.0 (2021年5月?)
PG11 MRs/master/2-hour/nightly MRs/master/2-hour/nightly MRs/master/2-hour/nightly MRs/master/2-hour/nightly MRs/master/2-hour/nightly nightly -
PG12 - - nightly 2-hour/nightly 2-hour/nightly MRs/2-hour/nightly 2-hour/nightly
PG13 - - - - - - MRs/2-hour/nightly

テストジョブ

詳細については、継続的インテグレーション(CI) コンテキストでの GitLab テストを参照してください。

レビューアプリのジョブ

詳しくはレビューアプリ専用ページをご覧ください。

As-if-FOSSジョブ

* as-if-foss ジョブは GitLab のテストスイートを「as-if-FOSS」、つまりgitlab-org/gitlab-foss プロジェクトのコンテキストでジョブが実行されるかのように実行することができます。これらのジョブは以下の場合にのみ作成されます:

  • gitlab-org/security/gitlab マージリクエスト。
  • タイトルにRUN AS-IF-FOSS を含むリクエストをマージします。
  • CI の設定を変更するマージリクエストです。

* as-if-foss ジョブにはFOSS_ONLY='1' 変数が設定されており、テストの実行前に EE 固有のフォルダが削除されます。

その意図は、gitlab-org/gitlab プロジェクトがgitlab-org/gitlab-foss プロジェクトと同期された時点で、変更によって障害が発生しないようにすることです。

パフォーマンス

中断可能パイプライン

デフォルトでは、すべてのジョブは割り込み可能です。ただし、dont-interrupt-me のジョブはmasterで自動的に実行され、それ以外はmanualとなります。

マージリクエストに新しいコミットをプッシュしても実行中のパイプラインを終了させたい場合は、プッシュする前に必ずdont-interrupt-me ジョブを開始してください。

キャッシュ戦略

  1. デフォルトでは、すべてのジョブはキャッシュをプルするだけです。
  2. つまり、キャッシュはジョブを高速化するためだけに存在するのです。
  3. 現在、.gitlab/ci/global.gitlab-ci.yml、固定キーで6種類のキャッシュが定義されています:
    • .rails-cache.
    • .static-analysis-cache.
    • .qa-cache
    • .yarn-cache.
    • .assets-compile-cache (キーには${NODE_ENV} 、実際には2つの異なるキャッシュが含まれています)。
  4. 2時間ごとにスケジュールされたパイプラインで実行される6つの特定のジョブだけが、キャッシュにプッシュ(つまり更新)されます:
  5. これらのジョブは、UPDATE CACHEをタイトルに含むマージリクエストで実行されます。

クローン前工程

GitLab.com のgitlab-org/gitlab プロジェクトでは、リポジトリの最近のアーカイブをプロジェクトにシードするために、pre-clone ステップを使っています。 これにはいくつかの理由があります:

  • 800MBのダウンロードが数秒で済むので、Gitクローンをフルに使うよりもビルドが速くなります。
  • デルタが小さいほど、git pack-objectsに費やす時間が短くなるため、ファイルサーバーの負荷が大幅に軽減されます。

クローン前のステップは、GitLab.comの共有ランナーで定義された変数CI_PRE_CLONE_SCRIPT

CI_PRE_CLONE_SCRIPT は現在、プロジェクトの CI/CD 変数として定義されています:

echo "Downloading archived master..."
wget -O /tmp/gitlab.tar.gz https://storage.googleapis.com/gitlab-ci-git-repo-cache/project-278964/gitlab-master.tar.gz

if [ ! -f /tmp/gitlab.tar.gz ]; then
    echo "Repository cache not available, cloning a new directory..."
    exit
fi

rm -rf $CI_PROJECT_DIR
echo "Extracting tarball into $CI_PROJECT_DIR..."
mkdir -p $CI_PROJECT_DIR
cd $CI_PROJECT_DIR
tar xzf /tmp/gitlab.tar.gz
rm -f /tmp/gitlab.tar.gz
chmod a+w $CI_PROJECT_DIR

cache-repo](https://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab/ci/cache-repo.gitlab-ci.yml#L5)スクリプトの最初のステップでは、gitlab-master.tar.gz を Google Cloud Storage からダウンロードします。[という GitLab CI ジョブがあり、このアーカイブを最新の状態に保つ役割を担っています。 スケジュールされたパイプラインで、2時間ごとに次のことを行います:

  1. GitLab.com上のgitlab-org/gitlab リポジトリの新鮮なクローンを作成します。
  2. データを.tar.gzとして保存します。
  3. Google Cloud Storageのバケットにアップロードします。

この設定でCIジョブが実行されると、次のように表示されます:

$ eval "$CI_PRE_CLONE_SCRIPT"
Downloading archived master...
Extracting tarball into /builds/group/project...
Fetching changes...
Reinitialized existing Git repository in /builds/group/project/.git/

Reinitialized existing Git repository のメッセージは、クローン前のステップがうまくいったことを示しています。ランナーはgit initを実行し、GitLab リポジトリから取得する適切な設定で Git の設定を上書きします。

CI_REPO_CACHE_CREDENTIALS には、gitlab-ci-git-repo-cache バケットにアップロードする Google Cloud サービスアカウントの JSON が含まれています。これらの認証情報は、1Password GitLab.com Production vault に保存されます。

このバケットはランナーと同じ大陸にある必要があります。

CIコンフィギュレーション内部

ステージ

現在のステージは:

  • syncこのステージは、https://gitlab.com/gitlab-org/gitlab からhttps://gitlab.com/gitlab-org/gitlab-fossへの変更を同期するために使用されます。
  • prepareこのステージには、後続ステージのジョブが必要とするアーティファクトを準備するジョブが含まれます。
  • build-imagesこのステージには、後続のステージや下流のパイプラインのジョブが必要とするDockerイメージを準備するジョブが含まれます。
  • fixtures: このステージはフロントエンドのテストで必要なフィクスチャを準備するジョブを含みます。
  • testこのステージには、ほとんどのテスト、DB/マイグレーションジョブ、静的解析ジョブが含まれます。
  • post-testこのステージには、レポートを作成したり、test ステージのジョブ(カバレッジ、ナップザックメタデータなど)からデータを収集したりするジョブが含まれます。
  • review-prepareこのステージには、後に(レビュアー)レビューアプリのデプロイで使用されるCNGイメージをビルドするジョブが含まれます(詳細はレビューアプリを参照)。
  • reviewこのステージにはGitLabとDocsレビューアプリをデプロイするジョブが含まれます。
  • qaこのステージには、前のステージでデプロイされたレビューアプリに対してQAタスクを実行するジョブが含まれます。
  • post-qa: このステージには、レポートを作成したり、qa ステージのジョブからデータを収集したりするジョブが含まれます(レビューアプリのパフォーマンスレポートなど)。
  • pages: このステージには、様々なレポーターをGitLab Pagesとしてデプロイするジョブが含まれます(例:coverage-ruby,coverage-javascript,webpack-report.

デフォルト画像

デフォルトの画像は.gitlab-ci.ymlで定義されています。

Ruby、Go、Git、Git LFS、Chrome、Node、Yarn、PostgreSQL、Graphics Magickが含まれています。

パイプラインで使用されるイメージはgitlab-org/gitlab-build-imagesプロジェクトで設定され、冗長性のためにgitlab/gitlab-build-imagesにプッシュミラーされています。

現在のバージョンのビルドイメージは、“Used byGitLab section “で確認できます。

デフォルト変数

定義済みの変数に加えて、各パイプラインには、https://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab-ci.ymlで定義されたデフォルト変数が含まれています。

一般的なジョブの定義

ほとんどのジョブは、.gitlab/ci/global.gitlab-ci.ymlで定義された、単一の設定パラメータにスコープされたいくつかの CI 定義から拡張されます。

ジョブ定義 説明
.default-tags ジョブが当社の専用ランナーを使用していることを確認するため、ジョブがgitlab-org タグを持っていることを確認します。
.default-retry unknown_failure,api_failure,runner_system_failure,job_execution_timeout,stuck_or_timeout_failureのときにジョブの再試行を許可します。
.default-before_script データベースの実行が必要なRuby/Railsタスク(テストなど)に適したデフォルトのbefore_script 定義をジョブが使用できるようにします。
.rails-cache ジョブがRuby/Railsタスクに適したデフォルトのcache 定義を使用できるようにします。
.static-analysis-cache 静的解析タスクに適したデフォルトのcache 定義をジョブが使用できるようにします。
.yarn-cache yarn installを実行するフロントエンドジョブに適したデフォルトのcache 定義をジョブが使用できるようにします。
.assets-compile-cache アセットをコンパイルするフロントエンドジョブに適したデフォルトのcache 定義をジョブが使用できるようにします。
.use-pg11 ジョブがpostgres:11.6 およびredis:alpine サービスを使用できるようにします。
.use-pg11-ee .use-pg11 と同じですが、docker.elastic.co/elasticsearch/elasticsearch:6.4.2 のサービスも利用できます。
.use-kaniko ジョブがkaniko ツールを使って Docker イメージをビルドできるようにします。
.as-if-foss FOSS_ONLY='1' 環境変数を設定してFOSSプロジェクトをシミュレートしてください。

rulesif: 条件と パターンchanges:

私たちはrules キーワード を多用しています。

すべてのrules 定義はhttps://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/ci/rules.gitlab-ci.ymlで定義され、extendsを介して個々のジョブに含まれます。

rules 定義はif: 条件とchanges: パターンで Composer されています。これらはrules.gitlab-ci.ymlでも定義されており、YAML アンカーを介してrules 定義に含まれています。

if: 条件

if: 条件 説明 備考
if-not-canonical-namespace プロジェクトが正規 (gitlab-org/) またはセキュリティ (gitlab-org/security) 名前空間にない場合にマッチします。 フォーク用のジョブを作成する場合(when: on_success\|manual)、またはフォーク用のジョブを作成しない場合(when: never)に使用します。
if-not-ee プロジェクトがEEでない場合(プロジェクト名がgitlab またはgitlab-ee)にマッチします。 FOSSプロジェクト内でのみジョブを作成する場合(when: on_success|manual)、またはプロジェクトがEEである場合はジョブを作成しない場合(when: never)に使用します。
if-not-foss プロジェクトがFOSSでない場合(プロジェクト名がgitlab-fossgitlab-cegitlabhqでない場合)にマッチします。 EEプロジェクトでのみジョブを作成する場合(when: on_success|manual)、プロジェクトがFOSSの場合はジョブを作成しない場合(when: never)に使用します。
if-default-refs パイプラインがmaster/^[\d-]+-stable(-ee)?$/ (安定ブランチ)、/^\d+-\d+-auto-deploy-\d+$/ (自動デプロイブランチ)、/^security\// (セキュリティブランチ)、マージリクエスト、タグの場合にマッチします。 このデフォルト設定のブランチにはジョブが作成されないことに注意してください。
if-master-refs 現在のブランチがmasterである場合にマッチします。  
if-master-or-tag パイプラインがmaster ブランチのものか、タグのものかにマッチします。  
if-merge-request パイプラインがマージリクエストである場合にマッチします。  
if-nightly-master-schedule パイプラインが$NIGHTLY が設定されたmaster スケジュールパイプラインの場合にマッチします。  
if-dot-com-gitlab-org-schedule GitLab.comのgitlab-org グループのスケジュールされたパイプラインにジョブの作成を制限します。  
if-dot-com-gitlab-org-master GitLab.comのgitlab-org グループのmaster ブランチにジョブ作成を制限します。  
if-dot-com-gitlab-org-merge-request ジョブの作成をGitLab.comのgitlab-org グループのマージリクエストに制限します。  
if-dot-com-gitlab-org-and-security-tag GitLab.com のgitlab-orggitlab-org/security グループのタグにジョブ作成を制限します。  
if-dot-com-gitlab-org-and-security-merge-request ジョブの作成を、GitLab.com のgitlab-orggitlab-org/security グループのマージリクエストに制限します。  
if-dot-com-ee-schedule GitLab.comのgitlab-org/gitlab プロジェクトのスケジュールされたパイプラインにジョブを制限します。  
if-cache-credentials-schedule ジョブを$CI_REPO_CACHE_CREDENTIALS 変数が設定されたスケジュールされたパイプラインに制限します。  

changes: パターン

changes: パターン 説明
ci-patterns CI設定関連の変更にのみジョブを作成します。
yaml-patterns YAML関連の変更にのみジョブを作成します。
docs-patterns ドキュメント関連の変更にのみジョブを作成します。
frontend-dependency-patterns フロントエンドの依存関係が更新されたときのみ、ジョブを作成します (例:package.json,yarn.lock)。
frontend-patterns フロントエンド関連の変更にのみジョブを作成します。
backstage-patterns バックステージ関連の変更 (デンジャー、フィクスチャ、RuboCop、スペックなど) にのみジョブを作成します。
code-patterns コードに関連する変更にのみジョブを作成します。
qa-patterns QA関連の変更にのみジョブを作成します。
code-backstage-patterns code-patternsbackstage-patternsの組み合わせ。
code-qa-patterns code-patternsqa-patternsの組み合わせ。
code-backstage-qa-patterns code-patterns,backstage-patterns,qa-patternsの組み合わせ。

開発者のドキュメントに戻る