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

feat(ci): update ci config to use workflow from feryardiant/actions #90

Merged
merged 1 commit into from
Oct 5, 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
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' }}