-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
168 lines (149 loc) · 7.63 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# Possible options aside from empty in GitLab settings are:
# .gitlab-ci.yml@jdkgabri/project-scaffolding-pipelines (separate repo with just gitlab-ci.yml and pipeline .yml files)
# https://raw.githubusercontent.com/Nakama-Partnering-Services/nakama-project-scaffolding/main/.gitlab-ci.yml
# Note: some variables referenced in job rules, although empty,
# they exist since they are declared here, so we need to check emptyness specifically
variables:
TARGET_ORG:
value: ''
description: 'Target org for the manual deployment. Mainly used for deployments to UAT and PRODUCTION.'
USE_MOST_RECENT:
value: 'false'
description: 'If true, if there is a successful validation deployment with test execution (NoTestRun level is not valid) in the last 10 days, use it for a quick deploy. Else, will result in error. Should normally be used for deployment to PRODUCTION after a successful validation. Note: make sure you are in the correct branch, since latest commit of the branch will be used to update the deployment information of the environment. When this parameter is true, DRY_RUN and TEST_LEVEL are ignored.'
DRY_RUN:
value: 'true'
description: 'If true, changes are not actually deployed, but just validated.'
TEST_LEVEL:
value: 'Default'
description: 'Specifies which level of deployment tests to run. NoTestRun cannot be used in production organizations. Similarly, if the deployment is just a validation, even if successful, it cannot be used in a quick deploy if it did not really run any test. Valid values are: NoTestRun, RunSpecifiedTests, RunLocalTests, RunAllTestsInOrg, Default.'
TESTS:
value: ''
description: 'Lists of the Apex classes containing the deployment tests to run. Use this parameter when you set TEST_LEVEL to RunSpecifiedTests. Default value is based on auto-identified test classes.'
PACKAGE_VERSION_ID:
value: ''
description: 'The Id of the package version to install. Starts by 04t.'
INSTALLATION_KEY:
value: ''
description: 'The installation key of the package version to install, if needed.'
stages:
- dispatch-child-pipeline
# Note: moved here from validate-merge-request.yml to work with included yml rather than dispatched child pipeline
- generate-code_quality-report
- generate-deltas
- validate-merge-request
- validate-test-coverage
.sfdx-changes:
- core/**/*
.target-orgs:
- INT
# - QA
# TODO: add lower environments
validate-merge-request:
stage: dispatch-child-pipeline
rules:
- if: $VALIDATE_MERGE_REQUEST && $CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^rc/ || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^patch/)
changes: !reference [.sfdx-changes]
script:
- echo 'Starting MR validation with includes...'
# Note: include is used with yml rather than dispatching child pipeline so that unit tests reports are visible in parent pipeline
# until this is solved: https://gitlab.com/gitlab-org/gitlab/-/issues/212894
include:
- local: '.gitlab/pipelines/validate-merge-request.yml'
rules:
- if: $VALIDATE_MERGE_REQUEST && $CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^rc/ || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^patch/)
# Note: the following 2 deployment jobs are separated because the value of the TARGET_ORG variable in the matrx is not set dynamically.
deploy-QA-and-lower-environments:
stage: dispatch-child-pipeline
rules:
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $DEPLOY && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes: !reference [.sfdx-changes]
variables:
TARGET_ORG: $TARGET_ORG
trigger:
include:
'.gitlab/pipelines/deploy.yml'
# - project: 'jdkgabri/nakama-project-scaffolding'
# ref: 'main'
# file: '.gitlab/pipelines/deploy.yml'
# - remote: 'https://raw.githubusercontent.com/Nakama-Partnering-Services/nakama-project-scaffolding/main/.gitlab/pipelines/deploy.yml'
strategy: depend
parallel:
matrix:
- TARGET_ORG: !reference [.target-orgs]
deploy-UAT:
stage: dispatch-child-pipeline
rules:
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $DEPLOY && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH =~ /^rc/
changes: !reference [.sfdx-changes]
variables:
TARGET_ORG: UAT
trigger:
include:
'.gitlab/pipelines/deploy.yml'
# - project: 'jdkgabri/nakama-project-scaffolding'
# ref: 'main'
# file: '.gitlab/pipelines/deploy.yml'
# - remote: 'https://raw.githubusercontent.com/Nakama-Partnering-Services/nakama-project-scaffolding/main/.gitlab/pipelines/deploy.yml'
strategy: depend
manual-deployment:
stage: dispatch-child-pipeline
rules:
- if: $CI_PIPELINE_SOURCE == "web" && $TARGET_ORG && $TARGET_ORG != ""
# Note: ths is not supposed to be needed since as per documentation it should be the default behaviour, however it is a non working issue: https://gitlab.com/gitlab-org/gitlab/-/issues/322772
variables:
TARGET_ORG: $TARGET_ORG
USE_MOST_RECENT: $USE_MOST_RECENT
DRY_RUN: $DRY_RUN
TEST_LEVEL: $TEST_LEVEL
TESTS: $TESTS
trigger:
include:
'.gitlab/pipelines/manual-deployment.yml'
# - project: 'jdkgabri/nakama-project-scaffolding'
# ref: 'main'
# file: '.gitlab/pipelines/manual-deployment.yml'
# - remote: 'https://raw.githubusercontent.com/Nakama-Partnering-Services/nakama-project-scaffolding/main/.gitlab/pipelines/manual-deployment.yml'
strategy: depend
install-package:
stage: dispatch-child-pipeline
rules:
- if: $CI_PIPELINE_SOURCE == "web" && $PACKAGE_VERSION_ID && $PACKAGE_VERSION_ID != ""
variables:
TARGET_ORG: $TARGET_ORG
PACKAGE_VERSION_ID: $PACKAGE_VERSION_ID
INSTALLATION_KEY: $INSTALLATION_KEY
trigger:
include:
'.gitlab/pipelines/install-package.yml'
# - project: 'jdkgabri/nakama-project-scaffolding'
# ref: 'main'
# file: '.gitlab/pipelines/install-package.yml'
# - remote: 'https://raw.githubusercontent.com/Nakama-Partnering-Services/nakama-project-scaffolding/main/.gitlab/pipelines/install-package.yml'
strategy: depend
parallel:
matrix:
- TARGET_ORG: !reference [.target-orgs]
run-apex-tests:
stage: dispatch-child-pipeline
rules:
- if: $RUN_APEX_TESTS_DISABLED
when: never
# Note: this second checks, not others as exists or null, works when variable is not even declared, so we check as well in each pipeline job individually
- if: $CI_PIPELINE_SOURCE == "schedule" && $TARGET_ORG != ""
variables:
TARGET_ORG: $TARGET_ORG
trigger:
include:
'.gitlab/pipelines/run-apex-tests.yml'
# - project: 'jdkgabri/nakama-project-scaffolding'
# ref: 'main'
# file: '.gitlab/pipelines/run-apex-tests.yml'
# - remote: 'https://raw.githubusercontent.com/Nakama-Partnering-Services/nakama-project-scaffolding/main/.gitlab/pipelines/run-apex-tests.yml'
strategy: depend
parallel:
matrix:
- TARGET_ORG: !reference [.target-orgs]