Skip to content

Commit

Permalink
feat(ci): update config to use workflow from projek-xyz (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
feryardiant authored Oct 5, 2024
2 parents 2d12e21 + daf0fe7 commit 9826946
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 54 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,4 @@ on:
jobs:
publish:
name: Publish Release
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Read Changelog file
run: npx @feryardiant/read-changelog > PUBLISH.md

- name: Publish
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: PUBLISH.md
generate_release_notes: true
uses: projek-xyz/actions/.github/workflows/release.yml@main
61 changes: 23 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Tests

on:
schedule: # scheduled to run at 23.00 on Saturday (UTC), means 6.00 on Monday (WIB)
- cron: '0 23 * * 6'
pull_request:
branches: [main]
push:
Expand All @@ -12,24 +14,18 @@ concurrency:

env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }}

jobs:
configs:
name: Configure
uses: creasico/laravel-package/.github/workflows/configure.yml@main
secrets: inherit

permissions:
contents: read
pull-requests: write
prepare:
name: Prepare
uses: feryardiant/actions/.github/workflows/configure.yml@main
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}

tests:
name: Test on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: configs
outputs:
has-reports: ${{ steps.reports.outputs.has-reports }}
needs: prepare

strategy:
fail-fast: false
Expand All @@ -53,7 +49,7 @@ jobs:
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ needs.configs.outputs.composer-cache }}
path: ${{ needs.prepare.outputs.composer-cache }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-

Expand All @@ -70,40 +66,29 @@ jobs:
composer test -- --coverage
- name: Generate reports for CodeClimate
if: ${{ github.actor != 'dependabot[bot]' || needs.configs.outputs.should-reports == '1' }}
if: needs.prepare.outputs.has-codeclimate == 'true'
id: reports
env:
COVERAGE_FILE: tests/reports/clover.xml
CODECLIMATE_REPORT: ${{ github.workspace }}/tests/reports/codeclimate.${{ matrix.php }}.json
CODECLIMATE_REPORT: tests/reports/codeclimate.${{ matrix.php }}.json
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }}
run: |
if [[ -n \"$CC_TEST_REPORTER_URL\" ]]; then
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT $COVERAGE_FILE
echo "has-reports=1" >> $GITHUB_OUTPUT
fi
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT $COVERAGE_FILE
- name: Upload tests reports
uses: actions/upload-artifact@v4
if: ${{ github.actor != 'dependabot[bot]' || needs.configs.outputs.should-reports == '1' }}
if: needs.prepare.outputs.has-codeclimate == 'true'
with:
name: test-reports-${{ matrix.php }}
path: tests/reports

reports:
name: Report Test Coverages
if: ${{ github.actor != 'dependabot[bot]' && needs.tests.outputs.has-reports == '1' }}
runs-on: ubuntu-latest
needs: tests

steps:
- name: Download test reports
uses: actions/download-artifact@v4
with:
pattern: test-reports-*
merge-multiple: true

- name: Report to CodeClimate
run: |
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
./cc-test-reporter sum-coverage -o - codeclimate.*.json | ./cc-test-reporter upload-coverage --input -
name: Reports
needs: [prepare, tests]
if: needs.prepare.outputs.should-reports == '1'
uses: feryardiant/actions/.github/workflows/report.yml@main
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
has-codeclimate: ${{ needs.prepare.outputs.has-codeclimate == 'true' }}

0 comments on commit 9826946

Please sign in to comment.