-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
267 lines (241 loc) · 7.19 KB
/
.gitlab-ci.yml
File metadata and controls
267 lines (241 loc) · 7.19 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# This file is part of Adblock Plus <https://adblockplus.org/>,
# Copyright (C) 2006-present eyeo GmbH
#
# Adblock Plus is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# Adblock Plus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
---
stages:
- test
- build_production
- deploy_production
- notify
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "schedule"
# TEST #########################################################################
.test_rules:
stage: test
rules:
- if: $SKIP_CI_TESTS == "true"
when: never
- when: always
interruptible: true
.test_runner:
extends: .test_rules
tags:
- eyeo-medium-runner
image: docker:24.0.5
services:
- docker:24.0.5-dind
variables:
DOCKER_DRIVER: overlay2
test:lint:
extends: .test_runner
script:
- docker build -t lintimage -f test/lint.Dockerfile .
- docker run -t lintimage
.test:
extends: .test_runner
script:
- docker build -t testpages .
- docker run --shm-size=2g -e GREP="$GREP" -t testpages
after_script:
- IMAGE_ID=$(docker ps -aqf ancestor=testpages)
- docker cp $IMAGE_ID:/testpages.adblockplus.org/test/screenshots .
2> /dev/null
- docker cp $IMAGE_ID:/var/log/nginx/ .
artifacts:
paths:
- screenshots/
- nginx/
when: on_failure
expire_in: 1 mo
test:chromium:oldest:
extends: .test
variables:
GREP: chromium 79.0.3945.0
test:chrome:latest:
extends: .test
variables:
GREP: chrome latest
test:chrome:beta:
extends: .test
variables:
GREP: chrome beta
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
test:chrome:dev:
extends: .test
variables:
GREP: chrome dev
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
allow_failure: true
test:firefox:latest:
extends: .test
variables:
GREP: firefox latest
test:firefox:beta:
extends: .test
variables:
GREP: firefox beta
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
test:firefox:oldest:
extends: .test
variables:
GREP: firefox 68.0
test:edge:latest:
extends: .test
variables:
GREP: edge latest
test:edge:beta:
extends: .test
variables:
GREP: edge beta
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
test:edge:windows:
extends: .test_rules
tags:
- eyeo-windows
cache:
- key:
files:
- .gitlab-ci.yml
- package-lock.json
paths:
- choco_cache
- node_modules
- pip_cache
before_script:
# Setup cache locations for chocolatey and pip
- New-Item -Name "choco_cache" -Path "$(Get-Location)"
-ItemType "directory" -Force
- New-Item -Name "pip_cache" -Path "$(Get-Location)"
-ItemType "directory" -Force
- choco config set cacheLocation "$(Get-Location)\choco_cache"
# Install other packages
- choco install -y nginx --version=1.27.3
- $Env:NGINX_WIN = "C:\tools\nginx-1.27.3"
- $Env:NGINX_LINUX = "C:/tools/nginx-1.27.3"
- choco install -y python3 --version 3.11.4
# Refresh system environment after package installations
- Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
- refreshenv
# nginx config
- xcopy test\etc\nginx\* $Env:NGINX_WIN\conf\ /E /V /F /H
- (Get-Content $Env:NGINX_WIN\conf\nginx.conf).replace("octet-stream;",
"octet-stream;`n
include $Env:NGINX_LINUX/conf/sites-enabled-windows/*.conf;"
) | Set-Content $Env:NGINX_WIN\conf\nginx.conf
- openssl req -x509 -newkey rsa:4096
-keyout $Env:NGINX_WIN\conf\${Env:DOMAIN}_key.pem
-out $Env:NGINX_WIN\conf\${Env:DOMAIN}_cert.pem
-days 365 -nodes -subj "/CN=$Env:DOMAIN"
- echo "`n127.0.0.1 $Env:DOMAIN" |
Add-Content c:\windows\system32\drivers\etc\hosts
# Build CMS
- git clone https://gitlab.com/eyeo/websites/cms.git
- git -C cms checkout fbd1527b9f98d99a8b62c6ad5e32ac7758c19a28
- pip3 install --cache-dir "$(Get-Location)\pip_cache"
-r cms\requirements.txt
# Build tests
- npm install
# Generate test pages files
- mkdir -p $Env:NGINX_WIN\html\$Env:DOMAIN
- $Env:PYTHONPATH = "cms"
- python -m cms.bin.generate_static_pages .
$Env:NGINX_WIN\html\$Env:DOMAIN
script:
# Run test pages server
- Start-Process "$Env:NGINX_WIN\nginx.exe"
-WorkingDirectory "$Env:NGINX_WIN" -PassThru
# Run endpoints server. Since NPM 10, NPM needs to be run with `npm.cmd`
# when using Start-Process (see https://github.com/nodejs/help/issues/4436)
- Start-Process "npm.cmd" -ArgumentList "run start-endpoints" -PassThru
- node ./test/extension-tests/extension-download.js
- npm run test "--" -g "edge latest"
variables:
TEST_PAGES_URL: https://local.testpages.adblockplus.org:5001/en/
SITE_URL: https://local.testpages.adblockplus.org:5001
DOMAIN: local.testpages.adblockplus.org
TEST_PAGES_INSECURE: "true"
MANIFEST_VERSION: 2
artifacts:
paths:
- ./test/screenshots
when: on_failure
expire_in: 1 mo
# BUILD, DEPLOY ################################################################
.production:
tags:
- eyeo_cms_web_server_testpages-1.uplink.eyeo.it
only:
- master
.build_production:
stage: build_production
extends: .production
script:
- env PYTHONPATH=/opt/cms
python3 -m cms.bin.generate_static_pages $PWD build
artifacts:
name: $CI_COMMIT_REF_SLUG
paths:
- build
build:abptestpages:
extends: .build_production
variables:
SITE_URL: https://abptestpages.org
.deploy_production:
stage: deploy_production
extends: .production
script:
- echo $DEPLOY_SCRIPT
- sudo /usr/local/sbin/$DEPLOY_SCRIPT $CI_PROJECT_DIR/build/ $CI_PROJECT_DIR
environment:
name: $DOMAIN
url: https://$DOMAIN
deploy:abptestpages:
extends: .deploy_production
dependencies:
- build:abptestpages
variables:
DOMAIN: abptestpages.org
DEPLOY_SCRIPT: deploy_testpages
# NOTIFY ######################################################################
notify:test_automation:
stage: notify
tags:
- eyeo-small-runner
image: registry.gitlab.com/eyeo/docker/get-browser-binary:node22
only:
- master
needs:
- deploy:abptestpages
script:
- |
CHANGED_FILES=$(git diff \
--name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA \
-- 'pages/**/*.tmpl' | tr '\n' ',')
if [ -z "$CHANGED_FILES" ]; then
echo "No .tmpl files changed, skipping trigger"
exit 0
fi
echo "Changed tmpl files: $CHANGED_FILES"
curl -X POST --fail \
-F "token=$TEST_AUTOMATION_TRIGGER_TOKEN" \
-F "ref=main" \
-F "variables[TESTPAGES_CHANGED_FILES]=$CHANGED_FILES" \
-F "variables[TESTPAGES_COMMIT_SHA]=$CI_COMMIT_SHA" \
"https://gitlab.com/api/v4/projects/${TEST_AUTOMATION_PROJECT_ID}/trigger/pipeline"
allow_failure: true