]> git.agnieray.net Git - galette.git/blob - .github/workflows/ci-linux.yml
a053a667f3681991bf419899f502cbecb35814fb
[galette.git] / .github / workflows / ci-linux.yml
1 name: Galette CI
2
3 on:
4 push:
5 branches:
6 - master
7 - develop
8 - 'feature/*'
9 - 'hotfix/*'
10 - 'release/*'
11 pull_request:
12
13 jobs:
14 ubuntu-latest:
15 runs-on: ubuntu-latest
16
17 strategy:
18 matrix:
19 php-versions: [ '7.3', '7.4', '8.0' ]
20 coverage: ['none']
21 db-image: ['mysql:5.6', 'mariadb:10.1', 'mariadb:10.5', 'postgres:9.5', 'postgres:13']
22 include:
23 - php-versions: '7.4'
24 coverage: 'xdebug'
25 db-image: 'postgres:13'
26 exclude:
27 - php-versions: 7.3
28 db-image: 'mysql:8.0' #due to a mysql config; fixed as of php 7.4
29 fail-fast: false
30
31 env:
32 DB: ${{ matrix.db-image }}
33
34 services:
35 # Label used to access the service container
36 db:
37 # Docker Hub image
38 image: ${{ matrix.db-image }}
39 # Provide env variables for both mysql and pgsql
40 env:
41 POSTGRES_USER: galette_tests
42 POSTGRES_PASSWORD: g@l3tte
43 POSTGRES_DB: galette_tests
44 MYSQL_USER: galette_tests
45 MYSQL_PASSWORD: g@l3tte
46 MYSQL_ROOT_PASSWORD: g@l3tte
47 MYSQL_DATABASE: galette_tests
48 # Open network ports for both mysql and pgsql
49 ports:
50 - 3306:3306
51 - 5432:5432
52 # Set health checks to wait until postgres has started
53 options: >-
54 --health-cmd="bash -c 'if [[ -n $(command -v pg_isready) ]]; then pg_isready; else mysqladmin ping; fi'"
55 --health-interval=10s
56 --health-timeout=5s
57 --health-retries=10
58
59 name: PHP ${{ matrix.php-versions }} ${{ matrix.db-image }}
60
61 steps:
62 - name: PHP
63 uses: shivammathur/setup-php@v2
64 with:
65 php-version: ${{ matrix.php-versions }}
66 tools: composer, pecl
67 coverage: ${{ matrix.coverage }}
68 extensions: apcu
69 ini-values: apc.enable_cli=1
70
71 - name: "Show versions"
72 run: |
73 php --version
74 composer --version
75 echo "node $(node --version)"
76 echo "npm $(npm --version)"
77 docker exec ${{ job.services.db.id }} bash -c "if [[ -n \$(command -v psql) ]]; then psql --version; else mysql --version; fi"
78
79 - name: Checkout
80 uses: actions/checkout@v2
81
82 - name: Get composer cache directory
83 id: composer-cache
84 run: |
85 echo "::set-output name=dir::$(composer config cache-files-dir)"
86
87 - name: Cache dependencies
88 uses: actions/cache@v2
89 with:
90 path: ${{ steps.composer-cache.outputs.dir }}
91 key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
92 restore-keys: ${{ runner.os }}-composer-
93
94 - name: Install dependencies
95 run: bin/install_deps
96
97 - name: CS
98 run: |
99 galette/vendor/bin/phpcs -n -p --ignore=galette_tcpdf_config.php --standard=phpcs-rules.xml galette/lib/ tests/TestsBootstrap.php tests/Galette tests/plugins galette/webroot/index.php galette/includes/fields_defs/ galette/includes/smarty_plugins/ galette/includes/functions.inc.php galette/includes/galette.inc.php galette/includes/dependencies.php galette/includes/main.inc.php
100
101 - name: Install checker
102 working-directory: galette
103 run: composer require maglnet/composer-require-checker
104 if: matrix.php-versions == '7.4'
105
106 - name: Check missing symbols
107 run: |
108 galette/vendor/bin/composer-require-checker check --config-file=.composer-require-checker.config.json galette/composer.json
109 if: matrix.php-versions == '7.4'
110
111 - name: Init for PostgreSQL (update)
112 env:
113 POSTGRES_HOST: localhost
114 POSTGRES_PORT: 5432
115 run: |
116 PGPASSWORD=g@l3tte psql -d galette_tests -a -f tests/pgsql_06.sql -U galette_tests -h localhost
117 if: startsWith(matrix.db-image, 'postgres')
118
119 - name: Init for MariaDB (update)
120 run: |
121 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
122 mysql -e 'use galette_tests; source tests/mysql_06.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
123 if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
124
125 - name: Update database tests
126 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php --no-cc -d tests/GaletteUpdate/
127 if: matrix.coverage != 'xdebug'
128
129 - name: Init for PostgreSQL
130 env:
131 POSTGRES_HOST: localhost
132 POSTGRES_PORT: 5432
133 run: |
134 PGPASSWORD=g@l3tte psql -d galette_tests -a -f galette/install/scripts/pgsql.sql -U galette_tests -h localhost
135 if: startsWith(matrix.db-image, 'postgres')
136
137 - name: Init for MariaDB
138 run: |
139 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
140 mysql -e 'use galette_tests; source galette/install/scripts/mysql.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
141 if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
142
143 - name: Unit tests
144 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php --no-cc -d tests/Galette/
145 if: matrix.coverage != 'xdebug'
146
147 - name: Unit tests (with coverage)
148 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php -c tests/clover.php -d tests/Galette/
149 if: matrix.coverage == 'xdebug'
150
151 - name: Upload code coverage (scrutinizer)
152 run: |
153 wget https://scrutinizer-ci.com/ocular.phar
154 php ocular.phar code-coverage:upload --format=php-clover tests/clover.xml
155 if: matrix.coverage == 'xdebug'
156
157 - name: Upload code coverage (codecov)
158 uses: codecov/codecov-action@v1
159 with:
160 file: tests/clover.xml
161 if: matrix.coverage == 'xdebug'