-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
91 lines (81 loc) · 3.13 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
stages:
- test
- build
variables:
CONTAINER_API_URL: "${CI_REGISTRY_IMAGE}/ssm-bats-rest-api"
FUSEKI_VERSION: "3.17.0"
include:
remote: "https://code.ornl.gov/rse-deployment/rse-sharables/-/raw/master/.gitlab-ci-before_script.yml"
lint:
stage: test
script:
- func_rse_docker_cleanup
- docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -f src/main/docker/Dockerfile.ssm_bats_rest_api -t ssm-bats-test .
- docker run --net=host -v /var/run/docker.sock:/var/run/docker.sock ssm-bats-test /bin/bash -c "mvn validate"
- func_rse_docker_cleanup
tags:
- rse-multi-builder
test:
stage: test
script:
- func_rse_docker_cleanup
- docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull ${CI_REGISTRY_IMAGE}/openjdk:11-jre-slim
- docker pull ${CI_REGISTRY_IMAGE}/mongo:4
- docker pull ${CI_REGISTRY_IMAGE}/fuseki:${FUSEKI_VERSION}
- docker build -f src/main/docker/Dockerfile.ssm_bats_rest_api -t ssm-bats-test .
- docker run --net=host -v /var/run/docker.sock:/var/run/docker.sock ssm-bats-test
- func_rse_docker_cleanup
tags:
- rse-multi-builder
coverage:
stage: test
script:
- func_rse_docker_cleanup
- docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull ${CI_REGISTRY_IMAGE}/openjdk:11-jre-slim
- docker pull ${CI_REGISTRY_IMAGE}/mongo:4
- docker pull ${CI_REGISTRY_IMAGE}/fuseki:${FUSEKI_VERSION}
- docker build -f src/main/docker/Dockerfile.ssm_bats_rest_api -t ssm-bats-test .
- docker run --net=host -v /var/run/docker.sock:/var/run/docker.sock ssm-bats-test /bin/bash -c "mvn clean docker:build verify; awk -F',' '{ instructions += \$4 + \$5; covered += \$5 } END { print covered, \"/\", instructions, \" instructions covered\"; printf \"%.2f %% covered\n\", 100*covered/instructions}' target/site/jacoco/jacoco.csv"
- func_rse_docker_cleanup
tags:
- rse-multi-builder
.build:
stage: build
script:
- func_rse_docker_cleanup
- docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -f Dockerfile --build-arg PROFILE=${PROFILE} -t $CONTAINER_API_URL/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA .
- docker tag $CONTAINER_API_URL/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA $CONTAINER_API_URL/$CI_COMMIT_REF_NAME:latest
- docker push $CONTAINER_API_URL/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
- docker push $CONTAINER_API_URL/$CI_COMMIT_REF_NAME:latest
tags:
- rse-multi-builder
build-dev:
extends: .build
variables:
PROFILE: "dev"
only:
- dev
build-qa:
extends: .build
variables:
PROFILE: "qa"
only:
- qa
build-prod:
extends: .build
variables:
PROFILE: "prod"
only:
- main
build-others:
extends: .build
variables:
PROFILE: "localdocker"
except:
- dev
- qa
- main