2020-12-13 12:44:02 +03:00
|
|
|
name: Continuous integration
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request: null
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- develop
|
2022-01-25 22:39:31 +03:00
|
|
|
- 2.x
|
2020-12-13 12:44:02 +03:00
|
|
|
|
|
|
|
jobs:
|
2020-12-13 14:59:06 +03:00
|
|
|
static-analysis:
|
2022-08-01 18:13:34 +03:00
|
|
|
runs-on: ubuntu-22.04
|
2020-12-13 14:59:06 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-04-23 13:08:01 +03:00
|
|
|
php-version: ['8.1']
|
2021-12-09 20:51:26 +03:00
|
|
|
command: ['cs', 'stan', 'swagger:validate']
|
2020-12-13 14:59:06 +03:00
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Use PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php-version }}
|
|
|
|
tools: composer
|
2022-05-09 09:00:54 +03:00
|
|
|
extensions: openswoole-4.11.1
|
2020-12-13 14:59:06 +03:00
|
|
|
coverage: none
|
2022-08-01 17:56:25 +03:00
|
|
|
- name: Install dependencies
|
|
|
|
run: composer install --no-interaction --prefer-dist
|
2021-12-09 20:51:26 +03:00
|
|
|
- run: composer ${{ matrix.command }}
|
2020-12-13 14:59:06 +03:00
|
|
|
|
2021-12-11 12:25:58 +03:00
|
|
|
tests:
|
2022-08-01 18:13:34 +03:00
|
|
|
runs-on: ubuntu-22.04
|
2020-12-13 12:44:02 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-04-23 13:08:01 +03:00
|
|
|
php-version: ['8.1']
|
2021-12-11 12:25:58 +03:00
|
|
|
test-group: ['unit', 'api']
|
2020-12-13 12:44:02 +03:00
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
2021-12-11 12:25:58 +03:00
|
|
|
- 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
|
2020-12-13 12:44:02 +03:00
|
|
|
- name: Use PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php-version }}
|
|
|
|
tools: composer
|
2022-05-09 09:00:54 +03:00
|
|
|
extensions: openswoole-4.11.1
|
2020-12-13 13:37:45 +03:00
|
|
|
coverage: pcov
|
|
|
|
ini-values: pcov.directory=module
|
2022-08-01 17:56:25 +03:00
|
|
|
- name: Install dependencies
|
|
|
|
run: composer install --no-interaction --prefer-dist
|
2021-12-11 12:25:58 +03:00
|
|
|
- run: composer test:${{ matrix.test-group }}:ci
|
2020-12-13 14:59:06 +03:00
|
|
|
- uses: actions/upload-artifact@v2
|
2022-04-23 13:08:01 +03:00
|
|
|
if: ${{ matrix.php-version == '8.1' }}
|
2020-12-13 14:59:06 +03:00
|
|
|
with:
|
2021-12-11 12:25:58 +03:00
|
|
|
name: coverage-${{ matrix.test-group }}
|
2020-12-13 14:59:06 +03:00
|
|
|
path: |
|
2021-12-11 12:25:58 +03:00
|
|
|
build/coverage-${{ matrix.test-group }}
|
|
|
|
build/coverage-${{ matrix.test-group }}.cov
|
2020-12-13 14:31:34 +03:00
|
|
|
|
2021-12-11 12:25:58 +03:00
|
|
|
db-tests:
|
2022-08-01 18:13:34 +03:00
|
|
|
runs-on: ubuntu-22.04
|
2020-12-13 14:31:34 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-04-23 13:08:01 +03:00
|
|
|
php-version: ['8.1']
|
2021-12-11 12:25:58 +03:00
|
|
|
platform: ['sqlite:ci', 'mysql', 'maria', 'postgres', 'ms']
|
2021-11-04 23:31:51 +03:00
|
|
|
env:
|
|
|
|
LC_ALL: C
|
2020-12-13 14:31:34 +03:00
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Install MSSQL ODBC
|
2021-12-11 12:25:58 +03:00
|
|
|
if: ${{ matrix.platform == 'ms' }}
|
2020-12-13 14:38:12 +03:00
|
|
|
run: sudo ./data/infra/ci/install-ms-odbc.sh
|
2020-12-13 14:59:06 +03:00
|
|
|
- name: Start database server
|
2021-12-11 12:25:58 +03:00
|
|
|
if: ${{ matrix.platform != 'sqlite:ci' }}
|
|
|
|
run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_${{ matrix.platform }}
|
2020-12-13 12:44:02 +03:00
|
|
|
- name: Use PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php-version }}
|
|
|
|
tools: composer
|
2022-08-05 17:31:15 +03:00
|
|
|
extensions: openswoole-4.11.1, pdo_sqlsrv-5.10.1
|
2020-12-13 13:37:45 +03:00
|
|
|
coverage: pcov
|
|
|
|
ini-values: pcov.directory=module
|
2022-08-01 17:56:25 +03:00
|
|
|
- name: Install dependencies
|
|
|
|
run: composer install --no-interaction --prefer-dist
|
2021-12-11 12:25:58 +03:00
|
|
|
- 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' }}
|
2020-12-13 14:59:06 +03:00
|
|
|
with:
|
2021-12-11 12:25:58 +03:00
|
|
|
name: coverage-db
|
2020-12-13 14:59:06 +03:00
|
|
|
path: |
|
2021-12-11 12:25:58 +03:00
|
|
|
build/coverage-db
|
|
|
|
build/coverage-db.cov
|
2020-12-13 15:11:41 +03:00
|
|
|
|
|
|
|
mutation-tests:
|
|
|
|
needs:
|
2021-12-11 12:25:58 +03:00
|
|
|
- tests
|
|
|
|
- db-tests
|
2022-08-01 18:13:34 +03:00
|
|
|
runs-on: ubuntu-22.04
|
2020-12-13 15:11:41 +03:00
|
|
|
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']
|
2020-12-13 15:11:41 +03:00
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Use PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php-version }}
|
|
|
|
tools: composer
|
2022-05-09 09:00:54 +03:00
|
|
|
extensions: openswoole-4.11.1
|
2020-12-13 15:11:41 +03:00
|
|
|
coverage: pcov
|
|
|
|
ini-values: pcov.directory=module
|
2022-08-01 17:56:25 +03:00
|
|
|
- name: Install dependencies
|
|
|
|
run: composer install --no-interaction --prefer-dist
|
2020-12-13 15:11:41 +03:00
|
|
|
- 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 }}
|
2020-12-13 15:34:22 +03:00
|
|
|
|
|
|
|
upload-coverage:
|
2020-12-13 19:17:16 +03:00
|
|
|
needs:
|
2021-12-11 12:25:58 +03:00
|
|
|
- tests
|
|
|
|
- db-tests
|
2022-08-01 18:13:34 +03:00
|
|
|
runs-on: ubuntu-22.04
|
2020-12-13 15:34:22 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-04-23 13:08:01 +03:00
|
|
|
php-version: ['8.1']
|
2020-12-13 15:34:22 +03:00
|
|
|
steps:
|
2020-12-13 19:31:22 +03:00
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
2020-12-13 15:34:22 +03:00
|
|
|
- name: Use PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php-version }}
|
2020-12-13 19:23:58 +03:00
|
|
|
coverage: pcov
|
|
|
|
ini-values: pcov.directory=module
|
2020-12-13 15:34:22 +03:00
|
|
|
- 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
|
2020-12-13 15:34:22 +03:00
|
|
|
|
|
|
|
delete-artifacts:
|
|
|
|
needs:
|
|
|
|
- mutation-tests
|
|
|
|
- upload-coverage
|
2022-08-01 18:13:34 +03:00
|
|
|
runs-on: ubuntu-22.04
|
2020-12-13 15:34:22 +03:00
|
|
|
steps:
|
|
|
|
- uses: geekyeggo/delete-artifact@v1
|
|
|
|
with:
|
|
|
|
name: |
|
|
|
|
coverage-unit
|
|
|
|
coverage-db
|
|
|
|
coverage-api
|
2020-12-13 19:45:48 +03:00
|
|
|
|
|
|
|
build-docker-image:
|
2022-08-01 18:13:34 +03:00
|
|
|
runs-on: ubuntu-22.04
|
2020-12-13 19:45:48 +03:00
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
2021-01-30 11:54:47 +03:00
|
|
|
with:
|
|
|
|
fetch-depth: 100
|
2020-12-13 19:45:48 +03:00
|
|
|
- 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"
|