Update po files
[phpmyadmin.git] / .github / workflows / tests.yml
blob8dcb4ec5f9e71b2ae983678a7ec1d9535c553584
1 name: Run tests
3 on:
4   push:
5   pull_request:
6     types: [opened, synchronize, reopened]
7     branches:
8       - master
9       - QA_**
11 permissions:
12   contents: read
14 jobs:
15   multi-arch-tests-php:
16     name: Test on PHP ${{ matrix.php-version }} (${{ matrix.arch }})
17     runs-on: ubuntu-latest
18     continue-on-error: ${{ matrix.experimental }}
19     strategy:
20       fail-fast: false
21       matrix:
22         include:
23           - { php-version: '82', experimental: false, arch: 'amd64', exclude-phpunit-groups: 'extension-iconv' }
24           - { php-version: '82', experimental: false, arch: 'arm64v8', exclude-phpunit-groups: 'extension-iconv' }
25           - { php-version: '82', experimental: false, arch: 'arm32v7', exclude-phpunit-groups: 'extension-iconv,32bit-incompatible' }
26           - { php-version: '82', experimental: false, arch: 'i386', exclude-phpunit-groups: 'extension-iconv,32bit-incompatible' }
27           - { php-version: '82', experimental: true, arch: 'ppc64le', exclude-phpunit-groups: 'extension-iconv' }
28           - { php-version: '82', experimental: false, arch: 's390x', exclude-phpunit-groups: 'extension-iconv,32bit-incompatible' }
29     steps:
30       - name: Checkout code
31         uses: actions/checkout@v4
33       - name: Write script
34         # tcpdf allowed memory exhausted needs the memory_limit workaround
35         # musl-locales and musl-locales-lang are needed to run some locale specific tests
36         # gettext is needed to run generate-mo
37         # git is needed to work around a version detection issue with composer, see: https://github.com/Roave/SecurityAdvisories/issues/76
38         # ctype for psalm
39         run: |
40           printf "set -exu && \
41           export V='%s' && \
42           apk add --update --no-cache \
43           php\$V-cli php\$V-mysqli php\$V-session php\$V-mbstring php\$V-ctype php\$V-sodium \
44           php\$V-iconv php\$V-xml php\$V-tokenizer php\$V-xmlwriter php\$V-simplexml \
45           php\$V-dom php\$V-json php\$V-bz2 php\$V-curl php\$V-gd php\$V-zip php\$V-bcmath \
46           musl-locales musl-locales-lang \
47           gettext composer git && \
48           composer config version "$(php -r "define('VERSION_SUFFIX', ''); require_once('src/Version.php'); echo \PhpMyAdmin\Version::VERSION;")" && \
49           composer install && \
50           ./bin/generate-mo && \
51           php\$V -d memory_limit=512M ./vendor/bin/phpunit --no-logging --no-coverage --testsuite unit --exclude-group=%s" \
52           "${{ matrix.php-version }}" "${{ matrix.exclude-phpunit-groups }}" > ./do-tests.sh
54       - name: Set up multi arch support
55         run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
57       - name: Print arch
58         run: docker run --rm ${{ matrix.arch }}/alpine:3.19 uname -a
60       - name: Run tests on php ${{ matrix.php-version }}
61         run: docker run -v $PWD:/app --workdir /app --rm ${{ matrix.arch }}/alpine:3.19 sh /app/do-tests.sh
63   test-php:
64     name: Test on PHP ${{ matrix.php-version }}, ${{ matrix.composer-dependency }} and ${{ matrix.os }}
65     runs-on: ${{ matrix.os }}
66     continue-on-error: ${{ matrix.php-version == '8.4' }}
67     strategy:
68       matrix:
69         php-version: ['8.2', '8.3']
70         os: [ubuntu-latest]
71         composer-dependency: [locked, highest]
72         php-extensions: ['mbstring, iconv, mysqli, zip, gd, bz2']
73         include:
74           - php-version: '8.4'
75             os: ubuntu-latest
76             composer-dependency: locked
77             composer-options: '--ignore-platform-req=php+'
78             php-extensions: 'mbstring, iconv, mysqli, zip, bz2'
79     steps:
80       - name: Checkout code
81         uses: actions/checkout@v4
82         with:
83           # Fetch some commits for Scrutinizer coverage upload
84           fetch-depth: 15
86       - name: Install gettext
87         run: sudo apt-get install -y gettext
89       - name: Generate mo files
90         run: ./bin/generate-mo --quiet
92       - name: Set up PHP ${{ matrix.php-version }}
93         uses: shivammathur/setup-php@v2
94         with:
95           php-version: ${{ matrix.php-version }}
96           extensions: ${{ matrix.php-extensions }}
97           coverage: xdebug
99       - name: Install Composer dependencies
100         uses: ramsey/composer-install@v3
101         with:
102           dependency-versions: ${{ matrix.composer-dependency }}
103           composer-options: ${{ matrix.composer-options }}
105       - name: Run PHP tests
106         run: composer run phpunit -- --testsuite unit --display-deprecations --display-notices --display-warnings --display-errors
108       - name: Send coverage
109         uses: codecov/codecov-action@v3
110         with:
111           flags: unit-${{ matrix.php-version }}-${{ matrix.os }}
112           name: phpunit-${{ matrix.php-version }}-${{ matrix.os }}
114       - name: Send coverage to Scrutinizer
115         uses: sudo-bot/action-scrutinizer@latest
116         # Do not run this step on forked versions of the main repository (example: contributor forks)
117         if: github.repository == 'phpmyadmin/phpmyadmin'
118         with:
119           cli-args: "--format=php-clover build/logs/clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}"
121       - name: Send coverage to Codacy
122         uses: codacy/codacy-coverage-reporter-action@v1
123         # Do not run this step on forked versions of the main repository (example: contributor forks)
124         if: github.repository == 'phpmyadmin/phpmyadmin'
125         # Upload can fail on forks or if the secret is missing
126         continue-on-error: true
127         with:
128           project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
129           coverage-reports: build/logs/clover.xml
131   test-php-optional-extensions:
132     name: Test on PHP (+ ext-${{ matrix.extension }}) ${{ matrix.php-version }} and ${{ matrix.os }}
133     runs-on: ${{ matrix.os }}
134     strategy:
135       matrix:
136         php-version: ["8.2"]
137         os: [ubuntu-latest]
138         extension: ["dbase"]
139     steps:
140       - name: Checkout code
141         uses: actions/checkout@v4
142         with:
143           # Fetch some commits for Scrutinizer coverage upload
144           fetch-depth: 15
146       - name: Install gettext
147         run: sudo apt-get install -y gettext
149       - name: Generate mo files
150         run: ./bin/generate-mo --quiet
152       - name: Set up PHP ${{ matrix.php-version }}
153         uses: shivammathur/setup-php@v2
154         with:
155           php-version: ${{ matrix.php-version }}
156           extensions: ${{ matrix.extension }}, mbstring, iconv, mysqli, zip, gd
157           coverage: xdebug
159       - name: Install Composer dependencies
160         uses: ramsey/composer-install@v3
162       - name: Run PHP tests
163         run: composer run phpunit -- --testsuite unit
165       - name: Send coverage
166         uses: codecov/codecov-action@v3
167         with:
168           flags: ${{ matrix.extension }}-extension
169           name: php-${{ matrix.php-version }}-${{ matrix.extension }}-enabled
171       - name: Send coverage to Scrutinizer
172         uses: sudo-bot/action-scrutinizer@latest
173         # Do not run this step on forked versions of the main repository (example: contributor forks)
174         if: github.repository == 'phpmyadmin/phpmyadmin'
175         with:
176           cli-args: "--format=php-clover build/logs/clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}"
178       - name: Send coverage to Codacy
179         uses: codacy/codacy-coverage-reporter-action@v1
180         # Do not run this step on forked versions of the main repository (example: contributor forks)
181         if: github.repository == 'phpmyadmin/phpmyadmin'
182         # Upload can fail on forks or if the secret is missing
183         continue-on-error: true
184         with:
185           project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
186           coverage-reports: build/logs/clover.xml