forked from CERT-Polska/mwdb-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
74 lines (63 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
image: certpl/docker-ci-base:latest
variables:
DOCKER_REGISTRY: dr.cert.pl/malwarecage
GIT_SUBMODULE_STRATEGY: none
DOCKER_BUILDKIT: 1
services:
- docker:dind
stages:
- build
- test
- deploy
before_script:
- echo "Start job $CI_BUILD_NAME" at `date +%Y-%m-%d-%H-%M-%S`
- echo "CI_PIPELINE_ID $CI_PIPELINE_ID"
- chmod +x build-image.sh
- eval $(ssh-agent -s)
- echo "$GIT_DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -H vcs.cert.pl >> ~/.ssh/known_hosts
# This is really weird glitch in Gitlab Runner, we need to forcefully
# clean submodules and reinit them manually
- git submodule deinit --all --force
- git submodule update --init --recursive
- docker login -u "$DOCKER_REGISTRY_LOGIN" -p "$DOCKER_REGISTRY_PASSWORD" "$DOCKER_REGISTRY"
- mkdir -p artifacts/test
- export CI_COMMIT_REF_NAME=`echo -n $CI_COMMIT_REF_NAME | sed 's#/#-#g'`
build_mwdb:
stage: build
script:
- ./build-image.sh "$DOCKER_REGISTRY/malwarecage_mwdb" ". -f ./deploy/docker/Dockerfile"
build_mwdb_tests:
stage: build
script:
- ./build-image.sh "$DOCKER_REGISTRY/malwarecage_mwdb-tests" "tests -f ./tests/Dockerfile"
build_malwarefront:
stage: build
script:
- ./build-image.sh "$DOCKER_REGISTRY/malwarecage_malwarefront" ". -f ./deploy/docker/Dockerfile-malwarefront"
test_mwdb:
stage: test
script:
- docker pull $DOCKER_REGISTRY/malwarecage_mwdb:$CI_COMMIT_SHA > /dev/null
- docker pull $DOCKER_REGISTRY/malwarecage_mwdb-tests:$CI_COMMIT_SHA > /dev/null
- docker pull $DOCKER_REGISTRY/malwarecage_malwarefront:$CI_COMMIT_SHA > /dev/null
- docker tag $DOCKER_REGISTRY/malwarecage_mwdb:$CI_COMMIT_SHA malwarecage_mwdb:latest
- docker tag $DOCKER_REGISTRY/malwarecage_mwdb-tests:$CI_COMMIT_SHA malwarecage_mwdb-tests:latest
- docker tag $DOCKER_REGISTRY/malwarecage_malwarefront:$CI_COMMIT_SHA malwarecage_malwarefront:latest
- chmod +x gen_vars.sh
- ./gen_vars.sh test
- docker-compose up -d
- docker-compose logs -f -t mwdb-tests
- ([ $(docker wait malwarecage_mwdb-tests_1) == 0 ])
after_script:
- docker-compose logs -t mwdb > artifacts/test/mwdb.log
- docker-compose logs -t malwarefront > artifacts/test/malwarefront.log
artifacts:
name: "$CI_JOB_NAME"
paths:
- artifacts/test/mwdb.log
- artifacts/test/malwarefront.log
when: always
expire_in: 1 week