Skip to content

Login via discord

Login via discord #55

Workflow file for this run

name: Run Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
run-tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: hms
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP 8.4
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: zip, pcntl, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, imagick, redis
coverage: xdebug
- name: Run composer install
run: composer install -n --prefer-dist
- name: Prepare Laravel Application
run: |
php artisan migrate --env=ci
php artisan key:generate --env=ci
php artisan typescript:transform --env=ci
php artisan ziggy:generate --env=ci
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- name: Execute tests
run: |
php artisan test --env=ci --coverage-clover=coverage/all/cobertura.xml
- name: Upload application
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage/all/cobertura.xml
check-coverage:
runs-on: ubuntu-latest
needs: run-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
fetch-depth: 0
- run: git fetch
- name: Download coverage
uses: actions/download-artifact@v4
with:
name: coverage
- uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies
- run: pip install diff_cover
- run: diff-cover cobertura.xml --markdown-report coverage.md --fail-under 80 --compare-branch origin/main
- name: Upload report
uses: actions/upload-artifact@v4
with:
name: coverage_report
path: coverage.md
comment-coverage:
runs-on: ubuntu-latest
needs: check-coverage
if: ${{ github.event.pull_request.number }}
permissions:
pull-requests: write
steps:
- name: Download report
uses: actions/download-artifact@v4
with:
name: coverage_report
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Diff Coverage
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: coverage.md
edit-mode: replace
# cleanup-artifacts-pr:
# runs-on: ubuntu-latest
# if: github.event.pull_request.number != null
# needs: [ run-tests, check-coverage, comment-coverage ]
# steps:
# - uses: geekyeggo/delete-artifact@v5
# with:
# name: |
# app_files
# coverage
# coverage_report
#
# cleanup-artifacts-branch:
# runs-on: ubuntu-latest
# if: github.event.pull_request.number == null
# needs: [ run-tests, check-coverage ]
# steps:
# - uses: geekyeggo/delete-artifact@v5
# with:
# name: |
# app_files
# coverage
# coverage_report