]> git.mxchange.org Git - friendica.git/blob - .drone.yml
Merge pull request #10677 from nupplaphil/feat/optimize_drone
[friendica.git] / .drone.yml
1 kind: pipeline
2 type: docker
3 name: Check messages.po
4
5 steps:
6   - name: Run default Xgettext
7     image: friendicaci/transifex
8     commands:
9       - ./bin/run_xgettext.sh
10
11   - name: Check default
12     image: friendicaci/transifex
13     commands:
14       - /check-messages.sh
15 ---
16 kind: pipeline
17 type: docker
18 name: php7.3-lint
19
20 steps:
21   - name: Test
22     image: php:7.3
23     commands:
24       - ./bin/composer.phar run lint
25 ---
26 kind: pipeline
27 type: docker
28 name: php7.4-lint
29
30 steps:
31   - name: Test
32     image: php:7.4
33     commands:
34       - ./bin/composer.phar run lint
35 ---
36 kind: pipeline
37 type: docker
38 name: php8.0-lint
39
40 steps:
41   - name: Test
42     image: php:8.0
43     commands:
44       - ./bin/composer.phar run lint
45 ---
46 kind: pipeline
47 type: docker
48 name: php-cs check
49
50 trigger:
51   event:
52     - pull_request
53
54 steps:
55   - name: Restore cache
56     image: meltwater/drone-cache:dev
57     settings:
58       backend: "filesystem"
59       restore: true
60       cache_key: '{{ .Repo.Name }}_phpcs_{{ arch }}_{{ os }}'
61       archive_format: "gzip"
62       mount:
63         - '.composer'
64     volumes:
65       - name: cache
66         path: /tmp/cache
67   - name: Install dependencies
68     image: composer
69     commands:
70       - export COMPOSER_HOME=.composer
71       - ./bin/composer.phar run cs:install
72   - name: Rebuild cache
73     image: meltwater/drone-cache:dev
74     settings:
75       backend: "filesystem"
76       rebuild: true
77       cache_key: '{{ .Repo.Name }}_phpcs_{{ arch }}_{{ os }}'
78       archive_format: "gzip"
79       mount:
80         - '.composer'
81     volumes:
82       - name: cache
83         path: /tmp/cache
84   - name: Run coding standards check
85     image: friendicaci/php-cs
86     commands:
87       - export CHANGED_FILES="$(git diff --name-status ${DRONE_COMMIT_BEFORE}..${DRONE_COMMIT_AFTER} | grep ^A | cut -f2)"
88       - /check-php-cs.sh
89
90 volumes:
91   - name: cache
92     host:
93       path: /tmp/drone-cache
94 ---
95 kind: pipeline
96 type: docker
97 name: php7.3-mariadb
98
99 depends_on:
100   - php7.3-lint
101
102 steps:
103   - name: Restore cache
104     image: meltwater/drone-cache:dev
105     settings:
106       backend: "filesystem"
107       restore: true
108       cache_key: '{{ .Repo.Name }}_php73_{{ arch }}_{{ os }}'
109       archive_format: "gzip"
110       mount:
111         - '.composer'
112     volumes:
113       - name: cache
114         path: /tmp/cache
115   - name: Composer install
116     image: friendicaci/php7.3:php7.3.28
117     commands:
118       - export COMPOSER_HOME=.composer
119       - ./bin/composer.phar validate
120       - ./bin/composer.phar install --prefer-dist
121   - name: Rebuild cache
122     image: meltwater/drone-cache:dev
123     settings:
124       backend: "filesystem"
125       rebuild: true
126       cache_key: '{{ .Repo.Name }}_php73_{{ arch }}_{{ os }}'
127       archive_format: "gzip"
128       mount:
129         - '.composer'
130     volumes:
131       - name: cache
132         path: /tmp/cache
133   - name: Test Friendica
134     image: friendicaci/php7.3:php7.3.28
135     environment:
136       MYSQL_HOST: "mariadb"
137       MYSQL_PORT: 3306
138       MYSQL_DATABASE: "test"
139       MYSQL_PASSWORD: "test"
140       MYSQL_USER: "test"
141       REDIS_HOST: "redis"
142       MEMCACHED_HOST: "memcached"
143       MEMCACHE_HOST: "memcached"
144     commands:
145       - cp config/local-sample.config.php config/local.config.php
146       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
147       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
148       - phpunit --configuration tests/phpunit.xml
149
150 services:
151   - name: mariadb
152     image: mariadb:latest
153     environment:
154       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
155       MYSQL_DATABASE: "test"
156       MYSQL_PASSWORD: "test"
157       MYSQL_USER: "test"
158     tmpfs:
159       - /var/lib/mysql
160
161   - name: memcached
162     image: memcached
163
164   - name: redis
165     image: redis
166
167 volumes:
168   - name: cache
169     host:
170       path: /tmp/drone-cache
171 ---
172 kind: pipeline
173 type: docker
174 name: php7.4-mariadb
175
176 depends_on:
177   - php7.4-lint
178
179 steps:
180   - name: Restore cache
181     image: meltwater/drone-cache:dev
182     settings:
183       backend: "filesystem"
184       restore: true
185       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
186       archive_format: "gzip"
187       mount:
188         - '.composer'
189     volumes:
190       - name: cache
191         path: /tmp/cache
192   - name: Composer install
193     image: friendicaci/php7.4:php7.4.18
194     commands:
195       - export COMPOSER_HOME=.composer
196       - ./bin/composer.phar validate
197       - ./bin/composer.phar install --prefer-dist
198   - name: Rebuild cache
199     image: meltwater/drone-cache:dev
200     settings:
201       backend: "filesystem"
202       rebuild: true
203       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
204       archive_format: "gzip"
205       mount:
206         - '.composer'
207     volumes:
208       - name: cache
209         path: /tmp/cache
210   - name: Test Friendica
211     image: friendicaci/php7.4:php7.4.18
212     environment:
213       MYSQL_HOST: "mariadb"
214       MYSQL_PORT: 3306
215       MYSQL_DATABASE: "test"
216       MYSQL_PASSWORD: "test"
217       MYSQL_USER: "test"
218       REDIS_HOST: "redis"
219       MEMCACHED_HOST: "memcached"
220       MEMCACHE_HOST: "memcached"
221       XDEBUG_MODE: "coverage"
222     commands:
223       - phpenmod xdebug
224       - cp config/local-sample.config.php config/local.config.php
225       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
226       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
227       - phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml
228   - name: Codecov
229     image: plugins/codecov
230     when:
231       repo:
232         - friendica/friendica
233     settings:
234       token:
235         from_secret: codecov-token
236       files:
237         - clover.xml
238
239 services:
240   - name: mariadb
241     image: mariadb:latest
242     environment:
243       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
244       MYSQL_DATABASE: "test"
245       MYSQL_PASSWORD: "test"
246       MYSQL_USER: "test"
247     tmpfs:
248       - /var/lib/mysql
249
250   - name: memcached
251     image: memcached
252
253   - name: redis
254     image: redis
255
256 volumes:
257   - name: cache
258     host:
259       path: /tmp/drone-cache
260 ---
261 kind: pipeline
262 type: docker
263 name: php8.0-mariadb
264
265 depends_on:
266   - php8.0-lint
267
268 steps:
269   - name: Restore cache
270     image: meltwater/drone-cache:dev
271     settings:
272       backend: "filesystem"
273       restore: true
274       cache_key: '{{ .Repo.Name }}_php80_{{ arch }}_{{ os }}'
275       archive_format: "gzip"
276       mount:
277         - '.composer'
278     volumes:
279       - name: cache
280         path: /tmp/cache
281   - name: Composer install
282     image: friendicaci/php8.0:php8.0.5
283     commands:
284       - export COMPOSER_HOME=.composer
285       - ./bin/composer.phar validate
286       - ./bin/composer.phar install --prefer-dist
287   - name: Rebuild cache
288     image: meltwater/drone-cache:dev
289     settings:
290       backend: "filesystem"
291       rebuild: true
292       cache_key: '{{ .Repo.Name }}_php80_{{ arch }}_{{ os }}'
293       archive_format: "gzip"
294       mount:
295         - '.composer'
296     volumes:
297       - name: cache
298         path: /tmp/cache
299   - name: Test Friendica
300     image: friendicaci/php8.0:php8.0.5
301     environment:
302       MYSQL_HOST: "mariadb"
303       MYSQL_PORT: 3306
304       MYSQL_DATABASE: "test"
305       MYSQL_PASSWORD: "test"
306       MYSQL_USER: "test"
307       REDIS_HOST: "redis"
308       MEMCACHED_HOST: "memcached"
309       MEMCACHE_HOST: "memcached"
310     commands:
311       - cp config/local-sample.config.php config/local.config.php
312       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
313       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
314       - phpunit --configuration tests/phpunit.xml
315
316 services:
317   - name: mariadb
318     image: mariadb:latest
319     environment:
320       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
321       MYSQL_DATABASE: "test"
322       MYSQL_PASSWORD: "test"
323       MYSQL_USER: "test"
324     tmpfs:
325       - /var/lib/mysql
326
327   - name: memcached
328     image: memcached
329
330   - name: redis
331     image: redis
332
333 volumes:
334   - name: cache
335     host:
336       path: /tmp/drone-cache
337 ---
338 kind: pipeline
339 type: docker
340 name: continuous-deployment
341
342 depends_on:
343   - php7.3-mariadb
344   - php7.4-mariadb
345   - php8.0-mariadb
346
347 trigger:
348   repo:
349     - friendica/friendica
350   branch:
351     - develop
352     - 20*-rc
353   event:
354     - push
355
356 node:
357   node: releaser # This prevents executing this pipeline at other servers than drone.friendi.ca
358
359 steps:
360   - name: Restore cache
361     image: meltwater/drone-cache:dev
362     settings:
363       backend: "filesystem"
364       restore: true
365       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
366       archive_format: "gzip"
367       mount:
368         - '.composer'
369     volumes:
370       - name: cache
371         path:
372           /tmp/cache
373   - name: Composer install
374     image: friendicaci/php7.4:php7.4.18
375     commands:
376       - export COMPOSER_HOME=.composer
377       - composer validate
378       - composer install --no-dev --optimize-autoloader
379   - name: Create artifacts
380     image: debian
381     commands:
382       - apt-get update
383       - apt-get install bzip2
384       - mkdir ./build
385       - export VERSION="$(cat VERSION)"
386       - # Create artifact
387       - export RELEASE="friendica-full-$VERSION"
388       - export ARTIFACT="$RELEASE.tar.gz"
389       - tar
390         --transform "s,^,$RELEASE/,"
391         -X mods/release-list-exclude.txt
392         -T mods/release-list-include.txt
393         -cvjf ./build/$ARTIFACT
394       - # calculate SHA256 checksum
395       - cd ./build
396       - sha256sum "$ARTIFACT" > "$ARTIFACT.sum256"
397       - ls -lh
398       - # output the sha256 sum for checking
399       - cat "$ARTIFACT.sum256"
400       - sha256sum "$ARTIFACT"
401   - name: Upload artifacts
402     image: alpine
403     environment:
404       LFTP_HOST:
405         from_secret: sftp_host
406       LFTP_USER:
407         from_secret: sftp_user
408       LFTP_KEY:
409         from_secret: ssh_key
410       LFTP_PORT: "22"
411       LFTP_SOURCE: "build"
412       LFTP_TARGET: "/http"
413     commands:
414       - apk add lftp openssh openssl
415       - touch drone.key
416       - chmod 400 drone.key
417       - echo "$LFTP_KEY" | openssl base64 -A -d > drone.key
418       - lftp -c "
419           set net:timeout 5;
420           set net:max-retries 2;
421           set net:reconnect-interval-base 5;
422           set sftp:auto-confirm true;
423           set sftp:connect-program 'ssh -q -a -x -i drone.key';
424           connect sftp://$LFTP_USER:@$LFTP_HOST:$LFTP_PORT;
425           cd $LFTP_TARGET;
426           mput $LFTP_SOURCE/*;
427         "
428       - rm drone.key
429
430 volumes:
431   - name: cache
432     host:
433       path: /tmp/drone-cache
434 ---
435 kind: pipeline
436 type: docker
437 name: release-deployment
438
439 depends_on:
440   - php7.3-mariadb
441   - php7.4-mariadb
442   - php8.0-mariadb
443
444 trigger:
445   repo:
446     - friendica/friendica
447   branch:
448     - stable
449   event:
450     - tag
451
452 node:
453   node: releaser # This prevents executing this pipeline at other servers than drone.friendi.ca
454
455 steps:
456   - name: Restore cache
457     image: meltwater/drone-cache:dev
458     settings:
459       backend: "filesystem"
460       restore: true
461       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
462       archive_format: "gzip"
463       mount:
464         - '.composer'
465     volumes:
466       - name: cache
467         path:
468           /tmp/cache
469   - name: Composer install
470     image: friendicaci/php7.4:php7.4.18
471     commands:
472       - export COMPOSER_HOME=.composer
473       - composer validate
474       - composer install --no-dev --optimize-autoloader
475   - name: Create artifacts
476     image: debian
477     commands:
478       - apt-get update
479       - apt-get install bzip2
480       - mkdir ./build
481       - export VERSION="$(cat VERSION)"
482       - mkdir ./build
483       - export VERSION="$(cat VERSION)"
484       - # Create artifact
485       - export RELEASE="friendica-full-$VERSION"
486       - export ARTIFACT="$RELEASE.tar.gz"
487       - tar
488         --transform "s,^,$RELEASE/,"
489         -X mods/release-list-exclude.txt
490         -T mods/release-list-include.txt
491         -cvjf ./build/$ARTIFACT
492       - # calculate SHA256 checksum
493       - cd ./build
494       - sha256sum "$ARTIFACT" > "$ARTIFACT.sum256"
495       - ls -lh
496       - # output the sha256 sum for checking
497       - cat "$ARTIFACT.sum256"
498       - sha256sum "$ARTIFACT"
499   - name: Upload artifacts
500     image: alpine
501     environment:
502       LFTP_HOST:
503         from_secret: sftp_host
504       LFTP_USER:
505         from_secret: sftp_user
506       LFTP_KEY:
507         from_secret: ssh_key
508       LFTP_PORT: "22"
509       LFTP_SOURCE: "build"
510       LFTP_TARGET: "/http"
511     commands:
512       - apk add lftp openssh openssl
513       - touch drone.key
514       - chmod 400 drone.key
515       - echo "$LFTP_KEY" | openssl base64 -A -d > drone.key
516       - lftp -c "
517         set net:timeout 5;
518         set net:max-retries 2;
519         set net:reconnect-interval-base 5;
520         set sftp:auto-confirm true;
521         set sftp:connect-program 'ssh -q -a -x -i drone.key';
522         connect sftp://$LFTP_USER:@$LFTP_HOST:$LFTP_PORT;
523         cd $LFTP_TARGET;
524         mput $LFTP_SOURCE/*;
525         "
526       - rm drone.key
527
528 volumes:
529   - name: cache
530     host:
531       path: /tmp/drone-cache