From 75d2ef618b9143a07653be86ca7273f4d418c66e Mon Sep 17 00:00:00 2001 From: SimonZanta Date: Mon, 18 May 2026 10:48:37 +0200 Subject: [PATCH 1/7] feat: add code coverage badge workflow and README badge - Add coverage-badge.yml workflow triggered on push to master - Runs Codeception with --coverage --coverage-xml - Parses coverage % from Clover XML via PHP one-liner - Updates GitHub Gist via schneegans/dynamic-badges-action - Adds shields.io coverage badge to README.md (placeholder {GH_USER}/{GIST_ID}) Manual setup required: - Create GitHub Gist with coverage.json file - Create PAT with gist scope - Add GIST_TOKEN and COVERAGE_GIST_ID secrets to repo Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/coverage-badge.yml | 106 +++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 107 insertions(+) create mode 100644 .github/workflows/coverage-badge.yml diff --git a/.github/workflows/coverage-badge.yml b/.github/workflows/coverage-badge.yml new file mode 100644 index 0000000..d5756db --- /dev/null +++ b/.github/workflows/coverage-badge.yml @@ -0,0 +1,106 @@ +name: "coverage-badge" + +on: + push: + branches: + - master + +env: + extensions: "json, xdebug" + cache-version: "1" + composer-version: "v2" + composer-install: "composer install --no-interaction --no-progress --prefer-dist" + coverage: "xdebug" + +jobs: + coverage: + name: "Coverage Badge" + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Setup PHP cache environment" + id: "extcache" + uses: "shivammathur/cache-extensions@v1" + with: + php-version: "8.5" + extensions: "${{ env.extensions }}" + key: "${{ env.cache-version }}" + + - name: "Cache PHP extensions" + uses: "actions/cache@v4" + with: + path: "${{ steps.extcache.outputs.dir }}" + key: "${{ steps.extcache.outputs.key }}" + restore-keys: "${{ steps.extcache.outputs.key }}" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.5" + extensions: "${{ env.extensions }}" + tools: "composer:${{ env.composer-version }}" + coverage: "${{ env.coverage }}" + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Get Composer cache directory" + id: "composercache" + run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' + + - name: "Cache PHP dependencies" + uses: "actions/cache@v4" + with: + path: "${{ steps.composercache.outputs.dir }}" + key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" + restore-keys: "${{ runner.os }}-composer-" + + - name: "Install dependencies" + run: "${{ env.composer-install }}" + + - name: "Env variables" + run: | + echo "API_MERCHANT=${{ secrets.API_MERCHANT }}" >> .env + echo "API_SECRET=${{ secrets.API_SECRET }}" >> .env + echo "API_URL=${{ secrets.API_URL }}" >> .env + echo "API_URL_REST=${{ secrets.API_URL_REST }}" >> .env + echo "APPLICATION_ENV='sdk-github'" >> .env + echo "CF_ACCESS_CLIENT_ID=${{ secrets.CF_ACCESS_CLIENT_ID }}" >> .env + echo "CF_ACCESS_CLIENT_SECRET=${{ secrets.CF_ACCESS_CLIENT_SECRET }}" >> .env + + - name: "Build Codeception actors" + run: "vendor/bin/codecept build -v" + + - name: "Regenerate autoloader" + run: "composer dump-autoload --optimize" + + - name: "Run tests with coverage" + run: | + vendor/bin/codecept run --coverage --coverage-xml coverage.xml + + - name: "Extract coverage percentage" + id: "coverage" + run: | + COVERAGE=$(php -r " + \$xml = simplexml_load_file('tests/_output/coverage.xml'); + \$metrics = \$xml->project->metrics; + \$statements = (int)\$metrics['statements']; + \$covered = (int)\$metrics['coveredstatements']; + echo \$statements > 0 ? round(\$covered / \$statements * 100) : 0; + ") + echo "percentage=${COVERAGE}" >> $GITHUB_OUTPUT + echo "Coverage: ${COVERAGE}%" + + - name: "Update coverage badge (Gist)" + uses: schneegans/dynamic-badges-action@v1.7.0 + with: + auth: ${{ secrets.GIST_TOKEN }} + gistID: ${{ secrets.COVERAGE_GIST_ID }} + filename: coverage.json + label: coverage + message: "${{ steps.coverage.outputs.percentage }}%" + valColorRange: ${{ steps.coverage.outputs.percentage }} + maxColorRange: 100 + minColorRange: 0 diff --git a/README.md b/README.md index 764f349..22d39fe 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@

+ From db2a54d6fc12f39fdc7fb218156f5db0bb260b22 Mon Sep 17 00:00:00 2001 From: SimonZanta Date: Mon, 18 May 2026 11:00:03 +0200 Subject: [PATCH 2/7] fix: update coverage badge URL with actual Gist ID Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22d39fe..58975ab 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

