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