]> git.mxchange.org Git - friendica.git/blob - .drone.yml
ET translation updated THX Rain Hawk
[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: Integrity checks
19
20 steps:
21   - name: Check database version
22     image: alpine
23     commands:
24       - export DBSTRUCTURE_VERSION="$(sed -rn "s/.*'DB_UPDATE_VERSION', ([0-9]+).*/\1/p" static/dbstructure.config.php)"
25       - export DATABASE_VERSION="$(sed -rn 's/.*DB_UPDATE_VERSION ([0-9]+).*/\1/p' database.sql)"
26       - echo "Database $DATABASE_VERSION - DB-Structure $DBSTRUCTURE_VERSION"
27       - if [[ "$DBSTRUCTURE_VERSION" != "$DATABASE_VERSION" ]]; then
28           echo "Database version mismatch.";
29           exit 1;
30         fi
31 ---
32 kind: pipeline
33 type: docker
34 name: php7.3-lint
35
36 steps:
37   - name: Test
38     image: php:7.3
39     commands:
40       - ./bin/composer.phar run lint
41 ---
42 kind: pipeline
43 type: docker
44 name: php7.4-lint
45
46 steps:
47   - name: Test
48     image: php:7.4
49     commands:
50       - ./bin/composer.phar run lint
51 ---
52 kind: pipeline
53 type: docker
54 name: php8.0-lint
55
56 steps:
57   - name: Test
58     image: php:8.0
59     commands:
60       - ./bin/composer.phar run lint
61 ---
62 kind: pipeline
63 type: docker
64 name: php-cs check
65
66 trigger:
67   event:
68     - pull_request
69
70 steps:
71   - name: Restore cache
72     image: meltwater/drone-cache:dev
73     settings:
74       backend: "filesystem"
75       restore: true
76       cache_key: '{{ .Repo.Name }}_phpcs_{{ arch }}_{{ os }}'
77       archive_format: "gzip"
78       mount:
79         - '.composer'
80     volumes:
81       - name: cache
82         path: /tmp/cache
83   - name: Install dependencies
84     image: composer
85     commands:
86       - export COMPOSER_HOME=.composer
87       - ./bin/composer.phar run cs:install
88   - name: Rebuild cache
89     image: meltwater/drone-cache:dev
90     settings:
91       backend: "filesystem"
92       rebuild: true
93       cache_key: '{{ .Repo.Name }}_phpcs_{{ arch }}_{{ os }}'
94       archive_format: "gzip"
95       mount:
96         - '.composer'
97     volumes:
98       - name: cache
99         path: /tmp/cache
100   - name: Run coding standards check
101     image: friendicaci/php-cs
102     commands:
103       - export CHANGED_FILES="$(git diff --name-status ${DRONE_COMMIT_BEFORE}..${DRONE_COMMIT_AFTER} | grep ^A | cut -f2)"
104       - /check-php-cs.sh
105
106 volumes:
107   - name: cache
108     host:
109       path: /tmp/drone-cache
110 ---
111 kind: pipeline
112 type: docker
113 name: php7.4-database-check
114
115 depends_on:
116   - Integrity checks
117
118 steps:
119   - name: Restore cache
120     image: meltwater/drone-cache:dev
121     settings:
122       backend: "filesystem"
123       restore: true
124       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
125       archive_format: "gzip"
126       mount:
127         - '.composer'
128     volumes:
129       - name: cache
130         path: /tmp/cache
131   - name: Composer install
132     image: friendicaci/php7.4:php7.4.18
133     commands:
134       - export COMPOSER_HOME=.composer
135       - ./bin/composer.phar validate
136       - ./bin/composer.phar install --prefer-dist
137   - name: Rebuild cache
138     image: meltwater/drone-cache:dev
139     settings:
140       backend: "filesystem"
141       rebuild: true
142       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
143       archive_format: "gzip"
144       mount:
145         - '.composer'
146     volumes:
147       - name: cache
148         path: /tmp/cache
149   - name: Recreate database.sql
150     image: friendicaci/php7.4:php7.4.18
151     environment:
152       MYSQL_HOST: "mariadb"
153       MYSQL_PORT: 3306
154       MYSQL_DATABASE: "test"
155       MYSQL_PASSWORD: "test"
156       MYSQL_USER: "test"
157       REDIS_HOST: "redis"
158       MEMCACHED_HOST: "memcached"
159       MEMCACHE_HOST: "memcached"
160       XDEBUG_MODE: "coverage"
161     commands:
162       - phpenmod xdebug
163       - cp config/local-sample.config.php config/local.config.php
164       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
165       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
166       - php ./bin/console.php dbstructure dumpsql > database.sql
167   - name: Check database.sql
168     image: alpine/git
169     commands:
170       - git update-index --refresh
171       - git diff-index --quiet HEAD --
172       - if [[ $? -ne 0 ]]; then
173           echo "database.sql mismatch.";
174           exit 1;
175         fi
176
177 services:
178   - name: mariadb
179     image: mariadb:latest
180     environment:
181       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
182       MYSQL_DATABASE: "test"
183       MYSQL_PASSWORD: "test"
184       MYSQL_USER: "test"
185     tmpfs:
186       - /var/lib/mysql
187
188 volumes:
189   - name: cache
190     host:
191       path: /tmp/drone-cache
192 ---
193 kind: pipeline
194 type: docker
195 name: php7.3-mariadb
196
197 depends_on:
198   - php7.3-lint
199
200 steps:
201   - name: Restore cache
202     image: meltwater/drone-cache:dev
203     settings:
204       backend: "filesystem"
205       restore: true
206       cache_key: '{{ .Repo.Name }}_php73_{{ arch }}_{{ os }}'
207       archive_format: "gzip"
208       mount:
209         - '.composer'
210     volumes:
211       - name: cache
212         path: /tmp/cache
213   - name: Composer install
214     image: friendicaci/php7.3:php7.3.28
215     commands:
216       - export COMPOSER_HOME=.composer
217       - ./bin/composer.phar validate
218       - ./bin/composer.phar install --prefer-dist
219   - name: Rebuild cache
220     image: meltwater/drone-cache:dev
221     settings:
222       backend: "filesystem"
223       rebuild: true
224       cache_key: '{{ .Repo.Name }}_php73_{{ arch }}_{{ os }}'
225       archive_format: "gzip"
226       mount:
227         - '.composer'
228     volumes:
229       - name: cache
230         path: /tmp/cache
231   - name: Test Friendica
232     image: friendicaci/php7.3:php7.3.28
233     environment:
234       MYSQL_HOST: "mariadb"
235       MYSQL_PORT: 3306
236       MYSQL_DATABASE: "test"
237       MYSQL_PASSWORD: "test"
238       MYSQL_USER: "test"
239       REDIS_HOST: "redis"
240       MEMCACHED_HOST: "memcached"
241       MEMCACHE_HOST: "memcached"
242     commands:
243       - cp config/local-sample.config.php config/local.config.php
244       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
245       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
246       - phpunit --configuration tests/phpunit.xml
247
248 services:
249   - name: mariadb
250     image: mariadb:latest
251     environment:
252       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
253       MYSQL_DATABASE: "test"
254       MYSQL_PASSWORD: "test"
255       MYSQL_USER: "test"
256     tmpfs:
257       - /var/lib/mysql
258
259   - name: memcached
260     image: memcached
261
262   - name: redis
263     image: redis
264
265 volumes:
266   - name: cache
267     host:
268       path: /tmp/drone-cache
269 ---
270 kind: pipeline
271 type: docker
272 name: php7.4-mariadb
273
274 depends_on:
275   - php7.4-lint
276
277 steps:
278   - name: Restore cache
279     image: meltwater/drone-cache:dev
280     settings:
281       backend: "filesystem"
282       restore: true
283       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
284       archive_format: "gzip"
285       mount:
286         - '.composer'
287     volumes:
288       - name: cache
289         path: /tmp/cache
290   - name: Composer install
291     image: friendicaci/php7.4:php7.4.18
292     commands:
293       - export COMPOSER_HOME=.composer
294       - ./bin/composer.phar validate
295       - ./bin/composer.phar install --prefer-dist
296   - name: Rebuild cache
297     image: meltwater/drone-cache:dev
298     settings:
299       backend: "filesystem"
300       rebuild: true
301       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
302       archive_format: "gzip"
303       mount:
304         - '.composer'
305     volumes:
306       - name: cache
307         path: /tmp/cache
308   - name: Test Friendica
309     image: friendicaci/php7.4:php7.4.18
310     environment:
311       MYSQL_HOST: "mariadb"
312       MYSQL_PORT: 3306
313       MYSQL_DATABASE: "test"
314       MYSQL_PASSWORD: "test"
315       MYSQL_USER: "test"
316       REDIS_HOST: "redis"
317       MEMCACHED_HOST: "memcached"
318       MEMCACHE_HOST: "memcached"
319       XDEBUG_MODE: "coverage"
320     commands:
321       - phpenmod xdebug
322       - cp config/local-sample.config.php config/local.config.php
323       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
324       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
325       - phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml
326   - name: Codecov
327     image: plugins/codecov
328     when:
329       repo:
330         - friendica/friendica
331     settings:
332       token:
333         from_secret: codecov-token
334       files:
335         - clover.xml
336
337 services:
338   - name: mariadb
339     image: mariadb:latest
340     environment:
341       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
342       MYSQL_DATABASE: "test"
343       MYSQL_PASSWORD: "test"
344       MYSQL_USER: "test"
345     tmpfs:
346       - /var/lib/mysql
347
348   - name: memcached
349     image: memcached
350
351   - name: redis
352     image: redis
353
354 volumes:
355   - name: cache
356     host:
357       path: /tmp/drone-cache
358 ---
359 kind: pipeline
360 type: docker
361 name: php8.0-mariadb
362
363 depends_on:
364   - php8.0-lint
365
366 steps:
367   - name: Restore cache
368     image: meltwater/drone-cache:dev
369     settings:
370       backend: "filesystem"
371       restore: true
372       cache_key: '{{ .Repo.Name }}_php80_{{ arch }}_{{ os }}'
373       archive_format: "gzip"
374       mount:
375         - '.composer'
376     volumes:
377       - name: cache
378         path: /tmp/cache
379   - name: Composer install
380     image: friendicaci/php8.0:php8.0.5
381     commands:
382       - export COMPOSER_HOME=.composer
383       - ./bin/composer.phar validate
384       - ./bin/composer.phar install --prefer-dist
385   - name: Rebuild cache
386     image: meltwater/drone-cache:dev
387     settings:
388       backend: "filesystem"
389       rebuild: true
390       cache_key: '{{ .Repo.Name }}_php80_{{ arch }}_{{ os }}'
391       archive_format: "gzip"
392       mount:
393         - '.composer'
394     volumes:
395       - name: cache
396         path: /tmp/cache
397   - name: Test Friendica
398     image: friendicaci/php8.0:php8.0.5
399     environment:
400       MYSQL_HOST: "mariadb"
401       MYSQL_PORT: 3306
402       MYSQL_DATABASE: "test"
403       MYSQL_PASSWORD: "test"
404       MYSQL_USER: "test"
405       REDIS_HOST: "redis"
406       MEMCACHED_HOST: "memcached"
407       MEMCACHE_HOST: "memcached"
408     commands:
409       - cp config/local-sample.config.php config/local.config.php
410       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
411       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
412       - phpunit --configuration tests/phpunit.xml
413
414 services:
415   - name: mariadb
416     image: mariadb:latest
417     environment:
418       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
419       MYSQL_DATABASE: "test"
420       MYSQL_PASSWORD: "test"
421       MYSQL_USER: "test"
422     tmpfs:
423       - /var/lib/mysql
424
425   - name: memcached
426     image: memcached
427
428   - name: redis
429     image: redis
430
431 volumes:
432   - name: cache
433     host:
434       path: /tmp/drone-cache
435 ---
436 kind: pipeline
437 type: docker
438 name: continuous-deployment
439
440 depends_on:
441   - php7.3-mariadb
442   - php7.4-mariadb
443   - php8.0-mariadb
444
445 trigger:
446   repo:
447     - friendica/friendica
448   branch:
449     - develop
450     - 20*-rc
451   event:
452     - push
453
454 node:
455   node: releaser # This prevents executing this pipeline at other servers than drone.friendi.ca
456
457 steps:
458   - name: Restore cache
459     image: meltwater/drone-cache:dev
460     settings:
461       backend: "filesystem"
462       restore: true
463       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
464       archive_format: "gzip"
465       mount:
466         - '.composer'
467     volumes:
468       - name: cache
469         path:
470           /tmp/cache
471   - name: Composer install
472     image: friendicaci/php7.4:php7.4.18
473     commands:
474       - export COMPOSER_HOME=.composer
475       - composer validate
476       - composer install --no-dev --optimize-autoloader
477   - name: Create artifacts
478     image: debian
479     commands:
480       - apt-get update
481       - apt-get install bzip2
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         -cvzf ./build/$ARTIFACT
492       - # calculate SHA256 checksum
493       - cd ./build
494       - sha256sum "$ARTIFACT" > "$ARTIFACT.sum256"
495       - chmod 664 ./*
496       - ls -lh
497       - # output the sha256 sum for checking
498       - cat "$ARTIFACT.sum256"
499       - sha256sum "$ARTIFACT"
500   - name: Sign artifacts
501     image: plugins/gpgsign
502     settings:
503       key:
504         from_secret: gpg_key
505       passphrase:
506         from_secret: gpg_password
507       files:
508         - build/*
509       exclude:
510         - build/*.sum256
511       detach_sign: true
512   - name: Upload artifacts
513     image: alpine
514     environment:
515       LFTP_HOST:
516         from_secret: sftp_host
517       LFTP_USER:
518         from_secret: sftp_user
519       LFTP_KEY:
520         from_secret: ssh_key
521       LFTP_PORT: "22"
522       LFTP_SOURCE: "build"
523       LFTP_TARGET: "/http"
524     commands:
525       - apk add lftp openssh openssl
526       - touch drone.key
527       - chmod 400 drone.key
528       - echo "$LFTP_KEY" | openssl base64 -A -d > drone.key
529       - lftp -c "
530           set net:timeout 5;
531           set net:max-retries 2;
532           set net:reconnect-interval-base 5;
533           set sftp:auto-confirm true;
534           set sftp:connect-program 'ssh -q -a -x -i drone.key';
535           connect sftp://$LFTP_USER:@$LFTP_HOST:$LFTP_PORT;
536           cd $LFTP_TARGET;
537           mput $LFTP_SOURCE/*;
538         "
539       - rm drone.key
540
541 volumes:
542   - name: cache
543     host:
544       path: /tmp/drone-cache
545 ---
546 kind: pipeline
547 type: docker
548 name: release-deployment
549
550 depends_on:
551   - php7.3-mariadb
552   - php7.4-mariadb
553   - php8.0-mariadb
554
555 trigger:
556   repo:
557     - friendica/friendica
558   branch:
559     - stable
560   event:
561     - tag
562
563 node:
564   node: releaser # This prevents executing this pipeline at other servers than drone.friendi.ca
565
566 steps:
567   - name: Restore cache
568     image: meltwater/drone-cache:dev
569     settings:
570       backend: "filesystem"
571       restore: true
572       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
573       archive_format: "gzip"
574       mount:
575         - '.composer'
576     volumes:
577       - name: cache
578         path:
579           /tmp/cache
580   - name: Composer install
581     image: friendicaci/php7.4:php7.4.18
582     commands:
583       - export COMPOSER_HOME=.composer
584       - composer validate
585       - composer install --no-dev --optimize-autoloader
586   - name: Create artifacts
587     image: debian
588     commands:
589       - apt-get update
590       - apt-get install bzip2
591       - mkdir ./build
592       - export VERSION="$(cat VERSION)"
593       - # Create artifact
594       - export RELEASE="friendica-full-$VERSION"
595       - export ARTIFACT="$RELEASE.tar.gz"
596       - tar
597         --transform "s,^,$RELEASE/,"
598         -X mods/release-list-exclude.txt
599         -T mods/release-list-include.txt
600         -cvzf ./build/$ARTIFACT
601       - # calculate SHA256 checksum
602       - cd ./build
603       - sha256sum "$ARTIFACT" > "$ARTIFACT.sum256"
604       - chmod 664 ./*
605       - ls -lh
606       - # output the sha256 sum for checking
607       - cat "$ARTIFACT.sum256"
608       - sha256sum "$ARTIFACT"
609   - name: Sign artifacts
610     image: plugins/gpgsign
611     settings:
612       key:
613         from_secret: gpg_key
614       passphrase:
615         from_secret: gpg_password
616       files:
617         - build/*
618       exclude:
619         - build/*.sum256
620       detach_sign: true
621   - name: Upload artifacts
622     image: alpine
623     environment:
624       LFTP_HOST:
625         from_secret: sftp_host
626       LFTP_USER:
627         from_secret: sftp_user
628       LFTP_KEY:
629         from_secret: ssh_key
630       LFTP_PORT: "22"
631       LFTP_SOURCE: "build"
632       LFTP_TARGET: "/http"
633     commands:
634       - apk add lftp openssh openssl
635       - touch drone.key
636       - chmod 400 drone.key
637       - echo "$LFTP_KEY" | openssl base64 -A -d > drone.key
638       - lftp -c "
639         set net:timeout 5;
640         set net:max-retries 2;
641         set net:reconnect-interval-base 5;
642         set sftp:auto-confirm true;
643         set sftp:connect-program 'ssh -q -a -x -i drone.key';
644         connect sftp://$LFTP_USER:@$LFTP_HOST:$LFTP_PORT;
645         cd $LFTP_TARGET;
646         mput $LFTP_SOURCE/*;
647         "
648       - rm drone.key
649
650 volumes:
651   - name: cache
652     host:
653       path: /tmp/drone-cache