]> git.agnieray.net Git - galette.git/blob - .github/workflows/ci-linux.yml
7429e75a86354c20c7578e30a828af5219d2bfcd
[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: [ '8.1', '8.2' ]
20 coverage: ['none']
21 db-image: ['mysql:5.7', 'mysql:8.0', 'mariadb:10.2', 'mariadb:10.6', 'postgres:10', 'postgres:14']
22 include:
23 - php-versions: '8.1'
24 coverage: 'xdebug'
25 db-image: 'postgres:14'
26 fail-fast: false
27
28 env:
29 DB: ${{ matrix.db-image }}
30
31 services:
32 # Label used to access the service container
33 db:
34 # Docker Hub image
35 image: ${{ matrix.db-image }}
36 # Provide env variables for both mysql and pgsql
37 env:
38 POSTGRES_USER: galette_tests
39 POSTGRES_PASSWORD: g@l3tte
40 POSTGRES_DB: galette_tests
41 MYSQL_USER: galette_tests
42 MYSQL_PASSWORD: g@l3tte
43 MYSQL_ROOT_PASSWORD: g@l3tte
44 MYSQL_DATABASE: galette_tests
45 # Open network ports for both mysql and pgsql
46 ports:
47 - 3306:3306
48 - 5432:5432
49 # Set health checks to wait until postgres has started
50 options: >-
51 --health-cmd="bash -c 'if [[ -n $(command -v pg_isready) ]]; then pg_isready; else mysqladmin ping; fi'"
52 --health-interval=10s
53 --health-timeout=5s
54 --health-retries=10
55
56 name: PHP ${{ matrix.php-versions }} ${{ matrix.db-image }}
57
58 steps:
59 - name: PHP
60 uses: shivammathur/setup-php@v2
61 with:
62 php-version: ${{ matrix.php-versions }}
63 tools: composer, pecl
64 coverage: ${{ matrix.coverage }}
65 extensions: apcu
66 ini-values: apc.enable_cli=1
67
68 - name: "Show versions"
69 run: |
70 php --version
71 composer --version
72 echo "node $(node --version)"
73 echo "npm $(npm --version)"
74 docker exec ${{ job.services.db.id }} bash -c "if [[ -n \$(command -v psql) ]]; then psql --version; else mysql --version; fi"
75
76 - name: Checkout
77 uses: actions/checkout@v3
78 with:
79 fetch-depth: 2
80
81 - name: Get composer cache directory
82 id: composer-cache
83 run: |
84 echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
85
86 - name: Cache dependencies
87 uses: actions/cache@v3
88 with:
89 path: ${{ steps.composer-cache.outputs.dir }}
90 key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
91 restore-keys: ${{ runner.os }}-composer-
92
93 - name: Install dependencies
94 run: bin/install_deps
95
96 - name: CS
97 run: |
98 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/
99
100 - name: Twig CS
101 run: |
102 galette/vendor/bin/twigcs galette/templates/default --severity error --display blocking
103 if: matrix.php-versions == '8.1'
104
105 - name: Install checker
106 working-directory: galette
107 run: composer require maglnet/composer-require-checker -W
108 if: matrix.php-versions == '8.1'
109
110 - name: Check missing symbols
111 run: |
112 galette/vendor/bin/composer-require-checker check --config-file=.composer-require-checker.config.json galette/composer.json
113 if: matrix.php-versions == '8.1'
114
115 - name: PHPStan checks
116 run: |
117 galette/vendor/bin/phpstan analyze --ansi --memory-limit=2G --no-interaction --no-progress
118 if: matrix.php-versions == '8.1'
119
120 - name: Init for PostgreSQL (update)
121 env:
122 POSTGRES_HOST: localhost
123 POSTGRES_PORT: 5432
124 run: |
125 PGPASSWORD=g@l3tte psql -d galette_tests -a -f tests/pgsql_06.sql -U galette_tests -h localhost
126 if: startsWith(matrix.db-image, 'postgres')
127
128 - name: Init for MariaDB (update)
129 run: |
130 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
131 mysql -e 'use galette_tests; source tests/mysql_06.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
132 if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
133
134 - name: Update database tests
135 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php --no-cc -d tests/GaletteUpdate/
136 if: matrix.coverage != 'xdebug'
137
138 - name: Init for PostgreSQL
139 env:
140 POSTGRES_HOST: localhost
141 POSTGRES_PORT: 5432
142 run: |
143 PGPASSWORD=g@l3tte psql -d galette_tests -a -f galette/install/scripts/pgsql.sql -U galette_tests -h localhost
144 if: startsWith(matrix.db-image, 'postgres')
145
146 - name: Init for MariaDB
147 run: |
148 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
149 mysql -e 'use galette_tests; source galette/install/scripts/mysql.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
150 if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
151
152 - name: Unit tests
153 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php --no-cc -d tests/Galette/
154 if: matrix.coverage != 'xdebug'
155
156 - name: Unit tests (with coverage)
157 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php -c tests/clover.php -d tests/Galette/
158 if: matrix.coverage == 'xdebug'
159
160 - name: Upload code coverage (scrutinizer)
161 run: |
162 cd galette
163 composer require scrutinizer/ocular
164 cd ..
165 php galette/vendor/bin/ocular code-coverage:upload --format=php-clover tests/clover.xml
166 if: matrix.coverage == 'xdebug'
167
168 - name: Upload code coverage (codecov)
169 uses: codecov/codecov-action@v3
170 with:
171 file: tests/clover.xml
172 if: matrix.coverage == 'xdebug'