Skip to content

Commit

Permalink
Add matrix to the jobs in the workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
christeredvartsen committed Aug 25, 2021
1 parent 1fa98a3 commit 0329483
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 90 deletions.
158 changes: 73 additions & 85 deletions .github/workflows/test.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,20 @@
name: CI build
on: push
jobs:
validate:
runs-on: ubuntu-20.04
name: Validate Composer files and lint code
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: imagick

- uses: actions/checkout@v2

- name: Debug PHP installation
run: |
php -v
php -i
php -m
- name: Validate composer files
run: composer validate --strict

- name: Lint all PHP files
run: composer run lint

- name: Get Composer Cache Directory
id: composer-cache-dir
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist -o

unit-tests:
needs:
- validate
runs-on: ubuntu-20.04
name: Unit tests
services:
mongodb:
image: mongo:4.2.8
ports:
- 27017:27017
strategy:
matrix:
operating-system: ['ubuntu-20.04']
php-versions: ['7.4']

runs-on: ${{ matrix.operating-system }}

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-versions }}
extensions: imagick

- uses: actions/checkout@v2
Expand All @@ -77,27 +34,32 @@ jobs:
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist -o
run: composer install

- name: Run unit tests using PHPUnit
run: composer run test:phpunit
run: vendor/bin/phpunit --verbose

integration-tests-mongodb-gridfs:
needs:
- validate
runs-on: ubuntu-20.04
name: Integration tests (MongoDB / GridFS)
strategy:
matrix:
operating-system: ['ubuntu-20.04']
php-versions: ['7.4']
mongodb-versions: ['5.0.2']

runs-on: ${{ matrix.operating-system }}

services:
mongodb:
image: mongo:4.2.8
image: mongo:${{ matrix.mongodb-versions }}
ports:
- 27017:27017

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-versions }}
extensions: imagick

- uses: actions/checkout@v2
Expand All @@ -117,35 +79,42 @@ jobs:
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist -o
run: composer install

- name: Start PHP web server
run: composer run dev --timeout=0 &
run: |
mkdir -p build/logs
php -S localhost:8080 -t ./public features/bootstrap/router.php > build/logs/httpd.log 2>&1 &
- name: Run integration tests using Behat
run: composer run test:behat:mongodb-gridfs
run: vendor/bin/behat --strict --suite=mongodb-gridfs

- uses: actions/upload-artifact@v2
with:
name: httpd-logs-mongodb-gridfs
path: build/logs

integration-tests-mongodb-filesystem:
needs:
- validate
runs-on: ubuntu-20.04
name: Integration tests (MongoDB / Filesystem)
strategy:
matrix:
operating-system: ['ubuntu-20.04']
php-versions: ['7.4']
mongodb-versions: ['5.0.2']

runs-on: ${{ matrix.operating-system }}

services:
mongodb:
image: mongo:4.2.8
image: mongo:${{ matrix.mongodb-versions }}
ports:
- 27017:27017

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-versions }}
extensions: imagick

- uses: actions/checkout@v2
Expand All @@ -165,35 +134,42 @@ jobs:
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist -o
run: composer install

- name: Start PHP web server
run: composer run dev --timeout=0 &
run: |
mkdir -p build/logs
php -S localhost:8080 -t ./public features/bootstrap/router.php > build/logs/httpd.log 2>&1 &
- name: Run integration tests using Behat
run: composer run test:behat:mongodb-filesystem
run: vendor/bin/behat --strict --suite=mongodb-filesystem

- uses: actions/upload-artifact@v2
with:
name: httpd-logs-mongodb-filesystem
path: build/logs

integration-tests-doctrine-sqlite-filesystem:
needs:
- validate
runs-on: ubuntu-20.04
name: Integration tests (SQLite / Filesystem)
strategy:
matrix:
operating-system: ['ubuntu-20.04']
php-versions: ['7.4']
mongodb-versions: ['5.0.2']

runs-on: ${{ matrix.operating-system }}

