Skip to content

Commit 8bcd7ac

Browse files
authored
Refactor CI for fork PR (#32)
1 parent 1ab96ba commit 8bcd7ac

File tree

2 files changed

+41
-69
lines changed

2 files changed

+41
-69
lines changed

.github/workflows/CI.yml

Lines changed: 37 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: 'CI'
2+
23
on: # Build any PRs and main branch changes
34
workflow_dispatch: # Allows to run the workflow manually from the Actions tab
45
pull_request:
56
types:
67
- opened
7-
- edited
88
- synchronize
99
push:
1010
branches: [ master ]
@@ -18,8 +18,6 @@ concurrency:
1818
env:
1919
TEST_OUTPUT_STYLE: pretty
2020
COMPOSER_OPTIONS: --optimize-autoloader
21-
CODACY_CACHE_PATH: ~/.cache/codacy
22-
CODACY_BIN: ~/.cache/codacy/codacy.sh
2321

2422
jobs:
2523
tests:
@@ -65,13 +63,13 @@ jobs:
6563
6664
- name: Setup PHP ${{ matrix.php-version }}
6765
uses: shivammathur/setup-php@v2
66+
env:
67+
update: true # Always use latest available patch for the version
68+
fail-fast: true # step will fail if an extension or tool fails to set up
6869
with:
6970
php-version: '${{ matrix.php-version }}'
7071
tools: composer
7172
coverage: ${{ env.COVERAGE_TYPE }}
72-
env:
73-
# Always use latest available patch for the version
74-
update: true
7573

7674
- name: Setup cache
7775
id: cache
@@ -80,18 +78,9 @@ jobs:
8078
path: |
8179
~/.composer
8280
./vendor
83-
${{ env.CODACY_CACHE_PATH }}
8481
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
8582
key: tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }}
8683

87-
- name: Download codacy binary
88-
if: steps.cache.outputs.cache-hit != 'true'
89-
run: |
90-
mkdir -p ${{ env.CODACY_CACHE_PATH }} \
91-
&& curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \
92-
&& chmod +x ${{ env.CODACY_BIN }} \
93-
&& ${{ env.CODACY_BIN }} download
94-
9584
- name: Build
9685
run: |
9786
SF_VERSION=${{ matrix.symfony-version }}
@@ -110,34 +99,43 @@ jobs:
11099
- name: Tests
111100
run: make test-unit && make test-functional
112101

113-
# Upload to codacy first as codecov action always remove coverage files despite move_coverage_to_trash at false
114-
# And only if it's not a PR from a fork => Can't work as codacy secret is not accessible in that context
115-
- name: Upload coverages to Codacy
116-
if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/symfony-jsonrpc-params-validator') && env.COVERAGE_TYPE == 'xdebug' }}
117-
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
118-
119-
# See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-params-validator
120-
- name: Upload unit tests coverage to codecov
102+
- name: Create "unit tests" reports group
121103
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
122-
uses: codecov/codecov-action@v3
104+
id: unit-tests-coverage-group
105+
uses: yoanm/temp-reports-group-workspace/.github/actions/create-action@develop
123106
with:
124-
file: "build/coverage-phpunit/unit.clover"
125-
name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}"
126-
flags: "unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}"
127-
fail_ci_if_error: true
128-
move_coverage_to_trash: false
129-
verbose: ${{ runner.debug == '1' }}
130-
131-
- name: Upload functional tests coverage to codecov
107+
name: unit-tests
108+
format: clover
109+
files: build/coverage-phpunit/unit.clover
110+
flags: |
111+
unit-tests
112+
php-${{ matrix.php-version }}
113+
sf-${{ matrix.symfony-version }}
114+
path: build/coverage-groups
115+
116+
- name: Create "functional tests" coverage group
117+
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
118+
id: functional-tests-coverage-group
119+
uses: yoanm/temp-reports-group-workspace/.github/actions/create-action@develop
120+
with:
121+
name: functional-tests
122+
format: clover
123+
files: |
124+
build/coverage-phpunit/functional.clover
125+
build/coverage-behat/clover.xml
126+
flags: |
127+
functional-tests
128+
php-${{ matrix.php-version }}
129+
sf-${{ matrix.symfony-version }}
130+
path: build/coverage-groups
131+
132+
- name: Upload coverage reports
132133
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
133-
uses: codecov/codecov-action@v3
134+
uses: actions/upload-artifact@v4
134135
with:
135-
files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover"
136-
name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}"
137-
flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}"
138-
fail_ci_if_error: true
139-
move_coverage_to_trash: false
140-
verbose: ${{ runner.debug == '1' }}
136+
name: coverage-groups-php${{ matrix.php-version }}-sf${{ matrix.symfony-version }}
137+
path: build/coverage-groups
138+
if-no-files-found: error
141139

142140
static-checks:
143141
name: Static checks
@@ -174,31 +172,6 @@ jobs:
174172
if: ${{ github.event_name == 'pull_request' }}
175173
uses: actions/dependency-review-action@v1
176174

177-
finalize-codacy-coverage-report:
178-
runs-on: ubuntu-latest
179-
name: Finalize Codacy coverage report
180-
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/symfony-jsonrpc-params-validator' }}
181-
needs: [ tests ]
182-
steps:
183-
- name: Setup cache
184-
id: cache
185-
uses: actions/cache@v3
186-
with:
187-
path: |
188-
${{ env.CODACY_CACHE_PATH }}
189-
key: codacy-final
190-
191-
- name: Download codacy binary
192-
if: steps.cache.outputs.cache-hit != 'true'
193-
run: |
194-
mkdir -p ${{ env.CODACY_CACHE_PATH }} \
195-
&& curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \
196-
&& chmod +x ${{ env.CODACY_BIN }} \
197-
&& ${{ env.CODACY_BIN }} download
198-
199-
- name: Finalize reporting
200-
run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }}
201-
202175
nightly-tests:
203176
name: Nightly - Symfony ${{ matrix.symfony-version }}
204177
runs-on: ubuntu-latest

.github/workflows/coverage-upload.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
checks: write # For the check run creation !
1414
steps:
1515
- name: 'Check run ○'
16-
uses: yoanm/tmp-reports-group-workspace/.github/actions/attach-check-run-to-triggering-workflow-action@develop
16+
uses: yoanm/temp-reports-group-workspace/.github/actions/attach-check-run-to-triggering-workflow-action@develop
1717
with:
1818
name: 'Fetch coverage info'
1919
fails-on-triggering-workflow-failure: true
2020

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

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

4241
codecov-uploader:
4342
name: Codecov
4443
needs: [fetch-info]
45-
uses: yoanm/tmp-reports-group-workspace/.github/workflows/codecov-upload-from-artifacts.yml@develop
44+
uses: yoanm/temp-reports-group-workspace/.github/workflows/codecov-upload-from-artifacts.yml@develop
4645
permissions:
4746
contents: read
4847
checks: write # For the check run creation !

0 commit comments

Comments
 (0)