shlink/.github/workflows/ci.yml

194 lines
5.9 KiB
YAML
Raw Normal View History

name: Continuous integration
on:
pull_request: null
push:
branches:
- main
- develop
2022-01-25 22:39:31 +03:00
- 2.x
jobs:
static-analysis:
2022-08-01 18:13:34 +03:00
runs-on: ubuntu-22.04
strategy:
matrix:
2022-04-23 13:08:01 +03:00
php-version: ['8.1']
command: ['cs', 'stan', 'swagger:validate']
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer
extensions: openswoole-4.11.1
coverage: none
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- run: composer ${{ matrix.command }}
tests:
2022-08-01 18:13:34 +03:00
runs-on: ubuntu-22.04
strategy:
matrix:
2022-04-23 13:08:01 +03:00
php-version: ['8.1']
test-group: ['unit', 'api']
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Start 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: 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:${{ matrix.test-group }}:ci
- uses: actions/upload-artifact@v2
2022-04-23 13:08:01 +03:00
if: ${{ matrix.php-version == '8.1' }}
with:
name: coverage-${{ matrix.test-group }}
path: |
build/coverage-${{ matrix.test-group }}
build/coverage-${{ matrix.test-group }}.cov
db-tests:
2022-08-01 18:13:34 +03:00
runs-on: ubuntu-22.04
strategy:
matrix:
2022-04-23 13:08:01 +03:00
php-version: ['8.1']
platform: ['sqlite:ci', 'mysql', 'maria', 'postgres', 'ms']
env:
LC_ALL: C
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install MSSQL ODBC
if: ${{ matrix.platform == 'ms' }}
run: sudo ./data/infra/ci/install-ms-odbc.sh
- name: Start database server
if: ${{ matrix.platform != 'sqlite:ci' }}
run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_${{ matrix.platform }}
- name: Use PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer
extensions: openswoole-4.11.1, pdo_sqlsrv-5.10.1
coverage: pcov
ini-values: pcov.directory=module
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- name: Create test database
if: ${{ matrix.platform == 'ms' }}
run: docker-compose exec -T shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;"
- name: Run tests
run: composer test:db:${{ matrix.platform }}
- name: Upload code coverage
uses: actions/upload-artifact@v2
2022-04-23 13:08:01 +03:00
if: ${{ matrix.php-version == '8.1' && matrix.platform == 'sqlite:ci' }}
with:
name: coverage-db
path: |
build/coverage-db
build/coverage-db.cov
mutation-tests:
needs:
- tests
- db-tests
2022-08-01 18:13:34 +03:00
runs-on: ubuntu-22.04
strategy:
matrix:
2022-04-23 13:08:01 +03:00
php-version: ['8.1']
2021-12-10 19:45:50 +03:00
test-group: ['unit', 'db', 'api']
steps:
- name: Checkout code
uses: actions/checkout@v2
- 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
- uses: actions/download-artifact@v2
with:
path: build
2021-12-05 10:55:05 +03:00
- if: ${{ matrix.test-group == 'unit' }}
run: composer infect:ci:unit
env:
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
2021-12-10 19:45:50 +03:00
- if: ${{ matrix.test-group != 'unit' }}
run: composer infect:ci:${{ matrix.test-group }}
upload-coverage:
needs:
- tests
- db-tests
2022-08-01 18:13:34 +03:00
runs-on: ubuntu-22.04
strategy:
matrix:
2022-04-23 13:08:01 +03:00
php-version: ['8.1']
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
ini-values: pcov.directory=module
- uses: actions/download-artifact@v2
with:
path: build
- run: mv build/coverage-unit/coverage-unit.cov build/coverage-unit.cov
- run: mv build/coverage-db/coverage-db.cov build/coverage-db.cov
- run: mv build/coverage-api/coverage-api.cov build/coverage-api.cov
2022-04-23 20:11:23 +03:00
- run: wget https://phar.phpunit.de/phpcov-8.2.1.phar
- run: php phpcov-8.2.1.phar merge build --clover build/clover.xml
2020-12-19 12:25:19 +03:00
- name: Publish coverage
uses: codecov/codecov-action@v1
with:
file: ./build/clover.xml
delete-artifacts:
needs:
- mutation-tests
- upload-coverage
2022-08-01 18:13:34 +03:00
runs-on: ubuntu-22.04
steps:
- uses: geekyeggo/delete-artifact@v1
with:
name: |
coverage-unit
coverage-db
coverage-api
build-docker-image:
2022-08-01 18:13:34 +03:00
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 100
- uses: marceloprado/has-changed-path@v1
id: changed-dockerfile
with:
paths: ./Dockerfile
- if: ${{ steps.changed-dockerfile.outputs.changed == 'true' }}
run: docker build -t shlink-docker-image:temp .
- if: ${{ steps.changed-dockerfile.outputs.changed != 'true' }}
run: echo "Dockerfile didn't change. Skipped"