-
Notifications
You must be signed in to change notification settings - Fork 22
/
.gitlab-ci.yml
141 lines (128 loc) · 3.99 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
## K-Box Continuous Integration script
stages:
- lint
- test
- release
- deploy
cache:
key: "kbox"
paths:
- .composer/
- .yarn/
- node_modules/
variables:
CONTAINER_RELEASE_IMAGE_BASE: $CI_REGISTRY/images/k-box
## Making sure that the composer cache folder is the one we have in the CI cache
before_script:
- export IMAGE_TAG="${CI_COMMIT_REF_NAME#v}_${CI_COMMIT_SHA:0:10}"
- export CLEANED_CI_COMMIT_REF_NAME="${CI_COMMIT_REF_NAME#v}"
- echo $IMAGE_TAG
- export COMPOSER_CACHE_DIR=`pwd`/.composer
## Composer Install script
## performs composer install with dev dependencies and syntax check
.composer_install: &composer_install
stage: lint
script:
- cp env.ci .env
- composer install --prefer-dist
# - ./vendor/bin/parallel-lint --exclude vendor .
- php artisan view:clear
# - ./vendor/bin/php-cs-fixer fix --dry-run
- echo $CI_COMMIT_REF_NAME
- echo $CI_COMMIT_SHA
## Linting
test-syntax:
<<: *composer_install
image: "klinktechnology/k-box-ci-pipeline-php:7.4"
tags:
- docker
test-shell-syntax:
stage: lint
image: "koalaman/shellcheck-alpine:v0.7.0"
script:
- shellcheck ./docker/configure.sh
- shellcheck ./docker/start.sh
tags:
- docker
## Testing
unit_test:
stage: test
image: "klinktechnology/k-box-ci-pipeline-php:7.4"
services:
- mariadb:10.3.17 # pinning because of issue https://github.com/docker-library/mariadb/issues/262 and https://gitlab.com/gitlab-org/gitlab-runner/issues/4405
variables:
MYSQL_DATABASE: dms
MYSQL_USER: dms
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_PASSWORD: dms
script:
- php --ri imagick
- cp env.ci .env
- cp env.ci .env.testing
- mkdir ./storage/documents
- yarn config set cache-folder .yarn
- yarn
- yarn run production
- composer install --prefer-dist
- composer run install-video-cli
- chmod +x ./bin/bin/packager-linux
- composer run install-content-cli
- composer run install-language-cli
# - composer run install-streaming-client
- php artisan view:clear
- php artisan config:clear
- php artisan route:clear
- php artisan migrate --env=testing --seed --force
- vendor/bin/phpunit
- php artisan lang:check --report=translations.txt
tags:
- docker
artifacts:
expire_in: 1 week
when: on_failure
paths:
- storage/
- translations.txt
## Release the docker image
## Normal branch release, we create local images for being used during tests
branch_release:
stage: release
image: docker:19.03.0
services:
- docker:19.03.0-dind
script:
- echo $IMAGE_TAG
- sed -i "s/BUILDVERSION/${CI_COMMIT_REF_NAME}/g" ./config/dms.php
- sed -i "s/BUILDCODE/${CI_COMMIT_SHA}/g" ./config/dms.php
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:${IMAGE_TAG} .
- docker push $CI_REGISTRY_IMAGE:${IMAGE_TAG}
- docker rmi $CI_REGISTRY_IMAGE:${IMAGE_TAG}
after_script:
- docker image prune --force --filter="label=kbox.builder=kbox"
tags:
- docker
except:
- tags
## Tagged releases
tagged_release:
stage: release
image: docker:19.03.0
services:
- docker:19.03.0-dind
script:
- sed -i "s/BUILDVERSION/${CI_COMMIT_REF_NAME}/g" ./config/dms.php
- sed -i "s/BUILDCODE/${CI_COMMIT_SHA}/g" ./config/dms.php
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $CONTAINER_RELEASE_IMAGE_BASE:${CI_COMMIT_REF_NAME#v} .
- docker login -u $REGISTRY_RELEASE_USERNAME -p $REGISTRY_RELEASE_PASSWORD $CI_REGISTRY
- docker tag $CONTAINER_RELEASE_IMAGE_BASE:${CI_COMMIT_REF_NAME#v} "$CONTAINER_RELEASE_IMAGE_BASE:latest"
- docker push "$CONTAINER_RELEASE_IMAGE_BASE:latest"
- docker push "$CONTAINER_RELEASE_IMAGE_BASE:${CI_COMMIT_REF_NAME#v}"
- docker rmi "$CONTAINER_RELEASE_IMAGE_BASE:${CI_COMMIT_REF_NAME#v}"
after_script:
- docker image prune --force --filter="label=kbox.builder=kbox"
tags:
- docker
only:
- tags