]> git.mxchange.org Git - friendica.git/blob - .woodpecker/.database_checks.yml
Fix a problem with MySQL
[friendica.git] / .woodpecker / .database_checks.yml
1 matrix:
2   include:
3     - PHP_MAJOR_VERSION: 7.4
4       PHP_VERSION: 7.4.33
5
6 branches:
7   exclude: [ stable ]
8
9 # This forces CI executions at the "opensocial" labeled location (because of much more power...)
10 labels:
11   location: opensocial
12
13 steps:
14   db_version_match:
15     image: friendicaci/transifex
16     commands:
17       - export DBSTRUCTURE_VERSION="$(sed -rn "s/.*'DB_UPDATE_VERSION', ([0-9]+).*/\1/p" static/dbstructure.config.php)"
18       - export DATABASE_VERSION="$(sed -rn 's/.*DB_UPDATE_VERSION ([0-9]+).*/\1/p' database.sql)"
19       - echo "Database $DATABASE_VERSION - DB-Structure $DBSTRUCTURE_VERSION"
20       - if [ "$DBSTRUCTURE_VERSION" != "$DATABASE_VERSION" ]; then
21           echo "Database version mismatch.";
22           exit 1;
23         fi
24   restore_cache:
25     image: meltwater/drone-cache:dev
26     settings:
27       backend: "filesystem"
28       restore: true
29       cache_key: "{{ .Repo.Name }}_php${PHP_MAJOR_VERSION}_{{ arch }}_{{ os }}"
30       archive_format: "gzip"
31       mount:
32         - '.composer'
33     volumes:
34       - /tmp/drone-cache:/tmp/cache
35   composer_install:
36     image: friendicaci/php${PHP_MAJOR_VERSION}:php${PHP_VERSION}
37     commands:
38       - export COMPOSER_HOME=.composer
39       - ./bin/composer.phar validate
40       - ./bin/composer.phar install --prefer-dist
41     volumes:
42       - /etc/hosts:/etc/hosts
43   rebuild_cache:
44     image: meltwater/drone-cache:dev
45     settings:
46       backend: "filesystem"
47       rebuild: true
48       cache_key: "{{ .Repo.Name }}_php${PHP_MAJOR_VERSION}_{{ arch }}_{{ os }}"
49       archive_format: "gzip"
50       mount:
51         - '.composer'
52     volumes:
53       - /tmp/drone-cache:/tmp/cache
54   recreate_database.sql:
55     image: friendicaci/php${PHP_MAJOR_VERSION}:php${PHP_VERSION}
56     environment:
57       MYSQL_HOST: "mariadb"
58       MYSQL_PORT: "3306"
59       MYSQL_DATABASE: "test"
60       MYSQL_PASSWORD: "test"
61       MYSQL_USER: "test"
62       REDIS_HOST: "redis"
63       MEMCACHED_HOST: "memcached"
64       MEMCACHE_HOST: "memcached"
65       XDEBUG_MODE: "coverage"
66     commands:
67       - phpenmod xdebug
68       - cp config/local-sample.config.php config/local.config.php
69       - if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
70       - mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
71       - php ./bin/console.php dbstructure dumpsql > database.sql
72   check_database.sql:
73     image: alpine/git
74     commands:
75       - git update-index --refresh
76       - git diff-index --quiet HEAD --
77       - if [[ $? -ne 0 ]]; then
78           echo "database.sql mismatch.";
79           exit 1;
80         fi
81
82 services:
83   mariadb:
84     image: mariadb:latest
85     environment:
86       MYSQL_ALLOW_EMPTY_PASSWORD: "true"
87       MYSQL_DATABASE: "test"
88       MYSQL_PASSWORD: "test"
89       MYSQL_USER: "test"