]> git.mxchange.org Git - friendica.git/blob - .drone.yml
580d8b8af754b4ed34b8c838eb681ec70adc0062
[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: Codecov
168     image: plugins/codecov
169     when:
170       repo:
171         - friendica/friendica
172     settings:
173       token:
174         from_secret: codecov-token
175       files:
176         - clover.xml
177   - name: Check database.sql
178     image: alpine
179     commands:
180       - git update-index --refresh
181       - git diff-index --quiet HEAD --
182       - if [[ $? -ne 0 ]]; then
183         echo "database.sql mismatch.";
184         exit 1;
185         fi
186
187 services:
188   - name: mariadb
189     image: mariadb:latest
190     environment:
191       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
192       MYSQL_DATABASE: "test"
193       MYSQL_PASSWORD: "test"
194       MYSQL_USER: "test"
195     tmpfs:
196       - /var/lib/mysql
197
198 volumes:
199   - name: cache
200     host:
201       path: /tmp/drone-cache
202 ---
203 kind: pipeline
204 type: docker
205 name: php7.3-mariadb
206
207 depends_on:
208   - php7.3-lint
209
210 steps:
211   - name: Restore cache
212     image: meltwater/drone-cache:dev
213     settings:
214       backend: "filesystem"
215       restore: true
216       cache_key: '{{ .Repo.Name }}_php73_{{ arch }}_{{ os }}'
217       archive_format: "gzip"
218       mount:
219         - '.composer'
220     volumes:
221       - name: cache
222         path: /tmp/cache
223   - name: Composer install
224     image: friendicaci/php7.3:php7.3.28
225     commands:
226       - export COMPOSER_HOME=.composer
227       - ./bin/composer.phar validate
228       - ./bin/composer.phar install --prefer-dist
229   - name: Rebuild cache
230     image: meltwater/drone-cache:dev
231     settings:
232       backend: "filesystem"
233       rebuild: true
234       cache_key: '{{ .Repo.Name }}_php73_{{ arch }}_{{ os }}'
235       archive_format: "gzip"
236       mount:
237         - '.composer'
238     volumes:
239       - name: cache
240         path: /tmp/cache
241   - name: Test Friendica
242     image: friendicaci/php7.3:php7.3.28
243     environment:
244       MYSQL_HOST: "mariadb"
245       MYSQL_PORT: 3306
246       MYSQL_DATABASE: "test"
247       MYSQL_PASSWORD: "test"
248       MYSQL_USER: "test"
249       REDIS_HOST: "redis"
250       MEMCACHED_HOST: "memcached"
251       MEMCACHE_HOST: "memcached"
252     commands:
253       - cp config/local-sample.config.php config/local.config.php
254       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
255       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
256       - phpunit --configuration tests/phpunit.xml
257
258 services:
259   - name: mariadb
260     image: mariadb:latest
261     environment:
262       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
263       MYSQL_DATABASE: "test"
264       MYSQL_PASSWORD: "test"
265       MYSQL_USER: "test"
266     tmpfs:
267       - /var/lib/mysql
268
269   - name: memcached
270     image: memcached
271
272   - name: redis
273     image: redis
274
275 volumes:
276   - name: cache
277     host:
278       path: /tmp/drone-cache
279 ---
280 kind: pipeline
281 type: docker
282 name: php7.4-mariadb
283
284 depends_on:
285   - php7.4-lint
286
287 steps:
288   - name: Restore cache
289     image: meltwater/drone-cache:dev
290     settings:
291       backend: "filesystem"
292       restore: true
293       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
294       archive_format: "gzip"
295       mount:
296         - '.composer'
297     volumes:
298       - name: cache
299         path: /tmp/cache
300   - name: Composer install
301     image: friendicaci/php7.4:php7.4.18
302     commands:
303       - export COMPOSER_HOME=.composer
304       - ./bin/composer.phar validate
305       - ./bin/composer.phar install --prefer-dist
306   - name: Rebuild cache
307     image: meltwater/drone-cache:dev
308     settings:
309       backend: "filesystem"
310       rebuild: true
311       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
312       archive_format: "gzip"
313       mount:
314         - '.composer'
315     volumes:
316       - name: cache
317         path: /tmp/cache
318   - name: Test Friendica
319     image: friendicaci/php7.4:php7.4.18
320     environment:
321       MYSQL_HOST: "mariadb"
322       MYSQL_PORT: 3306
323       MYSQL_DATABASE: "test"
324       MYSQL_PASSWORD: "test"
325       MYSQL_USER: "test"
326       REDIS_HOST: "redis"
327       MEMCACHED_HOST: "memcached"
328       MEMCACHE_HOST: "memcached"
329       XDEBUG_MODE: "coverage"
330     commands:
331       - phpenmod xdebug
332       - cp config/local-sample.config.php config/local.config.php
333       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
334       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
335       - phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml
336   - name: Codecov
337     image: plugins/codecov
338     when:
339       repo:
340         - friendica/friendica
341     settings:
342       token:
343         from_secret: codecov-token
344       files:
345         - clover.xml
346
347 services:
348   - name: mariadb
349     image: mariadb:latest
350     environment:
351       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
352       MYSQL_DATABASE: "test"
353       MYSQL_PASSWORD: "test"
354       MYSQL_USER: "test"
355     tmpfs:
356       - /var/lib/mysql
357
358   - name: memcached
359     image: memcached
360
361   - name: redis
362     image: redis
363
364 volumes:
365   - name: cache
366     host:
367       path: /tmp/drone-cache
368 ---
369 kind: pipeline
370 type: docker
371 name: php8.0-mariadb
372
373 depends_on:
374   - php8.0-lint
375
376 steps:
377   - name: Restore cache
378     image: meltwater/drone-cache:dev
379     settings:
380       backend: "filesystem"
381       restore: true
382       cache_key: '{{ .Repo.Name }}_php80_{{ arch }}_{{ os }}'
383       archive_format: "gzip"
384       mount:
385         - '.composer'
386     volumes:
387       - name: cache
388         path: /tmp/cache
389   - name: Composer install
390     image: friendicaci/php8.0:php8.0.5
391     commands:
392       - export COMPOSER_HOME=.composer
393       - ./bin/composer.phar validate
394       - ./bin/composer.phar install --prefer-dist
395   - name: Rebuild cache
396     image: meltwater/drone-cache:dev
397     settings:
398       backend: "filesystem"
399       rebuild: true
400       cache_key: '{{ .Repo.Name }}_php80_{{ arch }}_{{ os }}'
401       archive_format: "gzip"
402       mount:
403         - '.composer'
404     volumes:
405       - name: cache
406         path: /tmp/cache
407   - name: Test Friendica
408     image: friendicaci/php8.0:php8.0.5
409     environment:
410       MYSQL_HOST: "mariadb"
411       MYSQL_PORT: 3306
412       MYSQL_DATABASE: "test"
413       MYSQL_PASSWORD: "test"
414       MYSQL_USER: "test"
415       REDIS_HOST: "redis"
416       MEMCACHED_HOST: "memcached"
417       MEMCACHE_HOST: "memcached"
418     commands:
419       - cp config/local-sample.config.php config/local.config.php
420       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
421       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
422       - phpunit --configuration tests/phpunit.xml
423
424 services:
425   - name: mariadb
426     image: mariadb:latest
427     environment:
428       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
429       MYSQL_DATABASE: "test"
430       MYSQL_PASSWORD: "test"
431       MYSQL_USER: "test"
432     tmpfs:
433       - /var/lib/mysql
434
435   - name: memcached
436     image: memcached
437
438   - name: redis
439     image: redis
440
441 volumes:
442   - name: cache
443     host:
444       path: /tmp/drone-cache
445 ---
446 kind: pipeline
447 type: docker
448 name: continuous-deployment
449
450 depends_on:
451   - php7.3-mariadb
452   - php7.4-mariadb
453   - php8.0-mariadb
454
455 trigger:
456   repo:
457     - friendica/friendica
458   branch:
459     - develop
460     - 20*-rc
461   event:
462     - push
463
464 node:
465   node: releaser # This prevents executing this pipeline at other servers than drone.friendi.ca
466
467 steps:
468   - name: Restore cache
469     image: meltwater/drone-cache:dev
470     settings:
471       backend: "filesystem"
472       restore: true
473       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
474       archive_format: "gzip"
475       mount:
476         - '.composer'
477     volumes:
478       - name: cache
479         path:
480           /tmp/cache
481   - name: Composer install
482     image: friendicaci/php7.4:php7.4.18
483     commands:
484       - export COMPOSER_HOME=.composer
485       - composer validate
486       - composer install --no-dev --optimize-autoloader
487   - name: Create artifacts
488     image: debian
489     commands:
490       - apt-get update
491       - apt-get install bzip2
492       - mkdir ./build
493       - export VERSION="$(cat VERSION)"
494       - # Create artifact
495       - export RELEASE="friendica-full-$VERSION"
496       - export ARTIFACT="$RELEASE.tar.gz"
497       - tar
498         --transform "s,^,$RELEASE/,"
499         -X mods/release-list-exclude.txt
500         -T mods/release-list-include.txt
501         -cvzf ./build/$ARTIFACT
502       - # calculate SHA256 checksum
503       - cd ./build
504       - sha256sum "$ARTIFACT" > "$ARTIFACT.sum256"
505       - chmod 664 ./*
506       - ls -lh
507       - # output the sha256 sum for checking
508       - cat "$ARTIFACT.sum256"
509       - sha256sum "$ARTIFACT"
510   - name: Sign artifacts
511     image: plugins/gpgsign
512     settings:
513       key:
514         from_secret: gpg_key
515       passphrase:
516         from_secret: gpg_password
517       files:
518         - build/*
519       exclude:
520         - build/*.sum256
521       detach_sign: true
522   - name: Upload artifacts
523     image: alpine
524     environment:
525       LFTP_HOST:
526         from_secret: sftp_host
527       LFTP_USER:
528         from_secret: sftp_user
529       LFTP_KEY:
530         from_secret: ssh_key
531       LFTP_PORT: "22"
532       LFTP_SOURCE: "build"
533       LFTP_TARGET: "/http"
534     commands:
535       - apk add lftp openssh openssl
536       - touch drone.key
537       - chmod 400 drone.key
538       - echo "$LFTP_KEY" | openssl base64 -A -d > drone.key
539       - lftp -c "
540           set net:timeout 5;
541           set net:max-retries 2;
542           set net:reconnect-interval-base 5;
543           set sftp:auto-confirm true;
544           set sftp:connect-program 'ssh -q -a -x -i drone.key';
545           connect sftp://$LFTP_USER:@$LFTP_HOST:$LFTP_PORT;
546           cd $LFTP_TARGET;
547           mput $LFTP_SOURCE/*;
548         "
549       - rm drone.key
550
551 volumes:
552   - name: cache
553     host:
554       path: /tmp/drone-cache
555 ---
556 kind: pipeline
557 type: docker
558 name: release-deployment
559
560 depends_on:
561   - php7.3-mariadb
562   - php7.4-mariadb
563   - php8.0-mariadb
564
565 trigger:
566   repo:
567     - friendica/friendica
568   branch:
569     - stable
570   event:
571     - tag
572
573 node:
574   node: releaser # This prevents executing this pipeline at other servers than drone.friendi.ca
575
576 steps:
577   - name: Restore cache
578     image: meltwater/drone-cache:dev
579     settings:
580       backend: "filesystem"
581       restore: true
582       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
583       archive_format: "gzip"
584       mount:
585         - '.composer'
586     volumes:
587       - name: cache
588         path:
589           /tmp/cache
590   - name: Composer install
591     image: friendicaci/php7.4:php7.4.18
592     commands:
593       - export COMPOSER_HOME=.composer
594       - composer validate
595       - composer install --no-dev --optimize-autoloader
596   - name: Create artifacts
597     image: debian
598     commands:
599       - apt-get update
600       - apt-get install bzip2
601       - mkdir ./build
602       - export VERSION="$(cat VERSION)"
603       - # Create artifact
604       - export RELEASE="friendica-full-$VERSION"
605       - export ARTIFACT="$RELEASE.tar.gz"
606       - tar
607         --transform "s,^,$RELEASE/,"
608         -X mods/release-list-exclude.txt
609         -T mods/release-list-include.txt
610         -cvzf ./build/$ARTIFACT
611       - # calculate SHA256 checksum
612       - cd ./build
613       - sha256sum "$ARTIFACT" > "$ARTIFACT.sum256"
614       - chmod 664 ./*
615       - ls -lh
616       - # output the sha256 sum for checking
617       - cat "$ARTIFACT.sum256"
618       - sha256sum "$ARTIFACT"
619   - name: Sign artifacts
620     image: plugins/gpgsign
621     settings:
622       key:
623         from_secret: gpg_key
624       passphrase:
625         from_secret: gpg_password
626       files:
627         - build/*
628       exclude:
629         - build/*.sum256
630       detach_sign: true
631   - name: Upload artifacts
632     image: alpine
633     environment:
634       LFTP_HOST:
635         from_secret: sftp_host
636       LFTP_USER:
637         from_secret: sftp_user
638       LFTP_KEY:
639         from_secret: ssh_key
640       LFTP_PORT: "22"
641       LFTP_SOURCE: "build"
642       LFTP_TARGET: "/http"
643     commands:
644       - apk add lftp openssh openssl
645       - touch drone.key
646       - chmod 400 drone.key
647       - echo "$LFTP_KEY" | openssl base64 -A -d > drone.key
648       - lftp -c "
649         set net:timeout 5;
650         set net:max-retries 2;
651         set net:reconnect-interval-base 5;
652         set sftp:auto-confirm true;
653         set sftp:connect-program 'ssh -q -a -x -i drone.key';
654         connect sftp://$LFTP_USER:@$LFTP_HOST:$LFTP_PORT;
655         cd $LFTP_TARGET;
656         mput $LFTP_SOURCE/*;
657         "
658       - rm drone.key
659
660 volumes:
661   - name: cache
662     host:
663       path: /tmp/drone-cache