]> BookStack Code Mirror - bookstack/blob - .github/workflows/phpunit.yml
c4be516f34dfd3451e08c9b2dd2d8749d14d48a1
[bookstack] / .github / workflows / phpunit.yml
1 name: phpunit
2
3 on:
4   push:
5     branches-ignore:
6       - l10n_master
7   pull_request:
8     branches-ignore:
9       - l10n_master
10
11 jobs:
12   build:
13     runs-on: ubuntu-20.04
14     strategy:
15       matrix:
16         php: ['7.3', '7.4', '8.0', '8.1']
17     steps:
18     - uses: actions/checkout@v1
19
20     - name: Setup PHP
21       uses: shivammathur/setup-php@v2
22       with:
23         php-version: ${{ matrix.php }}
24         extensions: gd, mbstring, json, curl, xml, mysql, ldap
25
26     - name: Get Composer Cache Directory
27       id: composer-cache
28       run: |
29         echo "::set-output name=dir::$(composer config cache-files-dir)"
30
31     - name: Cache composer packages
32       uses: actions/cache@v1
33       with:
34         path: ${{ steps.composer-cache.outputs.dir }}
35         key: ${{ runner.os }}-composer-${{ matrix.php }}
36
37     - name: Start Database
38       run: |
39         sudo systemctl start mysql
40
41     - name: Setup Database
42       run: |
43         mysql -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS `bookstack-test`;'
44         mysql -uroot -proot -e "CREATE USER 'bookstack-test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'bookstack-test';"
45         mysql -uroot -proot -e "GRANT ALL ON \`bookstack-test\`.* TO 'bookstack-test'@'localhost';"
46         mysql -uroot -proot -e 'FLUSH PRIVILEGES;'
47
48     - name: Install composer dependencies
49       run: composer install --prefer-dist --no-interaction --ansi
50
51     - name: Migrate and seed the database
52       run: |
53         php${{ matrix.php }} artisan migrate --force -n --database=mysql_testing
54         php${{ matrix.php }} artisan db:seed --force -n --class=DummyContentSeeder --database=mysql_testing
55
56     - name: phpunit
57       run: php${{ matrix.php }} ./vendor/bin/phpunit