diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e21eeae..82759c7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,56 +1,69 @@ name: Tests +permissions: + contents: read + on: ['push', 'pull_request'] jobs: test: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.operating-system }} strategy: fail-fast: true matrix: - os: [ubuntu-latest, macos-latest] - php: [8.1, 8.2] + operating-system: [ubuntu-latest] + php-version: [8.1, 8.2] dependency-version: [prefer-lowest, prefer-stable] - - name: Test PHP-${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} + name: ๐Ÿ‘ท CI PHP-${{ matrix.php-version }} ${{ matrix.dependency-version }} on ${{ matrix.operating-system }} steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Cache dependencies + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.operating-system }}-dependencies-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }} + restore-keys: | + ${{ runner.operating-system }}-dependencies-php-${{ matrix.php-version }}-composer- + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: curl, dom, gd, intl, mbstring, openssl, tokenizer, zip + ini-values: error_reporting=E_ALL + tools: composer:v2, php-cs-fixer, phpunit, vimeo/psalm + coverage: pcov + + - name: Install dependencies + run: | + set -e + composer install -q --no-ansi --no-cache --no-interaction --no-scripts --no-progress --prefer-dist + composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist --no-progress + + - name: Update dependencies with latest stable + if: matrix.dependency-version == 'prefer-stable' + run: composer update --prefer-stable + + - name: Update dependencies with lowest stable + if: matrix.dependency-version == 'prefer-lowest' + run: composer update --prefer-stable --prefer-lowest + + - name: ๐Ÿงน Check code lint + run: composer check + + - name: โš—๏ธ Run static analysis + run: | + composer analyse + composer inspect + + - name: โœ… Test features + run: composer test - - name: Checkout - uses: actions/checkout@v3 - - - name: Cache dependencies - id: composer-cache - run: | - echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, mbstring, zip - coverage: none - tools: vimeo/psalm - - - name: Install Composer dependencies - run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist - - - name: ๐Ÿงน Check code lint - run: composer check - - - name: โš—๏ธ Run static analysis - run: | - composer analyse - composer inspect - - - name: โœ… Run unit tests - run: composer test - - - name: ๐Ÿ› Check all code bugs - run: composer debug + - name: ๐Ÿงช Test the whole application + run: composer debug