From 77deb9c1114de83b2b487de964e955a7ff453a7d Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 10:44:02 +0100 Subject: [PATCH 01/13] Created first version of the ci workflow --- .github/workflows/ci.yml | 118 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..d6baae37 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,118 @@ +name: Continuous integration + +on: + pull_request: null + push: + branches: + - main + - develop + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Use PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + tools: composer + extensions: swoole-4.5.9 + - run: composer install --no-interaction --prefer-dist + - run: composer cs + + unit-tests: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: + - 7.4 + - 8.0 + 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: swoole-4.5.9 + - if: ${{ matrix.php-version == '8.0' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.0' }} + run: composer install --no-interaction --prefer-dist + - run: composer test:unit:ci + # TODO Upload code coverage + + db-tests-sqlite: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: + - 7.4 + - 8.0 + 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: swoole-4.5.9 + - if: ${{ matrix.php-version == '8.0' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.0' }} + run: composer install --no-interaction --prefer-dist + - run: composer test:db:sqlite:ci + # TODO Upload code coverage + + db-tests-mysql: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: + - 7.4 + - 8.0 + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Start database + run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db + - name: Use PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer + extensions: swoole-4.5.9 + - if: ${{ matrix.php-version == '8.0' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.0' }} + run: composer install --no-interaction --prefer-dist + - run: composer test:db:mysql + + api-tests: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: + - 7.4 + - 8.0 + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Start database + run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db + - name: Use PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer + extensions: swoole-4.5.9 + - if: ${{ matrix.php-version == '8.0' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.0' }} + run: composer install --no-interaction --prefer-dist + - run: bin/test/run-api-tests.sh + # TODO Upload code coverage From 5040f5b1773e6a97509b0a5d79a8fe5e005de63a Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 11:07:37 +0100 Subject: [PATCH 02/13] Changed condition to determine if tests are run in CI --- config/test/test_config.global.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/test/test_config.global.php b/config/test/test_config.global.php index 6b3c6612..3608257e 100644 --- a/config/test/test_config.global.php +++ b/config/test/test_config.global.php @@ -36,7 +36,7 @@ if ($isApiTest) { $buildDbConnection = function (): array { $driver = env('DB_DRIVER', 'sqlite'); - $isCi = env('TRAVIS', false); + $isCi = env('CI', false); $getMysqlHost = fn (string $driver) => sprintf('shlink_db%s', $driver === 'mysql' ? '' : '_maria'); $getCiMysqlPort = fn (string $driver) => $driver === 'mysql' ? '3307' : '3308'; From 0e58d1a242a21babb15d3658aaa10d003d112dd1 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 11:37:45 +0100 Subject: [PATCH 03/13] Added pcov as code coverage driver in github action --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6baae37..4ad1809e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,8 @@ jobs: php-version: ${{ matrix.php-version }} tools: composer extensions: swoole-4.5.9 + coverage: pcov + ini-values: pcov.directory=module - if: ${{ matrix.php-version == '8.0' }} run: composer install --no-interaction --prefer-dist --ignore-platform-req=php - if: ${{ matrix.php-version != '8.0' }} @@ -61,6 +63,8 @@ jobs: php-version: ${{ matrix.php-version }} tools: composer extensions: swoole-4.5.9 + coverage: pcov + ini-values: pcov.directory=module - if: ${{ matrix.php-version == '8.0' }} run: composer install --no-interaction --prefer-dist --ignore-platform-req=php - if: ${{ matrix.php-version != '8.0' }} @@ -110,6 +114,8 @@ jobs: php-version: ${{ matrix.php-version }} tools: composer extensions: swoole-4.5.9 + coverage: pcov + ini-values: pcov.directory=module - if: ${{ matrix.php-version == '8.0' }} run: composer install --no-interaction --prefer-dist --ignore-platform-req=php - if: ${{ matrix.php-version != '8.0' }} From ac85b913c20026ae06c04c89dc523329ce158e74 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 12:31:34 +0100 Subject: [PATCH 04/13] Added other database test envs to ci workflow --- .github/workflows/ci.yml | 104 ++++++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ad1809e..df73356b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,25 +10,28 @@ on: jobs: lint: runs-on: ubuntu-latest + strategy: + matrix: + php-version: ['7.4'] steps: - name: Checkout code uses: actions/checkout@v2 - name: Use PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: ${{ matrix.php-version }} tools: composer extensions: swoole-4.5.9 + coverage: none - run: composer install --no-interaction --prefer-dist - run: composer cs unit-tests: runs-on: ubuntu-latest + continue-on-error: ${{ matrix.php-version == '8.0' }} strategy: matrix: - php-version: - - 7.4 - - 8.0 + php-version: ['7.4', '8.0'] steps: - name: Checkout code uses: actions/checkout@v2 @@ -45,15 +48,13 @@ jobs: - if: ${{ matrix.php-version != '8.0' }} run: composer install --no-interaction --prefer-dist - run: composer test:unit:ci - # TODO Upload code coverage + # TODO Upload code coverage on one PHP version only db-tests-sqlite: runs-on: ubuntu-latest strategy: matrix: - php-version: - - 7.4 - - 8.0 + php-version: ['7.4', '8.0'] steps: - name: Checkout code uses: actions/checkout@v2 @@ -70,15 +71,13 @@ jobs: - if: ${{ matrix.php-version != '8.0' }} run: composer install --no-interaction --prefer-dist - run: composer test:db:sqlite:ci - # TODO Upload code coverage + # TODO Upload code coverage on one PHP version only db-tests-mysql: runs-on: ubuntu-latest strategy: matrix: - php-version: - - 7.4 - - 8.0 + php-version: ['7.4', '8.0'] steps: - name: Checkout code uses: actions/checkout@v2 @@ -90,19 +89,90 @@ jobs: php-version: ${{ matrix.php-version }} tools: composer extensions: swoole-4.5.9 + coverage: none - if: ${{ matrix.php-version == '8.0' }} run: composer install --no-interaction --prefer-dist --ignore-platform-req=php - if: ${{ matrix.php-version != '8.0' }} run: composer install --no-interaction --prefer-dist - run: composer test:db:mysql - api-tests: + db-tests-maria: runs-on: ubuntu-latest strategy: matrix: - php-version: - - 7.4 - - 8.0 + php-version: ['7.4', '8.0'] + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Start database + 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: swoole-4.5.9 + coverage: none + - if: ${{ matrix.php-version == '8.0' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.0' }} + run: composer install --no-interaction --prefer-dist + - run: composer test:db:maria + + db-tests-postgres: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: ['7.4', '8.0'] + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Start database + 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: swoole-4.5.9 + coverage: none + - if: ${{ matrix.php-version == '8.0' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.0' }} + run: composer install --no-interaction --prefer-dist + - run: composer test:db:postgres + + db-tests-ms: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: ['7.4', '8.0'] + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Install MSSQL ODBC + run: ./data/infra/ci/install-ms-odbc.sh + - name: Start database + run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms + - name: Use PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer + extensions: swoole-4.5.9, pdo_sqlsrv-5.9.0beta2 + coverage: none + - if: ${{ matrix.php-version == '8.0' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.0' }} + run: composer install --no-interaction --prefer-dist + - run: composer test:db:ms + + api-tests: + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.php-version == '8.0' }} + strategy: + matrix: + php-version: ['7.4', '8.0'] steps: - name: Checkout code uses: actions/checkout@v2 @@ -121,4 +191,4 @@ jobs: - if: ${{ matrix.php-version != '8.0' }} run: composer install --no-interaction --prefer-dist - run: bin/test/run-api-tests.sh - # TODO Upload code coverage + # TODO Upload code coverage on one PHP version only From 7fe7354a27bf8628ec1cd37f6550ba2f82a039c6 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 12:38:12 +0100 Subject: [PATCH 05/13] Ensured mssql odbc installation is done as super user --- .github/workflows/ci.yml | 2 +- data/infra/ci/install-ms-odbc.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df73356b..56d3ac11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -151,7 +151,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Install MSSQL ODBC - run: ./data/infra/ci/install-ms-odbc.sh + run: sudo ./data/infra/ci/install-ms-odbc.sh - name: Start database run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms - name: Use PHP diff --git a/data/infra/ci/install-ms-odbc.sh b/data/infra/ci/install-ms-odbc.sh index 8cd60580..1efdf8a3 100755 --- a/data/infra/ci/install-ms-odbc.sh +++ b/data/infra/ci/install-ms-odbc.sh @@ -3,7 +3,7 @@ set -ex curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - -curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list +curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update ACCEPT_EULA=Y apt-get install msodbcsql17 apt-get install unixodbc-dev From 5dc2c1640acdf1ceeca1887b56050a8ee80e6c38 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 12:40:38 +0100 Subject: [PATCH 06/13] Added command to create mssql database for tests --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56d3ac11..16c99d75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -165,6 +165,7 @@ jobs: run: composer install --no-interaction --prefer-dist --ignore-platform-req=php - if: ${{ matrix.php-version != '8.0' }} run: composer install --no-interaction --prefer-dist + - run: docker-compose exec -T shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;" - run: composer test:db:ms api-tests: From ac5a22a3d0404e9183b40c62864dd5df86360107 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 12:59:06 +0100 Subject: [PATCH 07/13] Added static analysis and generation of code coverage artifacts --- .github/workflows/ci.yml | 52 +++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16c99d75..d96e5ce5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,24 @@ jobs: - run: composer install --no-interaction --prefer-dist - run: composer cs + static-analysis: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: ['7.4'] + 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: swoole-4.5.9 + coverage: none + - run: composer install --no-interaction --prefer-dist + - run: composer stan + unit-tests: runs-on: ubuntu-latest continue-on-error: ${{ matrix.php-version == '8.0' }} @@ -48,7 +66,12 @@ jobs: - if: ${{ matrix.php-version != '8.0' }} run: composer install --no-interaction --prefer-dist - run: composer test:unit:ci - # TODO Upload code coverage on one PHP version only + - uses: actions/upload-artifact@v2 + with: + name: coverage-unit + path: | + build/coverage-unit + build/coverage-unit.cov db-tests-sqlite: runs-on: ubuntu-latest @@ -71,7 +94,12 @@ jobs: - if: ${{ matrix.php-version != '8.0' }} run: composer install --no-interaction --prefer-dist - run: composer test:db:sqlite:ci - # TODO Upload code coverage on one PHP version only + - uses: actions/upload-artifact@v2 + with: + name: coverage-db + path: | + build/coverage-db + build/coverage-db.cov db-tests-mysql: runs-on: ubuntu-latest @@ -81,7 +109,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Start database + - name: Start database server run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db - name: Use PHP uses: shivammathur/setup-php@v2 @@ -104,7 +132,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Start database + - name: Start database server 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 @@ -127,7 +155,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Start database + - name: Start database server 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 @@ -152,7 +180,7 @@ jobs: uses: actions/checkout@v2 - name: Install MSSQL ODBC run: sudo ./data/infra/ci/install-ms-odbc.sh - - name: Start database + - name: Start database server run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms - name: Use PHP uses: shivammathur/setup-php@v2 @@ -165,7 +193,8 @@ jobs: run: composer install --no-interaction --prefer-dist --ignore-platform-req=php - if: ${{ matrix.php-version != '8.0' }} run: composer install --no-interaction --prefer-dist - - 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: Create test database + run: docker-compose exec -T shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;" - run: composer test:db:ms api-tests: @@ -177,7 +206,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Start database + - name: Start database server run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db - name: Use PHP uses: shivammathur/setup-php@v2 @@ -192,4 +221,9 @@ jobs: - if: ${{ matrix.php-version != '8.0' }} run: composer install --no-interaction --prefer-dist - run: bin/test/run-api-tests.sh - # TODO Upload code coverage on one PHP version only + - uses: actions/upload-artifact@v2 + with: + name: coverage-api + path: | + build/coverage-api + build/coverage-api.cov From d8a7f3e08c5b161b45e3673654dd0f5f5523e5df Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 13:11:41 +0100 Subject: [PATCH 08/13] Added mutation-tests step in ci workflow --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ composer.json | 3 ++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d96e5ce5..652a66d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,6 +67,7 @@ jobs: run: composer install --no-interaction --prefer-dist - run: composer test:unit:ci - uses: actions/upload-artifact@v2 + if: ${{ matrix.php-version == '7.4' }} with: name: coverage-unit path: | @@ -95,6 +96,7 @@ jobs: run: composer install --no-interaction --prefer-dist - run: composer test:db:sqlite:ci - uses: actions/upload-artifact@v2 + if: ${{ matrix.php-version == '7.4' }} with: name: coverage-db path: | @@ -222,8 +224,41 @@ jobs: run: composer install --no-interaction --prefer-dist - run: bin/test/run-api-tests.sh - uses: actions/upload-artifact@v2 + if: ${{ matrix.php-version == '7.4' }} with: name: coverage-api path: | build/coverage-api build/coverage-api.cov + + mutation-tests: + needs: + - unit-tests + - db-tests-sqlite + - api-tests + runs-on: ubuntu-latest + strategy: + matrix: + php-version: ['7.4'] + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Start database server + run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db + - name: Use PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer + extensions: swoole-4.5.9 + coverage: pcov + ini-values: pcov.directory=module + - if: ${{ matrix.php-version == '8.0' }} + run: composer install --no-interaction --prefer-dist --ignore-platform-req=php + - if: ${{ matrix.php-version != '8.0' }} + run: composer install --no-interaction --prefer-dist + - uses: actions/download-artifact@v2 + with: + path: build + - run: ls -l build + - run: composer infect:ci diff --git a/composer.json b/composer.json index b89d3e63..19c4097e 100644 --- a/composer.json +++ b/composer.json @@ -115,7 +115,8 @@ ], "test:ci": [ "@test:unit:ci", - "@test:db" + "@test:db", + "@test:api" ], "test:unit": "@php vendor/bin/phpunit --order-by=random --colors=always --coverage-php build/coverage-unit.cov --testdox", "test:unit:ci": "@test:unit --coverage-xml=build/coverage-unit/coverage-xml --log-junit=build/coverage-unit/junit.xml", From 53726bc679f03c50919c92c24a412711408372f3 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 13:34:22 +0100 Subject: [PATCH 09/13] Added steps to upload code coverage and delete artifacts to ci workflow --- .github/workflows/ci.yml | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 652a66d4..02308b9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -260,5 +260,39 @@ jobs: - uses: actions/download-artifact@v2 with: path: build - - run: ls -l build - run: composer infect:ci + + upload-coverage: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: ['7.4'] + steps: + - name: Use PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + - 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 + - run: wget https://phar.phpunit.de/phpcov-7.0.2.phar + - run: php phpcov-7.0.2.phar merge build --clover build/clover.xml + - run: wget https://scrutinizer-ci.com/ocular.phar + - run: php ocular.phar code-coverage:upload --format=php-clover build/clover.xml + + delete-artifacts: + needs: + - mutation-tests + - upload-coverage + runs-on: ubuntu-latest + steps: + - uses: geekyeggo/delete-artifact@v1 + with: + name: | + coverage-unit + coverage-db + coverage-api From 1a42ca9239411e51dde6b4df7228921ed277938f Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 17:17:16 +0100 Subject: [PATCH 10/13] Added missing dependency between upload coverage job and test jobs --- .github/workflows/ci.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02308b9d..f4535352 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: jobs: lint: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: php-version: ['7.4'] @@ -27,7 +27,7 @@ jobs: - run: composer cs static-analysis: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: php-version: ['7.4'] @@ -45,7 +45,7 @@ jobs: - run: composer stan unit-tests: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 continue-on-error: ${{ matrix.php-version == '8.0' }} strategy: matrix: @@ -75,7 +75,7 @@ jobs: build/coverage-unit.cov db-tests-sqlite: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: php-version: ['7.4', '8.0'] @@ -104,7 +104,7 @@ jobs: build/coverage-db.cov db-tests-mysql: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: php-version: ['7.4', '8.0'] @@ -127,7 +127,7 @@ jobs: - run: composer test:db:mysql db-tests-maria: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: php-version: ['7.4', '8.0'] @@ -150,7 +150,7 @@ jobs: - run: composer test:db:maria db-tests-postgres: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: php-version: ['7.4', '8.0'] @@ -173,7 +173,7 @@ jobs: - run: composer test:db:postgres db-tests-ms: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: php-version: ['7.4', '8.0'] @@ -200,7 +200,7 @@ jobs: - run: composer test:db:ms api-tests: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 continue-on-error: ${{ matrix.php-version == '8.0' }} strategy: matrix: @@ -236,7 +236,7 @@ jobs: - unit-tests - db-tests-sqlite - api-tests - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: php-version: ['7.4'] @@ -263,7 +263,11 @@ jobs: - run: composer infect:ci upload-coverage: - runs-on: ubuntu-latest + needs: + - unit-tests + - db-tests-sqlite + - api-tests + runs-on: ubuntu-20.04 strategy: matrix: php-version: ['7.4'] @@ -288,7 +292,7 @@ jobs: needs: - mutation-tests - upload-coverage - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: geekyeggo/delete-artifact@v1 with: From f2210ca0cb85b9a2e740fc11098f21560ef77c9e Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 17:23:58 +0100 Subject: [PATCH 11/13] Added coverage driver to upload coverage job --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4535352..b75e3861 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -276,7 +276,8 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - coverage: none + coverage: pcov + ini-values: pcov.directory=module - uses: actions/download-artifact@v2 with: path: build From a9e9f897999ae532e1e0dfe9af6599676255517b Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 17:31:22 +0100 Subject: [PATCH 12/13] Ensured code is cloned before using ocular to upload code coverage to scrutinizer during ci workflow --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b75e3861..22b459b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -272,6 +272,8 @@ jobs: matrix: php-version: ['7.4'] steps: + - name: Checkout code + uses: actions/checkout@v2 - name: Use PHP uses: shivammathur/setup-php@v2 with: From 625c87041721d0a65774cdd1fb89ad93d6683658 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 13 Dec 2020 17:45:48 +0100 Subject: [PATCH 13/13] Added step to build docker image, and deleted travis config file --- .github/workflows/ci.yml | 14 ++++++++++ .travis.yml | 56 ---------------------------------------- README.md | 4 +-- 3 files changed, 16 insertions(+), 58 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22b459b9..4e5ff5b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -303,3 +303,17 @@ jobs: coverage-unit coverage-db coverage-api + + build-docker-image: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + - 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" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f3857e5d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,56 +0,0 @@ -dist: bionic - -language: php - -branches: - only: - - /.*/ - -services: - - docker - -cache: - directories: - - $HOME/.composer/cache/files - -jobs: - fast_finish: true - allow_failures: - - php: '8.0' - include: - - name: 'CI - 8.0' - php: '8.0' - env: - - COMPOSER_FLAGS='--ignore-platform-req=php' - - name: 'CI - 7.4' - php: '7.4' - env: - - COMPOSER_FLAGS='' - -before_install: - - echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - - phpenv config-rm xdebug.ini || return 0 - - sudo ./data/infra/ci/install-ms-odbc.sh - - docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms shlink_db shlink_db_postgres shlink_db_maria - - yes | pecl install pdo_sqlsrv-5.9.0beta2 swoole-4.5.9 pcov - -install: - - composer self-update - - composer install --no-interaction --prefer-dist $COMPOSER_FLAGS - -before_script: - - docker-compose exec shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;" - - mkdir build - - export DOCKERFILE_CHANGED=$(git diff ${TRAVIS_COMMIT_RANGE:-origin/main} --name-only | grep Dockerfile) - -script: - - composer ci - - bin/test/run-api-tests.sh - - if [[ ! -z "${DOCKERFILE_CHANGED}" && "${TRAVIS_PHP_VERSION}" == "7.4" ]]; then docker build -t shlink-docker-image:temp . ; fi - -after_success: - - rm -f build/clover.xml - - wget https://phar.phpunit.de/phpcov-7.0.2.phar - - php phpcov-7.0.2.phar merge build --clover build/clover.xml - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover build/clover.xml diff --git a/README.md b/README.md index 1f6d2149..255c719e 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ ![Shlink](https://raw.githubusercontent.com/shlinkio/shlink.io/main/public/images/shlink-hero.png) -[![Build Status](https://img.shields.io/travis/com/shlinkio/shlink.svg?style=flat-square)](https://travis-ci.com/shlinkio/shlink) +[![Build Status](https://img.shields.io/github/workflow/status/shlinkio/shlink/Continuous%20integration/main?logo=github&style=flat-square)](https://github.com/shlinkio/shlink/actions?query=workflow%3A%22Continuous+integration%22) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/shlinkio/shlink.svg?style=flat-square)](https://scrutinizer-ci.com/g/shlinkio/shlink/) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/shlinkio/shlink.svg?style=flat-square)](https://scrutinizer-ci.com/g/shlinkio/shlink/) [![Latest Stable Version](https://img.shields.io/github/release/shlinkio/shlink.svg?style=flat-square)](https://packagist.org/packages/shlinkio/shlink) -[![Docker pulls](https://img.shields.io/docker/pulls/shlinkio/shlink.svg?style=flat-square)](https://hub.docker.com/r/shlinkio/shlink/) +[![Docker pulls](https://img.shields.io/docker/pulls/shlinkio/shlink.svg?logo=docker&style=flat-square)](https://hub.docker.com/r/shlinkio/shlink/) [![License](https://img.shields.io/github/license/shlinkio/shlink.svg?style=flat-square)](https://github.com/shlinkio/shlink/blob/main/LICENSE) [![Paypal donate](https://img.shields.io/badge/Donate-paypal-blue.svg?style=flat-square&logo=paypal&colorA=aaaaaa)](https://slnk.to/donate)