diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index b0600e5..cf91a9b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,39 +8,84 @@ on: - master jobs: - tests: + unit-tests: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: php-version: [ '8.3', '8.4', '8.5' ] - name: Run tests on PHP v${{ matrix.php-version }} + name: Run unit tests on PHP v${{ matrix.php-version }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} + extensions: curl, json, mbstring + coverage: none + tools: composer:v2 - name: Set composer cache directory id: composer-cache run: echo "COMPOSER_CACHE_DIRECTORY=$(composer config cache-files-dir)" >> $GITHUB_ENV - name: Restore composer from cache - uses: actions/cache@v3 + uses: actions/cache@v6 with: path: ${{ env.COMPOSER_CACHE_DIRECTORY }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-${{ matrix.php-version }}- + ${{ runner.os }}-composer- - name: Install composer dependencies run: composer install --no-interaction --prefer-dist --no-progress - - name: Run phpunit tests - run: vendor/bin/phpunit --colors=always --testdox + - name: Run phpunit unit tests + run: vendor/bin/phpunit --testsuite=unit --colors=always --testdox + + # integration tests send requests to the live CurseForge API and need the CURSEFORGE_API_KEY secret, + # so they only run on the master branch and when started manually + integration-tests: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + + name: Run integration tests + + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.5' + extensions: curl, json, mbstring + coverage: none + tools: composer:v2 + + - name: Set composer cache directory + id: composer-cache + run: echo "COMPOSER_CACHE_DIRECTORY=$(composer config cache-files-dir)" >> $GITHUB_ENV + + - name: Restore composer from cache + uses: actions/cache@v6 + with: + path: ${{ env.COMPOSER_CACHE_DIRECTORY }} + key: ${{ runner.os }}-composer-8.5-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-8.5- + ${{ runner.os }}-composer- + + - name: Install composer dependencies + run: composer install --no-interaction --prefer-dist --no-progress + + - name: Run phpunit integration tests + run: vendor/bin/phpunit --testsuite=integration --colors=always --testdox env: CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index dd1d6d0..0dcdabb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,8 +1,13 @@ + colors="true" + executionOrder="random" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerErrors="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true"> src