-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
173 lines (161 loc) · 4.1 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
169
170
171
172
173
# Build tools Dockerfile
image: quay.io/pantheon-public/build-tools-ci:6.x
# Default Variables
variables:
CI_BUILD_NUMBER: $CI_PIPELINE_IID
DEFAULT_SITE: $CI_PROJECT_NAME
PR_NUMBER: $CI_MERGE_REQUEST_IID
CI_BRANCH: $CI_COMMIT_REF_NAME
# Cache libraries in between jobs
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- vendor/
- /composer/cache
- $HOME/.composer/cache
stages:
- configure-and-build
- deploy
- visual-test
- behat-test
- cleanup
- updates
before_script:
- export PATH="$PATH:$CI_PROJECT_DIR/.ci/scripts"
- export BASH_ENV="$HOME/.envvarsrc"
- /build-tools-ci/scripts/set-environment
- source $BASH_ENV
# See https://docs.gitlab.com/ee/ci/ssh_keys/README.html
- eval $(ssh-agent -s) && ssh-add <(echo "$SSH_PRIVATE_KEY")
- terminus -n auth:login --machine-token="$TERMINUS_TOKEN"
configure:env-vars:
stage: configure-and-build
before_script:
# See https://docs.gitlab.com/ee/ci/ssh_keys/README.html
- eval $(ssh-agent -s) && ssh-add <(echo "$SSH_PRIVATE_KEY")
script:
# Set TERMINUS_ENV and related environment variables.
# https://github.com/pantheon-systems/docker-build-tools-ci/blob/6.x/scripts/set-environment
- export PATH="$PATH:$CI_PROJECT_DIR/.ci/scripts"
- export BASH_ENV="$HOME/.envvarsrc"
- /build-tools-ci/scripts/set-environment
- source $BASH_ENV
- cp $BASH_ENV bash_env.txt
artifacts:
paths:
- bash_env.txt
only:
- merge_requests
- master
test:static:
stage: configure-and-build
script:
- ./.ci/test/static/run
only:
- merge_requests
- master
except:
- schedules
build:php:
stage: configure-and-build
script:
- ./.ci/build/php
artifacts:
paths:
- web
- vendor
only:
- merge_requests
- master
except:
- schedules
deploy:pantheon:
stage: deploy
environment:
name: deploy/$TERMINUS_ENV
url: https://$TERMINUS_ENV-$TERMINUS_SITE.pantheonsite.io/
script:
- echo "Target site.env is $TERMINUS_SITE.$TERMINUS_ENV"
- ./.ci/deploy/pantheon/dev-multidev
dependencies:
- build:php
only:
- merge_requests
- master
except:
- schedules
test:visual-regression:
stage: visual-test
image:
name: backstopjs/backstopjs:4.1.9
entrypoint: [""]
variables:
CI_BUILD_URL: $CI_PIPELINE_IID
CI_REPOSITORY_URL: $CI_MERGE_REQUEST_IID
ARTIFACTS_DIR_URL: https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/jobs/$CI_JOB_ID/artifacts
before_script:
# See https://docs.gitlab.com/ee/ci/ssh_keys/README.html
- eval $(ssh-agent -s) && ssh-add <(echo "$SSH_PRIVATE_KEY")
- export BASH_ENV="$HOME/.envvarsrc"
- cp bash_env.txt $BASH_ENV
- source $BASH_ENV
script:
- ./.ci/test/visual-regression/run
artifacts:
paths:
- backstop_data
dependencies:
- configure:env-vars
- deploy:pantheon
only:
- merge_requests
except:
- schedules
test:behat:
stage: behat-test
script:
- ./.ci/test/behat/initialize
# Start headless Chrome
- google-chrome --disable-gpu --headless --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 --no-sandbox </dev/null &>/dev/null &
- ./.ci/test/behat/run
artifacts:
paths:
- behat-screenshots
dependencies:
- deploy:pantheon
- test:visual-regression
only:
- merge_requests
- master
except:
- schedules
test:behat:cleanup:
stage: cleanup
when: always
script:
- ./.ci/test/behat/cleanup
only:
- merge_requests
- master
except:
- schedules
dependencies:
- test:behat
schedule:composer:update:
stage: updates
variables:
# The default set of CI credentials do not contain the necessary permissions in GitLab for our operations.
LAB_CORE_TOKEN: $GITLAB_TOKEN
LAB_CORE_USER: $CI_REGISTRY_USER
LAB_CORE_HOST: "https://$CI_SERVER_HOST"
GIT_STRATEGY: none
script:
# The default repository URL uses a token without permission to write so replace it with ours.
- FULL_REPOSITORY_URL=$(sed 's|'"$CI_JOB_TOKEN"'|'"$GITLAB_TOKEN"'|' <<< "$CI_REPOSITORY_URL")
# lab tries to use CI variables with improper permissions.
- unset CI_PROJECT_URL
- unset CI_REGISTRY_USER
- unset CI_JOB_TOKEN
- set -e && clu --provider=gitlab $FULL_REPOSITORY_URL
only:
- schedules