Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ci #32

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 37 additions & 64 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'CI'

on: # Build any PRs and main branch changes
workflow_dispatch: # Allows to run the workflow manually from the Actions tab
pull_request:
types:
- opened
- edited
- synchronize
push:
branches: [ master ]
Expand All @@ -18,8 +18,6 @@ concurrency:
env:
TEST_OUTPUT_STYLE: pretty
COMPOSER_OPTIONS: --optimize-autoloader
CODACY_CACHE_PATH: ~/.cache/codacy
CODACY_BIN: ~/.cache/codacy/codacy.sh

jobs:
tests:
Expand Down Expand Up @@ -65,13 +63,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
Expand All @@ -80,18 +78,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 }}
Expand All @@ -110,34 +99,43 @@ 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-params-validator') && 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-params-validator
- 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/temp-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 }}
sf-${{ matrix.symfony-version }}
path: build/coverage-groups

- name: Create "functional tests" coverage group
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
id: functional-tests-coverage-group
uses: yoanm/temp-reports-group-workspace/.github/actions/create-action@develop
with:
name: functional-tests
format: clover
files: |
build/coverage-phpunit/functional.clover
build/coverage-behat/clover.xml
flags: |
functional-tests
php-${{ matrix.php-version }}
sf-${{ matrix.symfony-version }}
path: build/coverage-groups

- name: Upload coverage reports
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
uses: codecov/codecov-action@v3
uses: actions/upload-artifact@v4
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: coverage-groups-php${{ matrix.php-version }}-sf${{ matrix.symfony-version }}
path: build/coverage-groups
if-no-files-found: error

static-checks:
name: Static checks
Expand Down Expand Up @@ -174,31 +172,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-params-validator' }}
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
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/coverage-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
checks: write # For the check run creation !
steps:
- name: 'Check run ○'
uses: yoanm/tmp-reports-group-workspace/.github/actions/attach-check-run-to-triggering-workflow-action@develop
uses: yoanm/temp-reports-group-workspace/.github/actions/attach-check-run-to-triggering-workflow-action@develop
with:
name: 'Fetch coverage info'
fails-on-triggering-workflow-failure: true

- uses: yoanm/tmp-reports-group-workspace/.github/actions/fetch-workflow-metadata-action@develop
- uses: yoanm/temp-reports-group-workspace/.github/actions/fetch-workflow-metadata-action@develop
id: fetch-workflow-metadata

outputs:
Expand All @@ -28,7 +28,7 @@ jobs:
codacy-uploader:
name: Codacy
needs: [fetch-info]
uses: yoanm/tmp-reports-group-workspace/.github/workflows/codacy-upload-from-artifacts.yml@develop
uses: yoanm/temp-reports-group-workspace/.github/workflows/codacy-upload-from-artifacts.yml@develop
permissions:
contents: read
checks: write # For the check run creation !
Expand All @@ -37,12 +37,11 @@ jobs:
with:
artifacts-pattern: coverage-groups-*
run-id: ${{ needs.fetch-info.outputs.run-id }}
override-commit: ${{ needs.fetch-info.outputs.commit-sha }}

codecov-uploader:
name: Codecov
needs: [fetch-info]
uses: yoanm/tmp-reports-group-workspace/.github/workflows/codecov-upload-from-artifacts.yml@develop
uses: yoanm/temp-reports-group-workspace/.github/workflows/codecov-upload-from-artifacts.yml@develop
permissions:
contents: read
checks: write # For the check run creation !
Expand Down
Loading