2019-09-17 10:16:34 -04:00
# Pipelines for the GitLab project
2019-11-27 01:06:40 -05:00
Pipelines for < https: / / gitlab . com / gitlab-org / gitlab > and < https: / / gitlab . com / gitlab-org / gitlab-foss > (as well as the
2019-09-17 10:16:34 -04:00
`dev` instance's mirrors) are configured in the usual
[`.gitlab-ci.yml` ](https://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab-ci.yml )
which itself includes files under
[`.gitlab/ci/` ](https://gitlab.com/gitlab-org/gitlab/tree/master/.gitlab/ci )
for easier maintenance.
We're striving to [dogfood ](https://about.gitlab.com/handbook/engineering/#dogfooding )
GitLab [CI/CD features and best-practices ](../ci/yaml/README.md )
as much as possible.
## Stages
The current stages are:
2019-11-27 01:06:40 -05:00
- `sync` : This stage is used to synchronize changes from < https: // gitlab . com / gitlab-org / gitlab > to
< https: / / gitlab . com / gitlab-org / gitlab-foss > .
2019-09-17 10:16:34 -04:00
- `prepare` : This stage includes jobs that prepare artifacts that are needed by
jobs in subsequent stages.
- `test` : This stage includes most of the tests, DB/migration jobs, and static analysis jobs.
2019-11-29 10:06:43 -05:00
- `post-test` : This stage includes jobs that build reports or gather data from
the `test` stage's jobs (e.g. coverage, Knapsack metadata etc.).
2019-09-17 10:16:34 -04:00
- `review-prepare` : This stage includes a job that build the CNG images that are
later used by the (Helm) Review App deployment (see
[Review Apps ](testing_guide/review_apps.md ) for details).
- `review` : This stage includes jobs that deploy the GitLab and Docs Review Apps.
- `qa` : This stage includes jobs that perform QA tasks against the Review App
that is deployed in the previous stage.
2019-11-29 10:06:43 -05:00
- `post-qa` : This stage includes jobs that build reports or gather data from
the `qa` stage's jobs (e.g. Review App performance report).
2019-11-25 10:06:45 -05:00
- `notification` : This stage includes jobs that sends notifications about pipeline status.
2019-09-17 10:16:34 -04:00
- `pages` : This stage includes a job that deploys the various reports as
2019-11-27 01:06:40 -05:00
GitLab Pages (e.g. < https: / / gitlab-org . gitlab . io / gitlab / coverage-ruby / > ,
2019-09-17 10:16:34 -04:00
< https: / / gitlab-org . gitlab . io / gitlab / coverage-javascript / > ,
< https: / / gitlab-org . gitlab . io / gitlab / webpack-report / > ).
## Default image
The default image is currently
2020-02-06 04:09:06 -05:00
`registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.6.5-golang-1.12-git-2.24-lfs-2.9-chrome-73.0-node-12.x-yarn-1.21-postgresql-9.6-graphicsmagick-1.3.34` .
2019-10-31 02:06:31 -04:00
2020-02-06 04:09:06 -05:00
It includes Ruby 2.6.5, Go 1.12, Git 2.24, Git LFS 2.9, Chrome 73, Node 12, Yarn 1.21,
2020-03-09 08:07:45 -04:00
PostgreSQL 9.6, and Graphics Magick 1.3.34.
2019-09-17 10:16:34 -04:00
The images used in our pipelines are configured in the
[`gitlab-org/gitlab-build-images` ](https://gitlab.com/gitlab-org/gitlab-build-images )
project, which is push-mirrored to < https: / / dev . gitlab . org / gitlab / gitlab-build-images >
for redundancy.
The current version of the build images can be found in the
2019-10-31 02:06:31 -04:00
["Used by GitLab section" ](https://gitlab.com/gitlab-org/gitlab-build-images/blob/master/.gitlab-ci.yml ).
2019-09-17 10:16:34 -04:00
## Default variables
In addition to the [predefined variables ](../ci/variables/predefined_variables.md ),
2019-10-31 02:06:31 -04:00
each pipeline includes default variables defined in
< https: / / gitlab . com / gitlab-org / gitlab / blob / master / . gitlab-ci . yml > .
2019-09-17 10:16:34 -04:00
## Common job definitions
Most of the jobs [extend from a few CI definitions ](../ci/yaml/README.md#extends )
2020-03-09 08:07:45 -04:00
defined in [`.gitlab/ci/global.gitlab-ci.yml` ](https://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab/ci/global.gitlab-ci.yml )
that are scoped to a single [configuration parameter ](../ci/yaml/README.md#configuration-parameters ).
2019-09-17 10:16:34 -04:00
2020-02-18 10:08:51 -05:00
| Job definitions | Description |
|------------------|-------------|
| `.default-tags` | Ensures a job has the `gitlab-org` tag to ensure it's using our dedicated runners. |
| `.default-retry` | Allows a job to [retry ](../ci/yaml/README.md#retry ) upon `unknown_failure` , `api_failure` , `runner_system_failure` , `job_execution_timeout` , or `stuck_or_timeout_failure` . |
| `.default-before_script` | Allows a job to use a default `before_script` definition suitable for Ruby/Rails tasks that may need a database running (e.g. tests). |
| `.default-cache` | Allows a job to use a default `cache` definition suitable for Ruby/Rails and frontend tasks. |
| `.use-pg9` | Allows a job to use the `postgres:9.6.17` and `redis:alpine` services. |
| `.use-pg10` | Allows a job to use the `postgres:10.12` and `redis:alpine` services. |
2020-03-09 08:07:45 -04:00
| `.use-pg11` | Allows a job to use the `postgres:11.6` and `redis:alpine` services. |
2020-02-18 10:08:51 -05:00
| `.use-pg9-ee` | Same as `.use-pg9` but also use the `docker.elastic.co/elasticsearch/elasticsearch:6.4.2` services. |
| `.use-pg10-ee` | Same as `.use-pg10` but also use the `docker.elastic.co/elasticsearch/elasticsearch:6.4.2` services. |
2020-03-09 08:07:45 -04:00
| `.use-pg11-ee` | Same as `.use-pg11` but also use the `docker.elastic.co/elasticsearch/elasticsearch:6.4.2` services. |
2020-02-18 10:08:51 -05:00
| `.as-if-foss` | Simulate the FOSS project by setting the `FOSS_ONLY='1'` environment variable. |
2020-03-09 08:07:45 -04:00
## `workflow:rules`
We're using the [`workflow:rules` keyword ](../ci/yaml/README.md#workflowrules ) to
define default rules to determine whether or not a pipeline is created.
These rules are defined in < https: / / gitlab . com / gitlab-org / gitlab / blob / master / . gitlab-ci . yml >
and are as follows:
1. If `$FORCE_GITLAB_CI` is set, create a pipeline.
1. For merge requests, create a pipeline.
1. For `master` branch, create a pipeline (this includes on schedules, pushes, merges, etc.).
1. For tags, create a pipeline.
1. If `$GITLAB_INTERNAL` isn't set, don't create a pipeline.
2020-03-09 14:07:59 -04:00
1. For stable, auto-deploy, and security branches, create a pipeline.
1. For any other cases (e.g. when pushing a branch with no MR for it), no pipeline is created.
2020-03-09 08:07:45 -04:00
2020-02-18 10:08:51 -05:00
## `rules`, `if:` conditions and `changes:` patterns
We're using the [`rules` keyword ](../ci/yaml/README.md#rules ) extensively.
All `rules` definitions are defined in
< https: / / gitlab . com / gitlab-org / gitlab / - / blob / master / . gitlab / ci / rules . gitlab-ci . yml > ,
then included in individual jobs via [`extends` ](../ci/yaml/README.md#extends ).
The `rules` definitions are composed of `if:` conditions and `changes:` patterns,
which are also defined in
< https: / / gitlab . com / gitlab-org / gitlab / - / blob / master / . gitlab / ci / rules . gitlab-ci . yml >
and included in `rules` definitions via [YAML anchors ](../ci/yaml/README.md#anchors )
### `if:` conditions
| `if:` conditions | Description | Notes |
|------------------|-------------|-------|
| `if-not-canonical-namespace` | Matches if the project isn't in the canonical (`gitlab-org/`) or security (`gitlab-org/security`) namespace. | Use to create a job for forks (by using `when: on_success\|manual` ), or **not** create a job for forks (by using `when: never` ). |
| `if-not-ee` | Matches if the project isn't EE (i.e. project name isn't `gitlab` or `gitlab-ee` ). | Use to create a job only in the FOSS project (by using `when: on_success|manual` ), or **not** create a job if the project is EE (by using `when: never` ). |
| `if-not-foss` | Matches if the project isn't FOSS (i.e. project name isn't `gitlab-foss` , `gitlab-ce` , or `gitlabhq` ). | Use to create a job only in the EE project (by using `when: on_success|manual` ), or **not** create a job if the project is FOSS (by using `when: never` ). |
| `if-default-refs` | Matches if the pipeline is for `master` , `/^[\d-]+-stable(-ee)?$/` (stable branches), `/^\d+-\d+-auto-deploy-\d+$/` (auto-deploy branches), `/^security\//` (security branches), merge requests, and tags. | Note that jobs won't be created for branches with this default configuration. |
| `if-master-refs` | Matches if the current branch is `master` . | |
| `if-master-or-tag` | Matches if the pipeline is for the `master` branch or for a tag. | |
| `if-merge-request` | Matches if the pipeline is for a merge request. | |
2020-02-20 04:09:13 -05:00
| `if-nightly-master-schedule` | Matches if the pipeline is for a `master` scheduled pipeline with `$NIGHTLY` set. | |
2020-02-18 10:08:51 -05:00
| `if-dot-com-gitlab-org-schedule` | Limits jobs creation to scheduled pipelines for the `gitlab-org` group on GitLab.com. | |
| `if-dot-com-gitlab-org-master` | Limits jobs creation to the `master` branch for the `gitlab-org` group on GitLab.com. | |
| `if-dot-com-gitlab-org-merge-request` | Limits jobs creation to merge requests for the `gitlab-org` group on GitLab.com. | |
| `if-dot-com-gitlab-org-and-security-tag` | Limits job creation to tags for the `gitlab-org` and `gitlab-org/security` groups on GitLab.com. | |
| `if-dot-com-gitlab-org-and-security-merge-request` | Limit jobs creation to merge requests for the `gitlab-org` and `gitlab-org/security` groups on GitLab.com. | |
| `if-dot-com-ee-schedule` | Limits jobs to scheduled pipelines for the `gitlab-org/gitlab` project on GitLab.com. | |
| `if-cache-credentials-schedule` | Limits jobs to scheduled pipelines with the `$CI_REPO_CACHE_CREDENTIALS` variable set. | |
### `changes:` patterns
| `changes:` patterns | Description |
|------------------------------|--------------------------------------------------------------------------|
| `yaml-patterns` | Only create job for YAML-related changes. |
| `docs-patterns` | Only create job for docs-related changes. |
2020-03-19 20:09:29 -04:00
| `frontend-dependency-patterns` | Only create job when frontend dependencies are updated (i.e. `package.json` , and `yarn.lock` ). changes. |
| `frontend-patterns` | Only create job for frontend-related changes. |
| `backstage-patterns` | Only create job for backstage-related changes (i.e. Danger, fixtures, RuboCop, specs). |
2020-02-18 10:08:51 -05:00
| `code-patterns` | Only create job for code-related changes. |
| `qa-patterns` | Only create job for QA-related changes. |
| `code-backstage-patterns` | Combination of `code-patterns` and `backstage-patterns` . |
| `code-qa-patterns` | Combination of `code-patterns` and `qa-patterns` . |
| `code-backstage-qa-patterns` | Combination of `code-patterns` , `backstage-patterns` , and `qa-patterns` . |
2019-12-23 16:07:52 -05:00
2020-03-27 05:08:28 -04:00
## Interruptible jobs pipelines
By default, all jobs are [interruptible ](../ci/yaml/README.md#interruptible ), except the
`dont-interrupt-me` job which runs automatically on `master` , and is `manual`
otherwise.
If you want a running pipeline to finish even if you push new commits to a merge
request, be sure to start the `dont-interrupt-me` job before pushing.
2019-09-17 10:16:34 -04:00
## Directed acyclic graph
We're using the [`needs:` ](../ci/yaml/README.md#needs ) keyword to
execute jobs out of order for the following jobs:
```mermaid
graph RL;
A[setup-test-env];
2020-02-06 16:08:48 -05:00
B["gitlab:assets:compile pull-push-cache< br / > (canonical master only)"];
C["gitlab:assets:compile pull-cache< br / > (canonical default refs only)"];
2019-09-17 10:16:34 -04:00
D["cache gems< br / > (master and tags only)"];
E[review-build-cng];
F[build-qa-image];
G[review-deploy];
2020-02-20 07:08:51 -05:00
I["karma, jest"];
2020-02-18 10:08:51 -05:00
I2["karma-as-if-foss, jest-as-if-foss< br / > (EE default refs only)"];
2019-10-16 14:08:01 -04:00
J["compile-assets pull-push-cache< br / > (master only)"];
2020-02-18 10:08:51 -05:00
J2["compile-assets pull-push-cache as-if-foss< br / > (EE master only)"];
2019-09-17 10:16:34 -04:00
K[compile-assets pull-cache];
2020-02-18 10:08:51 -05:00
K2["compile-assets pull-cache as-if-foss< br / > (EE default refs only)"];
2020-02-20 07:08:51 -05:00
U[frontend-fixtures];
U2["frontend-fixtures-as-if-foss< br / > (EE default refs only)"];
V["webpack-dev-server, static-analysis"];
2019-09-17 10:16:34 -04:00
M[coverage];
2020-02-26 04:08:47 -05:00
O[coverage-frontend];
2020-02-06 16:08:48 -05:00
N["pages (master only)"];
2019-09-17 10:16:34 -04:00
Q[package-and-qa];
2019-10-16 14:08:01 -04:00
S["RSpec< br / > (e.g. rspec unit pg9)"]
T[retrieve-tests-metadata];
2020-02-20 07:08:51 -05:00
QA["qa:internal, qa:selectors"];
QA2["qa:internal-as-if-foss, qa:selectors-as-if-foss< br / > (EE default refs only)"];
X["docs lint, code_quality, sast, dependency_scanning, danger-review"];
2019-09-17 10:16:34 -04:00
subgraph "`prepare` stage"
A
2019-12-24 07:08:01 -05:00
B
C
2019-09-17 10:16:34 -04:00
F
K
2020-02-06 16:08:48 -05:00
K2
2019-10-16 14:08:01 -04:00
J
2020-02-06 16:08:48 -05:00
J2
2019-10-16 14:08:01 -04:00
T
2019-09-17 10:16:34 -04:00
end
2020-02-20 07:08:51 -05:00
subgraph "`fixture` stage"
U -.-> |needs and depends on| A;
U -.-> |needs and depends on| K;
U2 -.-> |needs and depends on| A;
U2 -.-> |needs and depends on| K2;
end
2019-09-17 10:16:34 -04:00
subgraph "`test` stage"
2020-02-06 16:08:48 -05:00
D -.-> |needs| A;
2020-02-20 07:08:51 -05:00
I -.-> |needs and depends on| U;
I2 -.-> |needs and depends on| U2;
2019-10-16 14:08:01 -04:00
L -.-> |needs and depends on| A;
S -.-> |needs and depends on| A;
S -.-> |needs and depends on| K;
S -.-> |needs and depends on| T;
2020-02-06 16:08:48 -05:00
L["db:*, gitlab:setup, graphql-docs-verify, downtime_check"] -.-> |needs| A;
2020-02-20 07:08:51 -05:00
V -.-> |needs and depends on| K;
X -.-> |needs| T;
QA -.-> |needs| T;
QA2 -.-> |needs| T;
2020-02-06 16:08:48 -05:00
end
subgraph "`post-test` stage"
M --> |happens after| S
2020-02-26 04:08:47 -05:00
O --> |needs `jest` | I
2019-09-17 10:16:34 -04:00
end
subgraph "`review-prepare` stage"
2020-02-06 16:08:48 -05:00
E -.-> |needs| C;
2019-09-17 10:16:34 -04:00
end
subgraph "`review` stage"
2020-02-17 10:09:01 -05:00
G -.-> |needs| E
2019-09-17 10:16:34 -04:00
end
subgraph "`qa` stage"
2020-02-06 16:08:48 -05:00
Q -.-> |needs| C;
Q -.-> |needs| F;
2020-02-17 10:09:01 -05:00
QA1["review-qa-smoke, review-qa-all, review-performance, dast"] -.-> |needs| G;
2019-09-17 10:16:34 -04:00
end
2020-02-06 16:08:48 -05:00
subgraph "`post-qa` stage"
PQA1["parallel-spec-reports"] -.-> |depends on `review-qa-all` | QA1;
end
2019-09-17 10:16:34 -04:00
subgraph "`pages` stage"
2019-10-16 14:08:01 -04:00
N -.-> |depends on| C;
2020-02-06 16:08:48 -05:00
N -.-> |depends on karma| I;
2019-09-17 10:16:34 -04:00
N -.-> |depends on| M;
2020-02-06 16:08:48 -05:00
N --> |happens after| PQA1
2019-09-17 10:16:34 -04:00
end
```
## Test jobs
Consult [GitLab tests in the Continuous Integration (CI) context ](testing_guide/ci.md )
for more information.
## Review app jobs
Consult the [Review Apps ](testing_guide/review_apps.md ) dedicated page for more information.
---
[Return to Development documentation ](README.md )