Skip to content

chore: remove push limitation on github actions #234

chore: remove push limitation on github actions

chore: remove push limitation on github actions #234

Workflow file for this run

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]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
jobs:
prepare:
name: Prepare
uses: feryardiant/actions/.github/workflows/configure.yml@main
secrets: inherit
tests:
name: Runs on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: prepare
env:
GIT_COMMIT_SHA: ${{ github.sha }}
GIT_BRANCH: ${{ needs.prepare.outputs.target-branch }}
outputs:
has-reports: ${{ steps.reports.outputs.has-reports }}
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ needs.prepare.outputs.composer-cache }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-suggest
- name: Run tests
run: composer test
- name: Generate reports for CodeClimate
id: reports
if: github.actor != 'dependabot[bot]' && needs.prepare.outputs.should-reports == '1'
env:
CODECLIMATE_REPORT: tests/codeclimate.${{ matrix.php }}.json
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }}
run: |
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t lcov -o $CODECLIMATE_REPORT tests/lcov.info
echo "has-reports=1" >> $GITHUB_OUTPUT
- name: Generate reports for Coveralls
if: steps.reports.outputs.has-reports == '1'
uses: coverallsapp/github-action@v2
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: php-${{ matrix.php }}
file: tests/lcov.info
parallel: true
- name: Save Coverage Reports
if: steps.reports.outputs.has-reports == '1'
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.php }}
path: tests/codeclimate.*.json
reports:
name: Reports
if: needs.tests.outputs.has-reports == '1'
uses: feryardiant/actions/.github/workflows/report.yml@main
secrets: inherit
needs: tests
with:
has-coveralls: true
has-codeclimate: true