|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + phpUnitTests: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + name: Unit Tests / PHP ${{ matrix.phpVersion }} / Winter ${{ matrix.winterRelease }} |
| 13 | + strategy: |
| 14 | + max-parallel: 6 |
| 15 | + matrix: |
| 16 | + phpVersion: ['8.0', '8.1'] |
| 17 | + winterRelease: ['develop'] |
| 18 | + winterReleaseDir: ['develop'] |
| 19 | + include: |
| 20 | + - phpVersion: '7.4' |
| 21 | + winterRelease: 'v1.1.9' |
| 22 | + winterReleaseDir: '1.1.9' |
| 23 | + fail-fast: false |
| 24 | + env: |
| 25 | + phpExtensions: mbstring, intl, gd, xml, sqlite |
| 26 | + cacheKey: ext-cache-v1 |
| 27 | + winterCmsRelease: develop |
| 28 | + steps: |
| 29 | + - name: Checkout changes |
| 30 | + uses: actions/checkout@v2 |
| 31 | + with: |
| 32 | + path: pages-plugin |
| 33 | + |
| 34 | + - name: Setup cache environment |
| 35 | + id: extcache |
| 36 | + uses: shivammathur/cache-extensions@v1 |
| 37 | + with: |
| 38 | + php-version: ${{ matrix.phpVersion }} |
| 39 | + extensions: ${{ env.phpExtensions }} |
| 40 | + key: ${{ env.cacheKey }} |
| 41 | + |
| 42 | + - name: Cache extensions |
| 43 | + uses: actions/cache@v2 |
| 44 | + with: |
| 45 | + path: ${{ steps.extcache.outputs.dir }} |
| 46 | + key: ${{ steps.extcache.outputs.key }} |
| 47 | + restore-keys: ${{ steps.extcache.outputs.key }} |
| 48 | + |
| 49 | + - name: Install PHP and extensions |
| 50 | + uses: shivammathur/setup-php@v2 |
| 51 | + with: |
| 52 | + php-version: ${{ matrix.phpVersion }} |
| 53 | + extensions: ${{ env.phpExtensions }} |
| 54 | + |
| 55 | + - name: Install Winter CMS |
| 56 | + run: | |
| 57 | + wget https://github.com/wintercms/winter/archive/${{ matrix.winterRelease }}.zip |
| 58 | + unzip ${{ matrix.winterRelease }}.zip |
| 59 | + rm ${{ matrix.winterRelease }}.zip |
| 60 | + shopt -s dotglob |
| 61 | + mv winter-${{ matrix.winterReleaseDir }}/* ./ |
| 62 | + rmdir winter-${{ matrix.winterReleaseDir }} |
| 63 | + shopt -u dotglob |
| 64 | + cp config/cms.php config/testing/cms.php |
| 65 | + mkdir -p plugins/winter |
| 66 | + mv pages-plugin plugins/winter/pages |
| 67 | +
|
| 68 | + - name: Get Composer cache directory |
| 69 | + id: composercache |
| 70 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 71 | + |
| 72 | + - name: Cache dependencies |
| 73 | + uses: actions/cache@v2 |
| 74 | + with: |
| 75 | + path: ${{ steps.composercache.outputs.dir }} |
| 76 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 77 | + restore-keys: ${{ runner.os }}-composer- |
| 78 | + |
| 79 | + - name: Install Composer dependencies |
| 80 | + run: composer install --no-interaction --no-progress --no-suggest |
| 81 | + |
| 82 | + - name: Run linting |
| 83 | + run: ./vendor/bin/parallel-lint plugins/winter/pages |
| 84 | + |
| 85 | + - name: Run unit tests (1.2/develop) |
| 86 | + if: matrix.winterRelease != 'v1.1.9' |
| 87 | + run: php artisan winter:test -p Winter.Pages |
| 88 | + |
| 89 | + - name: Run unit tests (1.1) |
| 90 | + if: matrix.winterRelease == 'v1.1.9' |
| 91 | + working-directory: plugins/winter/pages |
| 92 | + run: ../../../vendor/bin/phpunit --bootstrap ../../../tests/bootstrap.php |
0 commit comments