Extracted definition of unit tests job to local reusable workflow

This commit is contained in:
Alejandro Celaya 2022-08-12 08:35:10 +02:00
parent 4bd3fa74d1
commit e3b6c061c4
2 changed files with 63 additions and 35 deletions

View file

@ -29,39 +29,20 @@ jobs:
run: composer install --no-interaction --prefer-dist
- run: composer ${{ matrix.command }}
tests:
runs-on: ubuntu-22.04
strategy:
matrix:
php-version: ['8.1']
test-group: ['unit', 'api', 'cli']
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Start postgres database server
if: ${{ matrix.test-group == 'api' }}
run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_postgres
- name: Start maria database server
if: ${{ matrix.test-group == 'cli' }}
run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_maria
- name: Use PHP
uses: shivammathur/setup-php@v2
unit-tests:
uses: './.github/workflows/ci/tests.yml'
with:
php-version: ${{ matrix.php-version }}
tools: composer
extensions: openswoole-4.11.1
coverage: pcov
ini-values: pcov.directory=module
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- run: composer test:${{ matrix.test-group }}:ci
- uses: actions/upload-artifact@v2
if: ${{ matrix.php-version == '8.1' }}
test-group: unit
api-tests:
uses: './.github/workflows/ci/tests.yml'
with:
name: coverage-${{ matrix.test-group }}
path: |
build/coverage-${{ matrix.test-group }}
build/coverage-${{ matrix.test-group }}.cov
test-group: api
cli-tests:
uses: './.github/workflows/ci/tests.yml'
with:
test-group: cli
db-tests:
runs-on: ubuntu-22.04
@ -106,7 +87,9 @@ jobs:
mutation-tests:
needs:
- tests
- unit-tests
- api-tests
- cli-tests
- db-tests
runs-on: ubuntu-22.04
strategy:
@ -138,7 +121,9 @@ jobs:
upload-coverage:
needs:
- tests
- unit-tests
- api-tests
- cli-tests
- db-tests
runs-on: ubuntu-22.04
strategy:

43
.github/workflows/ci/tests.yml vendored Normal file
View file

@ -0,0 +1,43 @@
name: Tests
on:
workflow_call:
inputs:
test-group:
type: string
required: true
description: One of unit, api or cli
jobs:
tests:
runs-on: ubuntu-22.04
strategy:
matrix:
php-version: ['8.1']
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Start postgres database server
if: ${{ inputs.test-group == 'api' }}
run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_postgres
- name: Start maria database server
if: ${{ inputs.test-group == 'cli' }}
run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_maria
- name: Use PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer
extensions: openswoole-4.11.1
coverage: pcov
ini-values: pcov.directory=module
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- run: composer test:${{ inputs.test-group }}:ci
- uses: actions/upload-artifact@v2
if: ${{ matrix.php-version == '8.1' }}
with:
name: coverage-${{ inputs.test-group }}
path: |
build/coverage-${{ inputs.test-group }}
build/coverage-${{ inputs.test-group }}.cov