- + From c5b2336092c955daa59eb6599e912a0a54482b6c Mon Sep 17 00:00:00 2001 From: SimonZanta Date: Mon, 18 May 2026 11:23:21 +0200 Subject: [PATCH 3/7] fix: set XDEBUG_MODE=coverage env var for codecept run Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/coverage-badge.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/coverage-badge.yml b/.github/workflows/coverage-badge.yml index d5756db..9d6ac78 100644 --- a/.github/workflows/coverage-badge.yml +++ b/.github/workflows/coverage-badge.yml @@ -77,6 +77,8 @@ jobs: run: "composer dump-autoload --optimize" - name: "Run tests with coverage" + env: + XDEBUG_MODE: coverage run: | vendor/bin/codecept run --coverage --coverage-xml coverage.xml From db5c4b998483fa271dd9e3ece5809fd46dd24f59 Mon Sep 17 00:00:00 2001 From: SimonZanta Date: Mon, 18 May 2026 13:12:14 +0200 Subject: [PATCH 4/7] feat: deploy coverage HTML report to GitHub Pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add permissions: pages write + id-token write - Add --coverage-html to codecept run - Upload tests/_output/coverage/ as Pages artifact - Add deploy job using actions/deploy-pages@v4 Manual setup: Repo → Settings → Pages → Source: GitHub Actions URL: https://comgate-payments.github.io/sdk-php/ Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/coverage-badge.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage-badge.yml b/.github/workflows/coverage-badge.yml index 9d6ac78..5a9071c 100644 --- a/.github/workflows/coverage-badge.yml +++ b/.github/workflows/coverage-badge.yml @@ -5,6 +5,10 @@ on: branches: - master +permissions: + pages: write + id-token: write + env: extensions: "json, xdebug" cache-version: "1" @@ -80,7 +84,7 @@ jobs: env: XDEBUG_MODE: coverage run: | - vendor/bin/codecept run --coverage --coverage-xml coverage.xml + vendor/bin/codecept run --coverage --coverage-xml coverage.xml --coverage-html - name: "Extract coverage percentage" id: "coverage" @@ -106,3 +110,20 @@ jobs: valColorRange: ${{ steps.coverage.outputs.percentage }} maxColorRange: 100 minColorRange: 0 + + - name: "Upload Pages artifact" + uses: actions/upload-pages-artifact@v3 + with: + path: tests/_output/coverage/ + + deploy: + name: "Deploy to GitHub Pages" + needs: coverage + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: "Deploy to GitHub Pages" + uses: actions/deploy-pages@v4 + id: deployment From dea7ea7dd78f3a9c7bf41e2c162d614b109fdd38 Mon Sep 17 00:00:00 2001 From: SimonZanta Date: Mon, 18 May 2026 13:54:12 +0200 Subject: [PATCH 5/7] feat: migrate to Coveralls, remove Gist badge and GitHub Pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove coverage-badge.yml (Gist + GitHub Pages approach) - Add coverage.yml: runs on push to master, uploads clover XML to Coveralls - Update README badge to Coveralls Manual setup: https://coveralls.io → enable repo → add COVERALLS_REPO_TOKEN secret Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../{coverage-badge.yml => coverage.yml} | 54 +++---------------- README.md | 2 +- 2 files changed, 8 insertions(+), 48 deletions(-) rename .github/workflows/{coverage-badge.yml => coverage.yml} (62%) diff --git a/.github/workflows/coverage-badge.yml b/.github/workflows/coverage.yml similarity index 62% rename from .github/workflows/coverage-badge.yml rename to .github/workflows/coverage.yml index 5a9071c..30c5266 100644 --- a/.github/workflows/coverage-badge.yml +++ b/.github/workflows/coverage.yml @@ -1,14 +1,10 @@ -name: "coverage-badge" +name: "coverage" on: push: branches: - master -permissions: - pages: write - id-token: write - env: extensions: "json, xdebug" cache-version: "1" @@ -18,7 +14,7 @@ env: jobs: coverage: - name: "Coverage Badge" + name: "Coverage" runs-on: "ubuntu-latest" steps: @@ -84,46 +80,10 @@ jobs: env: XDEBUG_MODE: coverage run: | - vendor/bin/codecept run --coverage --coverage-xml coverage.xml --coverage-html - - - name: "Extract coverage percentage" - id: "coverage" - run: | - COVERAGE=$(php -r " - \$xml = simplexml_load_file('tests/_output/coverage.xml'); - \$metrics = \$xml->project->metrics; - \$statements = (int)\$metrics['statements']; - \$covered = (int)\$metrics['coveredstatements']; - echo \$statements > 0 ? round(\$covered / \$statements * 100) : 0; - ") - echo "percentage=${COVERAGE}" >> $GITHUB_OUTPUT - echo "Coverage: ${COVERAGE}%" + vendor/bin/codecept run --coverage --coverage-xml coverage.xml - - name: "Update coverage badge (Gist)" - uses: schneegans/dynamic-badges-action@v1.7.0 + - name: "Upload coverage to Coveralls" + uses: coverallsapp/github-action@v2 with: - auth: ${{ secrets.GIST_TOKEN }} - gistID: ${{ secrets.COVERAGE_GIST_ID }} - filename: coverage.json - label: coverage - message: "${{ steps.coverage.outputs.percentage }}%" - valColorRange: ${{ steps.coverage.outputs.percentage }} - maxColorRange: 100 - minColorRange: 0 - - - name: "Upload Pages artifact" - uses: actions/upload-pages-artifact@v3 - with: - path: tests/_output/coverage/ - - deploy: - name: "Deploy to GitHub Pages" - needs: coverage - runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - name: "Deploy to GitHub Pages" - uses: actions/deploy-pages@v4 - id: deployment + file: tests/_output/coverage.xml + format: clover diff --git a/README.md b/README.md index 58975ab..58a89a9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

