From cee5c328e614b5be826341ee1e1e973e96bfb26b Mon Sep 17 00:00:00 2001 From: yethee Date: Tue, 14 May 2024 18:51:42 +0300 Subject: [PATCH] Add code coverage report --- .github/workflows/ci.yml | 49 ++++++++++++++++++++++++++++++++-------- README.md | 1 + 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd3dfa7..51fa353 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: coding-standards: name: "Check Coding Standards" - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" steps: - name: "Checkout" @@ -19,7 +19,7 @@ jobs: with: coverage: "none" php-version: "8.1" - tools: composer:v2 + tools: "composer:v2" - name: "Install dependencies" uses: "ramsey/composer-install@v3" @@ -27,12 +27,12 @@ jobs: dependency-versions: "highest" - name: "Run phpcs" - run: vendor/bin/phpcs -n + run: "vendor/bin/phpcs -n" static-analysis: name: "Static Analysis" - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" steps: - name: "Checkout" @@ -43,7 +43,7 @@ jobs: with: coverage: "none" php-version: "8.1" - tools: composer:v2 + tools: "composer:v2" - name: "Install dependencies" uses: "ramsey/composer-install@v3" @@ -51,12 +51,43 @@ jobs: dependency-versions: "highest" - name: "Run psalm" - run: vendor/bin/psalm + run: "vendor/bin/psalm" + + code-coverage: + name: "Code coverage" + + needs: [ "coding-standards", "static-analysis" ] + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "pcov" + php-version: "8.3" + tools: "composer:v2" + + - name: "Install dependencies" + uses: "ramsey/composer-install@v3" + with: + dependency-versions: "highest" + + - name: "Run tests" + run: "vendor/bin/phpunit --coverage-clover=coverage.xml" + + - name: "Upload coverage reports to Codecov" + uses: "codecov/codecov-action@v4" + with: + token: ${{ secrets.CODECOV_TOKEN }} tests: name: "PHPUnit tests" - runs-on: ubuntu-latest + needs: ["code-coverage"] + runs-on: "ubuntu-latest" strategy: matrix: @@ -78,7 +109,7 @@ jobs: uses: "shivammathur/setup-php@v2" with: php-version: "${{ matrix.php-version }}" - tools: composer:v2 + tools: "composer:v2" - name: "Install dependencies" uses: "ramsey/composer-install@v3" @@ -86,4 +117,4 @@ jobs: dependency-versions: "${{ matrix.dependencies }}" - name: "Run tests" - run: vendor/bin/phpunit + run: "vendor/bin/phpunit --no-coverage" diff --git a/README.md b/README.md index b07784d..800479a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ![Packagist Version](https://img.shields.io/packagist/v/yethee/tiktoken) ![Build status](https://img.shields.io/github/actions/workflow/status/yethee/tiktoken-php/ci.yml?branch=master) +[![codecov](https://codecov.io/github/yethee/tiktoken-php/graph/badge.svg)](https://codecov.io/github/yethee/tiktoken-php) ![License](https://img.shields.io/github/license/yethee/tiktoken-php) This is a port of the [tiktoken](https://github.com/openai/tiktoken).