From 8a55c50b0232fe35ce312a282c477ae50ec7915b Mon Sep 17 00:00:00 2001 From: yoanm <4410697+yoanm@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:54:14 +0100 Subject: [PATCH 1/2] Update CI.yml --- .github/workflows/CI.yml | 99 ++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 65 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0f3152f..30bb8b8 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,7 +4,6 @@ on: # Build any PRs and main branch changes pull_request: types: - opened - - edited - synchronize push: branches: [ master ] @@ -18,8 +17,6 @@ concurrency: env: TEST_OUTPUT_STYLE: pretty COMPOSER_OPTIONS: --optimize-autoloader - CODACY_CACHE_PATH: ~/.cache/codacy - CODACY_BIN: ~/.cache/codacy/codacy.sh jobs: tests: @@ -65,13 +62,13 @@ jobs: - name: Setup PHP ${{ matrix.php-version }} uses: shivammathur/setup-php@v2 + env: + update: true # Always use latest available patch for the version + fail-fast: true # step will fail if an extension or tool fails to set up with: php-version: '${{ matrix.php-version }}' tools: composer coverage: ${{ env.COVERAGE_TYPE }} - env: - # Always use latest available patch for the version - update: true - name: Setup cache id: cache @@ -80,18 +77,9 @@ jobs: path: | ~/.composer ./vendor - ${{ env.CODACY_CACHE_PATH }} # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }} - - name: Download codacy binary - if: steps.cache.outputs.cache-hit != 'true' - run: | - mkdir -p ${{ env.CODACY_CACHE_PATH }} \ - && curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \ - && chmod +x ${{ env.CODACY_BIN }} \ - && ${{ env.CODACY_BIN }} download - - name: Build run: | SF_VERSION=${{ matrix.symfony-version }} @@ -110,39 +98,45 @@ jobs: - name: Tests run: make test-unit && make test-functional - # Upload to codacy first as codecov action always remove coverage files despite move_coverage_to_trash at false - # And only if it's not a PR from a fork => Can't work as codacy secret is not accessible in that context - - name: Upload coverages to Codacy - if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/symfony-jsonrpc-http-server') && env.COVERAGE_TYPE == 'xdebug' }} - run: ${{ env.CODACY_BIN }} report -r build/coverage-phpunit/unit.clover -r build/coverage-behat/clover.xml -r build/coverage-phpunit/functional.clover -t ${{ secrets.CODACY_PROJECT_TOKEN }} --partial - - # See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server - - name: Upload unit tests coverage to codecov + - name: Create "unit tests" reports group if: ${{ env.COVERAGE_TYPE == 'xdebug' }} - uses: codecov/codecov-action@v3 + id: unit-tests-coverage-group + uses: yoanm/tmp-reports-group-workspace/.github/actions/create-action@develop with: - file: "build/coverage-phpunit/unit.clover" - name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" - fail_ci_if_error: true - move_coverage_to_trash: false - verbose: ${{ runner.debug == '1' }} - - - name: Upload functional tests coverage to codecov + name: unit-tests + format: clover + files: build/coverage-phpunit/unit.clover + flags: | + unit-tests + php-${{ matrix.php-version }} + path: build/coverage-groups + + - name: Create "functional tests" coverage group if: ${{ env.COVERAGE_TYPE == 'xdebug' }} - uses: codecov/codecov-action@v3 + id: functional-tests-coverage-group + uses: yoanm/tmp-reports-group-workspace/.github/actions/create-action@develop with: - files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover" - name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" - fail_ci_if_error: true - move_coverage_to_trash: false - verbose: ${{ runner.debug == '1' }} + name: functional-tests + format: clover + files: | + build/coverage-phpunit/functional.clover + build/coverage-behat/clover.xml + flags: | + functional-tests + php-${{ matrix.php-version }} + path: build/coverage-groups + + - name: Upload coverage reports + if: ${{ env.COVERAGE_TYPE == 'xdebug' }} + uses: actions/upload-artifact@v4 + with: + name: coverage-groups-php${{ matrix.php-version }}-sf${{ matrix.symfony-version }} + path: build/coverage-groups + if-no-files-found: error static-checks: name: Static checks runs-on: ubuntu-latest - needs: [ tests ] steps: - uses: actions/checkout@v3 @@ -175,31 +169,6 @@ jobs: if: ${{ github.event_name == 'pull_request' }} uses: actions/dependency-review-action@v1 - finalize-codacy-coverage-report: - runs-on: ubuntu-latest - name: Finalize Codacy coverage report - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/symfony-jsonrpc-http-server' }} - needs: [ tests ] - steps: - - name: Setup cache - id: cache - uses: actions/cache@v3 - with: - path: | - ${{ env.CODACY_CACHE_PATH }} - key: codacy-final - - - name: Download codacy binary - if: steps.cache.outputs.cache-hit != 'true' - run: | - mkdir -p ${{ env.CODACY_CACHE_PATH }} \ - && curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \ - && chmod +x ${{ env.CODACY_BIN }} \ - && ${{ env.CODACY_BIN }} download - - - name: Finalize reporting - run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }} - nightly-tests: name: Nightly - Symfony ${{ matrix.symfony-version }} runs-on: ubuntu-latest From 22cdc423d4222c429f0827a7907f1bce7a3130a9 Mon Sep 17 00:00:00 2001 From: yoanm <4410697+yoanm@users.noreply.github.com> Date: Mon, 25 Mar 2024 20:00:43 +0100 Subject: [PATCH 2/2] Update CI.yml --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 30bb8b8..9953ff7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,4 +1,5 @@ name: 'CI' + on: # Build any PRs and main branch changes workflow_dispatch: # Allows to run the workflow manually from the Actions tab pull_request: