-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
83 lines (71 loc) · 2.4 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
image:
name: "registry.rnl.tecnico.ulisboa.pt/es/humanaethica"
stages:
- prepare
- build
variables:
POSTGRES_DB: hedb
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
PSQL_INT_TEST_DB_USERNAME: "postgres"
PSQL_INT_TEST_DB_PASSWORD: "postgres"
cypress_psql_db_name: "hedb"
cypress_psql_db_username: "postgres"
cypress_psql_db_password: "postgres"
cypress_psql_db_host: "localhost"
cypress_psql_db_port: "5432"
# Docker-in-Docker is broken on gitlab ATM
# https://gitlab.com/gitlab-org/gitlab-runner/-/issues/29130
# JFF: RNL's runners do not have permission for this. We pushed the
# container manually.
gitlab-build-image:
image: docker:stable
services:
- docker:dind
stage: prepare
when: manual
script:
- echo $CI_REGISTRY
- echo $CI_REGISTRY_USER
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY/es/humanaethica .
- docker push $CI_REGISTRY/es/humanaethica
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- Dockerfile
build-and-test:
stage: build
script:
# Backend unit tests incl coverage report
- cd backend
- mvn clean -Ptest test
# Convert Jacoco's report into a format that Gitlab understands
- python2 /bin/cover2cover.py target/site/jacoco/jacoco.xml src/main/java > ../cobertura.xml
#- sed -i 's;filename=";filename="backend/src/main/java/;g' ../cobertura.xml
#- sed -i 's;<sources>.*</sources>;;' ../cobertura.xml
- grep -o '<coverage branch-rate="[0-9.]\+" complexity="[0-9.]\+" line-rate="[0-9.]\+"' ../cobertura.xml | gawk '{match($0, "line-rate=\"([0-9.]+)", m)}END{print "Java code coverage:" m[1]*100}'
# Backend integration tests
- /etc/init.d/postgresql start
- mvn clean verify -Ptest-int
- sudo -u postgres psql -d hedb -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
# Frontend tests
- cd ../frontend
- npm install
#- npm run test:unit
# Cypress tests
- cd ../backend
- mvn clean -Ptest-int spring-boot:run &
- cd ../frontend
- npm start &
- wget --tries=0 --timeout=1 --retry-connrefused -q http://localhost:8081
- npx cypress run
coverage: '/Java code coverage:[0-9.]+/'
artifacts:
paths:
- target/site/jacoco/
reports:
coverage_report:
coverage_format: cobertura
path: cobertura.xml