Skip to content

Commit

Permalink
feat(ci): update ci config to use workflow from feryardiant/actions (
Browse files Browse the repository at this point in the history
  • Loading branch information
feryardiant authored Oct 5, 2024
2 parents 5685528 + 546aa6c commit 612ce59
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 53 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: feryardiant/actions/.github/workflows/release.yml@main
58 changes: 21 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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:
branches: [main]
# paths: ['.github/**.yml', 'src/*', 'tests/*']

env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }}
DB_USERNAME: ${{ github.repository_owner }}
DB_PASSWORD: secret

Expand All @@ -20,12 +20,9 @@ concurrency:
jobs:
configs:
name: Configure
uses: creasico/laravel-package/.github/workflows/configure.yml@main
secrets: inherit

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

prepare:
name: Prepare Database
Expand Down Expand Up @@ -60,7 +57,6 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: xdebug

Expand All @@ -81,8 +77,6 @@ jobs:
name: Test on PHP ${{ matrix.php }} Laravel ${{ matrix.laravel }} DB ${{ matrix.db }}
needs: [configs, prepare]
runs-on: ubuntu-latest
outputs:
has-reports: ${{ steps.reports.outputs.has-reports }}
env:
DB_CONNECTION: ${{ matrix.db }}
DB_DATABASE: ${{ github.repository_owner }}
Expand Down Expand Up @@ -164,39 +158,29 @@ jobs:

- name: Generate reports for CodeClimate
id: reports
if: ${{ matrix.db == 'pgsql' && ( github.actor != 'dependabot[bot]' || needs.configs.outputs.should-reports == '1' ) }}
if: needs.configs.outputs.has-codeclimate == 'true'
env:
COVERAGE_FILE: tests/reports/clover.xml
CODECLIMATE_REPORT: tests/reports/codeclimate.${{ matrix.php }}-L${{ matrix.laravel }}.json
CODECLIMATE_REPORT: tests/reports/codeclimate.PHP${{ matrix.php }}-L${{ matrix.laravel }}-${{ matrix.db }}.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 tests/reports/clover.xml
- name: Upload tests reports
uses: actions/upload-artifact@v4
if: ${{ steps.reports.outputs.has-reports == '1' }}
if: needs.configs.outputs.has-codeclimate == 'true'
with:
name: cc-reports-${{ matrix.php }}-L${{ matrix.laravel }}
path: tests/reports/codeclimate.${{ matrix.php }}-L${{ matrix.laravel }}.json
name: test-reports-PHP${{ matrix.php }}-L${{ matrix.laravel }}-${{ matrix.db }}
path: tests/reports/codeclimate.PHP${{ matrix.php }}-L${{ matrix.laravel }}-${{ matrix.db }}.json

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: cc-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 -
needs: [configs, tests]
if: needs.configs.outputs.should-reports == '1'
uses: feryardiant/actions/.github/workflows/report.yml@main
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
has-coveralls: ${{ needs.configs.outputs.has-coveralls == 'true' }}
has-codeclimate: ${{ needs.configs.outputs.has-codeclimate == 'true' }}

0 comments on commit 612ce59

Please sign in to comment.