-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
155 lines (145 loc) · 4.5 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
default:
image: php:8.2
before_script:
- apt-get update -yqq
- apt-get install git zip zlib1g-dev libzip-dev libxml2-dev libonig-dev libpng-dev libghc-curl-dev libldb-dev libldap2-dev postgresql postgresql-client libpq-dev -yqq
- docker-php-ext-install pgsql pdo_pgsql zip xml intl mbstring gd curl bcmath opcache ldap
- pecl install xdebug-3.3.1 \
&& docker-php-ext-enable xdebug
- cd app
- curl -sS https://getcomposer.org/installer | php
- cd ..
services:
- postgres:11.7-alpine
variables:
GIT_SUBMODULE_STRATEGY: recursive
POSTGRES_DB: db
POSTGRES_USER: db
POSTGRES_PASSWORD: password
POSTGRES_HOST_AUTH_METHOD: trust
stages:
- build
- tests
- publish
- release
# On build la CSS et le JS
build:assets:
inherit:
default: false
stage: build
image: node:16.16-alpine
script:
- apk add --no-cache jq python3 gcc g++ make
- cd app-front
- yarn install
- yarn build
- cd ..
artifacts:
expire_in: '1 hour'
paths:
- app/public/build
# On descend les paquets composer
build:composer-install:
inherit:
default: true
stage: build
script:
- cd app
- php composer.phar install --no-dev
- cd ..
artifacts:
expire_in: '1 hour'
paths:
- app/vendor
# Tests CS and Static analysis
test:composer-checks:
inherit:
default: true
stage: tests
script:
- cd app
- cp .env.dist .env
- php composer.phar install
- php composer.phar checks
- cd ..
# Tests PHPUNIT
test:phpunit:
inherit:
default: true
stage: tests
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
script:
- cd app
- cp .env.dist .env
- php composer.phar install
- php bin/console aeneria:install -n
- php bin/console aeneria:dev:generate-fake-data --from="7 days ago" --user-name=admin@example.com --user-password=password
- php bin/console aeneria:user:grant admin@example.com
- php bin/console aeneria:dev:generate-fake-data --from="7 days ago" --user-name=user-test@example.com --user-password=password
- php bin/phpunit --coverage-text --colors=never -vvv
- cd ..
# On vérifie que la documentation build correctement
test:documentation-build:
inherit:
default: false
stage: tests
image: python:3.7-alpine
script:
- pip install -U sphinx
- cd docs
- sphinx-build -b html . _build
# Sur un tag sur master, on archive les sources et on
# les envoie sur le serveur de statics d'æneria
publish:
inherit:
default: false
stage: publish
only:
- tags
image: docker:stable
before_script:
- apk add --update curl tar zip && rm -rf /var/cache/apk/*
- 'command -v ssh-agent >/dev/null || ( apk add --update openssh-client )'
- 'which ssh-agent || ( apk add --update openssh-client )'
- eval $(ssh-agent -s)
- echo "$SSH_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $SSH_SERVER >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- tar -cvf aeneria-app-$CI_COMMIT_TAG.tar app/
- tar -zcvf aeneria-app-$CI_COMMIT_TAG.tar.gz app/
- zip -r aeneria-app-$CI_COMMIT_TAG.zip app/
- scp aeneria-app-$CI_COMMIT_TAG.tar $SSH_USER@$SSH_SERVER:www/.
- scp aeneria-app-$CI_COMMIT_TAG.tar.gz $SSH_USER@$SSH_SERVER:www/.
- scp aeneria-app-$CI_COMMIT_TAG.zip $SSH_USER@$SSH_SERVER:www/.
# Sur un tag sur master qui n'est pas une alpha ou beta
# On créée une Release Gitlab & on met à jour les derniers
# statics disponibles sur le serveur d'æneria
release:
inherit:
default: false
stage: release
only:
variables:
- $CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^[0-9\.]*$/
image: registry.gitlab.com/gitlab-org/release-cli:latest
before_script:
- 'command -v ssh-agent >/dev/null || ( apk add --update openssh-client )'
- 'which ssh-agent || ( apk add --update openssh-client )'
- eval $(ssh-agent -s)
- echo "$SSH_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $SSH_SERVER >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
# On met à jour la version latest
- ssh $SSH_USER@$SSH_SERVER "cp www/aeneria-app-$CI_COMMIT_TAG.tar www/aeneria-app-latest.tar"
- ssh $SSH_USER@$SSH_SERVER "cp www/aeneria-app-${CI_COMMIT_TAG}.tar.gz www/aeneria-app-latest.tar.gz"
- ssh $SSH_USER@$SSH_SERVER "cp www/aeneria-app-${CI_COMMIT_TAG}.zip www/aeneria-app-latest.zip"
release:
tag_name: '$CI_COMMIT_TAG'
name: 'Version $CI_COMMIT_TAG'
description: 'Release autogénérée par la CI - Version $CI_COMMIT_TAG'