services:
mongodb:
image: mongo:4.2.8
image: mongo:${{ matrix.mongodb-versions }}
ports:
- 27017:27017

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-versions }}
extensions: imagick

- uses: actions/checkout@v2
Expand All @@ -213,31 +189,41 @@ jobs:
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist -o
run: composer install

- name: Start PHP web server
run: composer run dev --timeout=0 &
run: |
mkdir -p build/logs
php -S localhost:8080 -t ./public features/bootstrap/router.php > build/logs/httpd.log 2>&1 &
- name: Run integration tests using Behat
run: composer run test:behat:doctrine-sqlite-filesystem
run: vendor/bin/behat --strict --suite=doctrine-sqlite-filesystem

- uses: actions/upload-artifact@v2
with:
name: httpd-logs-doctrine-sqlite-filesystem
path: build/logs

integration-tests-doctrine-mysql-filesystem:
needs:
- validate
runs-on: ubuntu-20.04
name: Integration tests (MySQL / Filesystem)

strategy:
matrix:
operating-system: ['ubuntu-20.04']
php-versions: ['7.4']
mongodb-versions: ['5.0.2']
mysql-versions: ['8.0.20']

runs-on: ${{ matrix.operating-system }}

services:
mongodb:
image: mongo:4.2.8
image: mongo:${{ matrix.mongodb-versions }}
ports:
- 27017:27017

mysql:
image: mysql:8.0.20
image: mysql:${{ matrix.mysql-versions }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: imbo_test
Expand All @@ -251,7 +237,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-versions }}
extensions: imagick

- uses: actions/checkout@v2
Expand All @@ -271,10 +257,12 @@ jobs:
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist -o
run: composer install

- name: Start PHP web server
run: composer run dev --timeout=0 &
run: |
mkdir -p build/logs
php -S localhost:8080 -t ./public features/bootstrap/router.php > build/logs/httpd.log 2>&1 &
- name: Update MySQL configuration for the Behat suite
run: |
Expand All @@ -286,7 +274,7 @@ jobs:
echo "================================="
- name: Run integration tests using Behat
run: composer run test:behat:doctrine-mysql-filesystem
run: vendor/bin/behat --strict --suite=doctrine-mysql-filesystem

- uses: actions/upload-artifact@v2
with:
Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,26 @@
"bin/imbo"
],
"scripts": {
"lint": "for file in `git ls-files '*php'`; do php -l $file; done",
"prepare": [
"clear-build": [
"rm -rf build",
"mkdir build",
"mkdir build/coverage",
"mkdir build/logs",
"mkdir build/docs"
],
"test:phpunit": "vendor/bin/phpunit --colors=always --verbose",
"test:phpunit": "vendor/bin/phpunit --verbose",
"test:phpunit:coverage": [
"rm -rf build/coverage",
"mkdir -p build/coverage",
"vendor/bin/phpunit --colors=always --verbose --coverage-html build/coverage --coverage-text"
"vendor/bin/phpunit --verbose --coverage-html build/coverage --coverage-text"
],
"test:behat": [
"@test:behat:mongodb-gridfs",
"@test:behat:mongodb-filesystem",
"@test:behat:doctrine-sqlite-filesystem",
"@test:behat:doctrine-mysql-filesystem"
],
"test:behat:mongodb-gridfs": "vendor/bin/behat --colors --strict --suite=mongodb-gridfs",
"test:behat:mongodb-gridfs": "vendor/bin/behat --strict --suite=mongodb-gridfs",
"test:behat:mongodb-filesystem": "vendor/bin/behat --strict --suite=mongodb-filesystem",
"test:behat:doctrine-sqlite-filesystem": "vendor/bin/behat --strict --suite=doctrine-sqlite-filesystem",
"test:behat:doctrine-mysql-filesystem": "vendor/bin/behat --strict --suite=doctrine-mysql-filesystem",
Expand Down

0 comments on commit 0329483

Please sign in to comment.