diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..aa3302dd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: PHP Composer + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + # Based on https://github.com/nanasess/setup-php + tests: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ ubuntu-latest, windows-latest ] + php: [ '7.3', '7.4', '8.0' ] + name: PHP ${{ matrix.php }} tests (${{ matrix.operating-system }}) + steps: + - uses: actions/checkout@v2 + - name: Setup PHP + uses: nanasess/setup-php@master + with: + php-version: ${{ matrix.php }} + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Run tests + run: composer run-script tests diff --git a/composer.json b/composer.json index d21d5bb0..63623155 100644 --- a/composer.json +++ b/composer.json @@ -35,5 +35,8 @@ "platform": { "php": "7.3.0" } + }, + "scripts": { + "tests": "php vendor/bin/phpunit" } }