-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
98 lines (92 loc) · 2.3 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
stages:
- test
- build
- deploy
variables:
NOMAD_ADDR: $NOMAD_ADDR
PERSONAL_ACCESS_TOKEN: $PERSONAL_ACCESS_TOKEN
npm_config_cache: "$CI_PROJECT_DIR/.npm"
# Define a hidden job to be used with extends
# Better than default to avoid activating cache for all jobs
.dependencies_cache:
cache:
key:
files:
- yarn.lock
paths:
- .yarn
policy: pull
#
# Test
#
test:
stage: test
image: node:20-alpine
extends: .dependencies_cache
cache:
policy: pull-push
before_script:
- apk update && apk add git bash
- yarn install
script:
- yarn test:coverage
- unset CI
- yarn build
coverage: /All\sfiles.*?\s+(\d+.\d+)/
test-e2e:
stage: test
image: node:20
extends: .dependencies_cache
before_script:
- apk update && apk add git bash
- yarn install
- yarn test:e2e:setup
script:
- yarn test:e2e
#
# Build
#
build:
stage: build
image: docker:19.03.1
extends: .dependencies_cache
cache:
policy: pull
rules:
- if: "$CI_COMMIT_TAG"
when: on_success
- when: never
services:
- name: docker:19.03.1-dind
command: ["--experimental"]
before_script:
- apk update && apk add git bash
- yarn install
- yarn build
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY/hmerritt/adrift:$CI_COMMIT_TAG -t $CI_REGISTRY/hmerritt/adrift:latest .
- docker push $CI_REGISTRY/hmerritt/adrift:latest
- docker push $CI_REGISTRY/hmerritt/adrift:$CI_COMMIT_TAG
after_script:
- docker logout
#
# Deploy
#
deploy:
stage: deploy
image: alpine:3.16.0
rules:
- if: "$CI_COMMIT_TAG"
when: on_success
- when: never
script:
- apk add nomad gettext
- envsubst '${CI_REGISTRY} ${CI_COMMIT_TAG} ${CI_REGISTRY_USER} ${PERSONAL_ACCESS_TOKEN}' < project.nomad > job.nomad
# - cat job.nomad
- nomad validate job.nomad
- nomad plan job.nomad || if [ $? -eq 255 ]; then exit 255; else echo "success"; fi
- nomad run job.nomad
environment:
name: production
allow_failure: false