This repository has been archived by the owner on Jun 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
101 lines (92 loc) · 3.21 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
# see also https://docs.gitlab.com/ce/ci/variables/README.html
stages:
- build
- test
- release
- deploy
before_script:
- echo $CI_SERVER_NAME
# create sanitized project name
- export COMPOSE_PROJECT_NAME=$(echo "buildpipeline${CI_PIPELINE_ID}${CI_PROJECT_NAME}${CI_BUILD_NAME}" | tr -dc '[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]')
- export APP_VERSION=$(git describe --always --dirty --tags)
# define image names for local builds and repository
- export BUILD_PHP_IMAGE=${COMPOSE_PROJECT_NAME}_php
- export STACK_PHP_IMAGE=${REGISTRY_HOST}/${CI_PROJECT_PATH}/php:${APP_VERSION}
- export STACK_PHP_IMAGE_LATEST=${REGISTRY_HOST}/${CI_PROJECT_PATH}/php:latest
- docker-compose config
# ensure a Docker image with correct version exists
- make version build
after_script:
# set docker-compose isolation
- export COMPOSE_PROJECT_NAME=$(echo "buildpipeline${CI_PIPELINE_ID}${CI_PROJECT_NAME}${CI_BUILD_NAME}" | tr -dc '[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]')
- docker-compose down -v
test:project:
stage: test
variables:
COMPOSE_FILE: './docker-compose.yml:./docker/docker-compose.dev.yml:./docker/docker-compose.project-test.yml:./docker/docker-compose.selenium.yml'
script:
- make test || (docker-compose logs > _host-volumes/project-tests-log/docker.log && exit 1)
except:
- coverage
artifacts:
name: "${CI_PROJECT_NAME}_${CI_PIPELINE_ID}_${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
paths:
- _host-volumes/project-tests-log
when: always
test:project:coverage:
stage: test
variables:
COMPOSE_FILE: './docker-compose.yml:./docker/docker-compose.dev.yml:./docker/docker-compose.project-test.yml:./docker/docker-compose.selenium.yml'
script:
- make test-init
- make test-coverage || (docker-compose logs > _host-volumes/project-tests-log/docker.log && exit 1)
only:
- coverage
artifacts:
name: "${CI_PROJECT_NAME}_${CI_PIPELINE_ID}_${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
paths:
- _host-volumes/project-tests-log
when: always
test:app:
stage: test
variables:
COMPOSE_FILE: './docker-compose.yml:./docker/docker-compose.dev.yml:./docker/docker-compose.app-test.yml:./docker/docker-compose.selenium.yml'
script:
- make app-test || (docker-compose logs > _host-volumes/app-tests-log/docker.log && exit 1)
artifacts:
name: "${CI_PROJECT_NAME}_${CI_PIPELINE_ID}_${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
paths:
- _host-volumes/app-tests-log
when: always
except:
- /^feature/
lint:
stage: test
variables:
COMPOSE_FILE: './docker-compose.yml:./docker/docker-compose.dev.yml:./docker/docker-compose.project-test.yml'
script:
- make lint
artifacts:
name: "${CI_PROJECT_NAME}_${CI_PIPELINE_ID}_${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
paths:
- _host-volumes/app-tests-log
when: always
release:latest:
stage: release
environment:
name: images
script:
- docker tag ${BUILD_PHP_IMAGE} ${STACK_PHP_IMAGE_LATEST}
- docker push ${STACK_PHP_IMAGE_LATEST} || exit 1
only:
- master
release:tags:
stage: release
environment:
name: images
script:
- docker tag ${BUILD_PHP_IMAGE} ${STACK_PHP_IMAGE}
- docker push ${STACK_PHP_IMAGE} || exit 1
only:
- release
- tags