This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
forked from research-software-directory/RSD-as-a-service
-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
147 lines (133 loc) · 3.48 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
# SPDX-FileCopyrightText: 2023 Christian Meeßen (GFZ) <[email protected]>
# SPDX-FileCopyrightText: 2023 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
#
# SPDX-License-Identifier: EUPL-1.2
stages:
- test
- build
.docker_login_gitlab_registry: &docker_login_gitlab_registry
- echo "$CI_BUILD_TOKEN" | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
.apply_helmholtz_design: &apply_helmholtz_design
- rm -rf ./frontend/public
- mv ./deployment/helmholtz ./frontend/public
.build_and_push_image: &build_and_push_image
- if test -z "${DOCKERFILE}"; then echo "Variable DOCKERFILE undefined."; exit 1; fi
- if test -z "${DOCKER_CONTEXT}"; then echo "Variable DOCKER_CONTEXT undefined."; exit 2; fi
- if test -z "${IMAGE_NAME}"; then echo "Variable IMAGE_NAME undefined."; exit 3; fi
- docker build -t ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CI_COMMIT_TAG} -f ${DOCKERFILE} ${DOCKER_CONTEXT}
- docker push ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CI_COMMIT_TAG}
default:
image: docker:23
services:
- docker:dind
# -- TEST stage ---------------------------------------------------------------
frontend-tests:
stage: test
image: node:18-alpine
tags:
- docker
- dind
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- frontend/**/*
- deployment/**/*
cache:
key: frontend-cache
paths:
- "frontend/node_modules"
# TODO: test coverage artifacts https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportscoverage_report
before_script:
- *apply_helmholtz_design
- cd frontend
- yarn install --frozen-lockfile
script:
- yarn test:coverage
- yarn build
scraper-tests:
# TODO: Caching
stage: test
image: maven:3.8.6-openjdk-18
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
before_script:
- cd scrapers
script:
- mvn test
# -- BUILD stage --------------------------------------------------------------
build-auth:
stage: build
tags:
- docker
- dind
variables:
DOCKERFILE: "authentication/Dockerfile"
DOCKER_CONTEXT: "authentication"
IMAGE_NAME: "auth"
rules:
- if: $CI_COMMIT_TAG
before_script:
- *docker_login_gitlab_registry
script:
- *build_and_push_image
build-backend:
stage: build
tags:
- docker
- dind
variables:
DOCKERFILE: "backend-postgrest/Dockerfile"
DOCKER_CONTEXT: "backend-postgrest"
IMAGE_NAME: "backend"
rules:
- if: $CI_COMMIT_TAG
before_script:
- *docker_login_gitlab_registry
script:
- *build_and_push_image
build-database:
stage: build
tags:
- docker
- dind
variables:
DOCKERFILE: "database/Dockerfile"
DOCKER_CONTEXT: "database"
IMAGE_NAME: "database"
rules:
- if: $CI_COMMIT_TAG
before_script:
- *docker_login_gitlab_registry
script:
- *build_and_push_image
build-frontend:
stage: build
tags:
- docker
- dind
variables:
DOCKERFILE: "frontend/Dockerfile"
DOCKER_CONTEXT: "frontend"
IMAGE_NAME: "frontend"
rules:
- if: $CI_COMMIT_TAG
before_script:
- *docker_login_gitlab_registry
- *apply_helmholtz_design
script:
- *build_and_push_image
build-scrapers:
stage: build
tags:
- docker
- dind
variables:
DOCKERFILE: "scrapers/Dockerfile"
DOCKER_CONTEXT: "scrapers"
IMAGE_NAME: "scrapers"
rules:
- if: $CI_COMMIT_TAG
before_script:
- *docker_login_gitlab_registry
script:
- *build_and_push_image