- + From 4b1d221b8e678fc8b731837cc078b42dbfcfeaa4 Mon Sep 17 00:00:00 2001 From: SimonZanta Date: Mon, 18 May 2026 14:57:19 +0200 Subject: [PATCH 6/7] chore: remove coverage.yml, merged into tests.yml Coverage on push to master is now handled by tests.yml directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/coverage.yml | 89 ---------------------------------- 1 file changed, 89 deletions(-) delete mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index 30c5266..0000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: "coverage" - -on: - push: - branches: - - master - -env: - extensions: "json, xdebug" - cache-version: "1" - composer-version: "v2" - composer-install: "composer install --no-interaction --no-progress --prefer-dist" - coverage: "xdebug" - -jobs: - coverage: - name: "Coverage" - runs-on: "ubuntu-latest" - - steps: - - name: "Checkout" - uses: actions/checkout@v4 - - - name: "Setup PHP cache environment" - id: "extcache" - uses: "shivammathur/cache-extensions@v1" - with: - php-version: "8.5" - extensions: "${{ env.extensions }}" - key: "${{ env.cache-version }}" - - - name: "Cache PHP extensions" - uses: "actions/cache@v4" - with: - path: "${{ steps.extcache.outputs.dir }}" - key: "${{ steps.extcache.outputs.key }}" - restore-keys: "${{ steps.extcache.outputs.key }}" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "8.5" - extensions: "${{ env.extensions }}" - tools: "composer:${{ env.composer-version }}" - coverage: "${{ env.coverage }}" - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: "Get Composer cache directory" - id: "composercache" - run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' - - - name: "Cache PHP dependencies" - uses: "actions/cache@v4" - with: - path: "${{ steps.composercache.outputs.dir }}" - key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" - restore-keys: "${{ runner.os }}-composer-" - - - name: "Install dependencies" - run: "${{ env.composer-install }}" - - - name: "Env variables" - run: | - echo "API_MERCHANT=${{ secrets.API_MERCHANT }}" >> .env - echo "API_SECRET=${{ secrets.API_SECRET }}" >> .env - echo "API_URL=${{ secrets.API_URL }}" >> .env - echo "API_URL_REST=${{ secrets.API_URL_REST }}" >> .env - echo "APPLICATION_ENV='sdk-github'" >> .env - echo "CF_ACCESS_CLIENT_ID=${{ secrets.CF_ACCESS_CLIENT_ID }}" >> .env - echo "CF_ACCESS_CLIENT_SECRET=${{ secrets.CF_ACCESS_CLIENT_SECRET }}" >> .env - - - name: "Build Codeception actors" - run: "vendor/bin/codecept build -v" - - - name: "Regenerate autoloader" - run: "composer dump-autoload --optimize" - - - name: "Run tests with coverage" - env: - XDEBUG_MODE: coverage - run: | - vendor/bin/codecept run --coverage --coverage-xml coverage.xml - - - name: "Upload coverage to Coveralls" - uses: coverallsapp/github-action@v2 - with: - file: tests/_output/coverage.xml - format: clover From d4a4884c26f438b8f8035260146c73f58919747a Mon Sep 17 00:00:00 2001 From: SimonZanta Date: Mon, 18 May 2026 15:00:15 +0200 Subject: [PATCH 7/7] feat: add Coveralls upload and push-to-master trigger to tests.yml - Add push: branches: master trigger for baseline coverage update - Checkout fallback for PR vs push events - Add coverallsapp/github-action@v2 step for coverage upload Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/tests.yml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b8b04a6..be5a9a5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,6 +2,9 @@ name: "tests" on: pull_request_target: types: [assigned, opened, synchronize, reopened] + push: + branches: + - master env: extensions: "json, xdebug" cache-version: "1" @@ -24,8 +27,8 @@ jobs: - name: Checkout PR head (fork code) uses: actions/checkout@v4 with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} + ref: ${{ github.event.pull_request.head.sha || github.sha }} fetch-depth: 0 persist-credentials: false @@ -94,8 +97,26 @@ jobs: run: "composer dump-autoload --optimize" - name: Run Codeception Tests + env: + XDEBUG_MODE: coverage run: | - vendor/bin/codecept run -v + vendor/bin/codecept run -v --coverage --coverage-xml coverage.xml --coverage-html + + - name: Upload coverage report + if: ${{ success() || failure() }} + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: | + tests/_output/coverage.xml + tests/_output/coverage/ + + - name: "Upload coverage to Coveralls" + if: ${{ success() }} + uses: coverallsapp/github-action@v2 + with: + file: tests/_output/coverage.xml + format: clover - name: IP check on Failure if: ${{ failure() }}