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