Laravel 11 #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deps & Tests | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Validate composer.json and composer.lock | |
run: composer validate --strict | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress | |
- name: Run phpstan | |
id: PHPStan | |
run: composer run-script phpstan | |
- name: Run test suite | |
id: PHPUnit | |
run: composer run-script phpunit-cov -- --coverage-clover=coverage.xml | |
- name: Check test coverage | |
uses: johanvanhelden/gha-clover-test-coverage-check@v1 | |
id: coverage | |
with: | |
percentage: "90" | |
filename: "coverage.xml" | |
# Use the output from the `coverage` step | |
- name: Generate the badge SVG image | |
uses: emibcn/badge-action@v1 | |
id: badge | |
with: | |
label: 'PHPUnit Coverage' | |
status: ${{ steps.coverage.outputs.coverage-rounded-display }} | |
path: ./test-coverage.svg | |
color: ${{ | |
steps.coverage.outputs.coverage > 90 && 'green' || | |
steps.coverage.outputs.coverage > 80 && 'yellow,green' || | |
steps.coverage.outputs.coverage > 70 && 'yellow' || | |
steps.coverage.outputs.coverage > 60 && 'orange,yellow' || | |
steps.coverage.outputs.coverage > 50 && 'orange' || | |
steps.coverage.outputs.coverage > 40 && 'red,orange' || | |
steps.coverage.outputs.coverage > 30 && 'red,red,orange' || | |
steps.coverage.outputs.coverage > 20 && 'red,red,red,orange' || | |
'red' }} | |
- name: Update gist | |
uses: sergeysova/jq-action@v2 | |
id: gist | |
with: | |
cmd: | | |
jq --null-input '{description: $description, public: true, files:{"badge.svg": {content: $file}}}' \ | |
--arg description "Badge from coverage testing" \ | |
--rawfile file test-coverage.svg | curl \ | |
-X PATCH \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GIST_API_TOKEN }}" \ | |
https://api.github.com/gists/a143261dcd5d0d9456c01f854eccecd0 \ | |
--data @- |