-
Notifications
You must be signed in to change notification settings - Fork 15
/
.gitlab-ci.yml
143 lines (130 loc) · 3.21 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
# Jobs defined here use the dashboard/ci docker image from ECR by default.
# Images are built via the identity-devops GitLab pipeline.
variables:
ECR_REGISTRY: '${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com'
CI_SHA: 'sha256:60cd46939b9fca7aefd5c5803f44d86a0ac463e138991b3fa7b26a571f970d24'
default:
image: '${ECR_REGISTRY}/dashboard/ci@${CI_SHA}'
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
stages:
- build
- test
- deploy
.build_cache:
- &dependency_cache
key:
files:
- Gemfile.lock
- package-lock.json
paths:
- vendor/bundle
- .npm-cache/
policy: pull
.bundle_npm_install: &bundle_npm_install
- bundle config set deployment true
- bundle install --jobs=4 --retry=3
- npm ci --cache .npm-cache --prefer-offline
install:
stage: build
cache:
- <<: *dependency_cache
policy: pull-push
script:
- *bundle_npm_install
lints:
stage: test
cache:
- <<: *dependency_cache
script:
- *bundle_npm_install
- make lint
integration:
stage: test
cache:
- <<: *dependency_cache
script:
- *bundle_npm_install
- npm test
variables:
SKIP_VISUAL_REGRESSION_TEST: 'true'
snapshot-main:
stage: test
cache:
- <<: *dependency_cache
script:
- git clone -b main --depth 1 https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.login.gov/lg/identity-design-system.git
- cd identity-design-system
- *bundle_npm_install
- make -j2 build-assets build-docs
- scripts/snapshot.js
- mkdir -p ../tmp/screenshot/branches
- mv tmp/screenshot/branches/$CI_COMMIT_REF_SLUG ../tmp/screenshot/branches/main
artifacts:
expire_in: 1h
paths:
- tmp/screenshot/branches/main/*.png
except:
- main
snapshot-branch:
stage: test
cache:
- <<: *dependency_cache
script:
- *bundle_npm_install
- make -j2 build-assets build-docs
- scripts/snapshot.js
artifacts:
expire_in: 1h
paths:
- tmp/screenshot/branches/$CI_COMMIT_REF_SLUG/*.png
except:
- main
visual-regression:
stage: test
cache:
- <<: *dependency_cache
needs:
- job: snapshot-main
artifacts: true
- job: snapshot-branch
artifacts: true
script:
- *bundle_npm_install
- npm test
variables:
ONLY_VISUAL_REGRESSION_TEST: 'true'
except:
- main
artifacts:
expose_as: Visual regression
when: on_failure
expire_in: 30d
paths:
- tmp/screenshot
pages:
stage: deploy
cache:
- <<: *dependency_cache
script:
- *bundle_npm_install
- make -j2 build-assets build-docs
- 'echo Preview URL: ${PREVIEW_URL}${PREVIEW_BASEURL}'
variables:
PREVIEW_URL: https://$CI_PROJECT_NAMESPACE.pages.production.gitlab.login.gov
PAGES_PREFIX: ''
PREVIEW_BASEURL: /identity-design-system
artifacts:
paths:
- dist
pages:
path_prefix: '$PAGES_PREFIX'
publish: dist
rules:
- if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH
variables:
PAGES_PREFIX: 'branch-$CI_COMMIT_REF_SLUG'
PREVIEW_BASEURL: /identity-design-system/branch-$CI_COMMIT_REF_SLUG