WebProject-xyz/ikea-tradfri-php

View on GitHub
.github/workflows/codecov.yml

Summary

Maintainability
Test Coverage
on: [ push, pull_request ]
name: Codecov

jobs:
    codeception-tests:
        name: "Codeception tests"
        runs-on: "ubuntu-latest"
        continue-on-error: ${{ matrix.allow-fail }}
        strategy:
            matrix:
                include:
                    - { php-version: 8.2, dependencies: locked, coverage: xdebug, with_coverage: true, allow-fail: false }

        steps:
            -   name: "Checkout"
                uses: "actions/checkout@v4.1.6"

            -   name: "Install PHP"
                uses: "shivammathur/setup-php@v2"
                with:
                    coverage: "${{ matrix.coverage }}"
                    ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767
                    php-version: "${{ matrix.php-version }}"

            -   name: "Set up problem matchers for PHP"
                run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""

            -   name: "Set up problem matchers for phpunit/phpunit"
                run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\""

            -   name: "Validate composer.json and composer.lock"
                run: "composer validate --ansi --strict"

            -   name: "Determine composer cache directory"
                uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.9.1"

            -   name: "Cache dependencies installed with composer"
                uses: "actions/cache@v4.0.2"
                with:
                    path: "${{ env.COMPOSER_CACHE_DIR }}"
                    key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
                    restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

            -   name: "Install ${{ matrix.dependencies }} dependencies with composer"
                uses: "ergebnis/.github/actions/composer/install@1.9.1"
                with:
                    dependencies: "${{ matrix.dependencies }}"

            -   name: "Run Codeception with coverage"
                run: |
                    vendor/bin/codecept run -c . -vvv --coverage --coverage-xml=coverage.xml
                    
            -   name: "Upload Coverage coverage"
                run: |
                    export CODACY_PROJECT_TOKEN=${{ secrets.CODACY_PROJECT_TOKEN }}
                    bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r ./build/logs/coverage.xml
            -   name: Codecov
                uses: codecov/codecov-action@v4
                with:
                    token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
                    files: ./build/logs/coverage.xml
                    flags: unittests # optional
                    fail_ci_if_error: "${{ matrix.with_coverage }}" # optional (default = false)
                    verbose: false # optional (default = false)