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