Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 53 additions & 8 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
9 changes: 7 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./vendor/autoload.php"
colors="true">
colors="true"
executionOrder="random"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true">
<source>
<include>
<directory>src</directory>
Expand Down
Loading