]> git.mxchange.org Git - friendica.git/blob - .drone.yml
Merge pull request #10749 from tobiasd/20210923-ru
[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       - ls -lh
414       - # output the sha256 sum for checking
415       - cat "$ARTIFACT.sum256"
416       - sha256sum "$ARTIFACT"
417   - name: Sign artifacts
418     image: plugins/gpgsign
419     settings:
420       key:
421         from_secret: gpg_key
422       passphrase:
423         from_secret: gpg_password
424       files:
425         - build/*
426       exclude:
427         - build/*.sum256
428       detach_sign: true
429   - name: Upload artifacts
430     image: alpine
431     environment:
432       LFTP_HOST:
433         from_secret: sftp_host
434       LFTP_USER:
435         from_secret: sftp_user
436       LFTP_KEY:
437         from_secret: ssh_key
438       LFTP_PORT: "22"
439       LFTP_SOURCE: "build"
440       LFTP_TARGET: "/http"
441     commands:
442       - apk add lftp openssh openssl
443       - touch drone.key
444       - chmod 400 drone.key
445       - echo "$LFTP_KEY" | openssl base64 -A -d > drone.key
446       - lftp -c "
447           set net:timeout 5;
448           set net:max-retries 2;
449           set net:reconnect-interval-base 5;
450           set sftp:auto-confirm true;
451           set sftp:connect-program 'ssh -q -a -x -i drone.key';
452           connect sftp://$LFTP_USER:@$LFTP_HOST:$LFTP_PORT;
453           cd $LFTP_TARGET;
454           mput $LFTP_SOURCE/*;
455         "
456       - rm drone.key
457
458 volumes:
459   - name: cache
460     host:
461       path: /tmp/drone-cache
462 ---
463 kind: pipeline
464 type: docker
465 name: release-deployment
466
467 depends_on:
468   - php7.3-mariadb
469   - php7.4-mariadb
470   - php8.0-mariadb
471
472 trigger:
473   repo:
474     - friendica/friendica
475   branch:
476     - stable
477   event:
478     - tag
479
480 node:
481   node: releaser # This prevents executing this pipeline at other servers than drone.friendi.ca
482
483 steps:
484   - name: Restore cache
485     image: meltwater/drone-cache:dev
486     settings:
487       backend: "filesystem"
488       restore: true
489       cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}'
490       archive_format: "gzip"
491       mount:
492         - '.composer'
493     volumes:
494       - name: cache
495         path:
496           /tmp/cache
497   - name: Composer install
498     image: friendicaci/php7.4:php7.4.18
499     commands:
500       - export COMPOSER_HOME=.composer
501       - composer validate
502       - composer install --no-dev --optimize-autoloader
503   - name: Create artifacts
504     image: debian
505     commands:
506       - apt-get update
507       - apt-get install bzip2
508       - mkdir ./build
509       - export VERSION="$(cat VERSION)"
510       - # Create artifact
511       - export RELEASE="friendica-full-$VERSION"
512       - export ARTIFACT="$RELEASE.tar.gz"
513       - tar
514         --transform "s,^,$RELEASE/,"
515         -X mods/release-list-exclude.txt
516         -T mods/release-list-include.txt
517         -cvzf ./build/$ARTIFACT
518       - # calculate SHA256 checksum
519       - cd ./build
520       - sha256sum "$ARTIFACT" > "$ARTIFACT.sum256"
521       - ls -lh
522       - # output the sha256 sum for checking
523       - cat "$ARTIFACT.sum256"
524       - sha256sum "$ARTIFACT"
525   - name: Sign artifacts
526     image: plugins/gpgsign
527     settings:
528       key:
529         from_secret: gpg_key
530       passphrase:
531         from_secret: gpg_password
532       files:
533         - build/*
534       exclude:
535         - build/*.sum256
536       detach_sign: true
537   - name: Upload artifacts
538     image: alpine
539     environment:
540       LFTP_HOST:
541         from_secret: sftp_host
542       LFTP_USER:
543         from_secret: sftp_user
544       LFTP_KEY:
545         from_secret: ssh_key
546       LFTP_PORT: "22"
547       LFTP_SOURCE: "build"
548       LFTP_TARGET: "/http"
549     commands:
550       - apk add lftp openssh openssl
551       - touch drone.key
552       - chmod 400 drone.key
553       - echo "$LFTP_KEY" | openssl base64 -A -d > drone.key
554       - lftp -c "
555         set net:timeout 5;
556         set net:max-retries 2;
557         set net:reconnect-interval-base 5;
558         set sftp:auto-confirm true;
559         set sftp:connect-program 'ssh -q -a -x -i drone.key';
560         connect sftp://$LFTP_USER:@$LFTP_HOST:$LFTP_PORT;
561         cd $LFTP_TARGET;
562         mput $LFTP_SOURCE/*;
563         "
564       - rm drone.key
565
566 volumes:
567   - name: cache
568     host:
569       path: /tmp/drone-cache