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