From daf0fe770f9bdf91a58b06af58577537a1a29808 Mon Sep 17 00:00:00 2001 From: Fery Wardiyanto Date: Sat, 5 Oct 2024 01:58:13 +0700 Subject: [PATCH] chore(ci): update ci config to use workflow from `feryardiant/actions` Signed-off-by: Fery Wardiyanto --- .github/workflows/release.yml | 17 +--------- .github/workflows/test.yml | 61 +++++++++++++---------------------- 2 files changed, 24 insertions(+), 54 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 19a173f..385992b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4cb0715..b5678fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: @@ -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 @@ -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- @@ -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' }}