Skip to content

merge dev

merge dev #28

Workflow file for this run

name: test
on:
- push
- pull_request
env:
APP_URL: "http://127.0.0.1:8000"
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_USERNAME: root
DB_DATABASE: testing
DB_PASSWORD: ''
MAIL_MAILER: log
BROADCAST_DRIVER: log
QUEUE_CONNECTION: sync
TELESCOPE_ENABLED: false
jobs:
test:
#runs-on: arc-runner-set
runs-on: ubuntu-20.04
services:
mariadb:
image: mariadb:10
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: testing
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
timeout-minutes: 5
outputs:
branch: ${{ steps.extract_branch.outputs.branch }}
coverage: ${{ steps.execute_tests.outputs.coverage }}
strategy:
fail-fast: true
matrix:
php: [8.3]
steps:
- uses: actions/checkout@v4
- name: Extract branch name
id: extract_branch
run: |
TMP_PULL_HEAD_REF="${{ github.head_ref }}"
TMP_GITHUB_REF="${GITHUB_REF#refs/heads/}"
EXPORT_VALUE=""
if [ "${TMP_PULL_HEAD_REF}" != "" ]
then
EXPORT_VALUE="${TMP_PULL_HEAD_REF}"
else
EXPORT_VALUE="${TMP_GITHUB_REF}"
fi
echo "branch=${EXPORT_VALUE}" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
# env:
# runner: self-hosted
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo
coverage: xdebug
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ hashFiles('**/composer.lock') }}
- name: Install PHP Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Link storage
run: php artisan storage:link
- name: Static analysis
run: ./vendor/bin/phpstan analyse --error-format github --ansi --no-progress
- name: Code insights
run: php artisan insights -n --ansi -s --format=github-action
- name: Execute tests
id: execute_tests
run: |
XDEBUG_MODE=coverage php artisan test -p --coverage
COVERAGE="$( awk -F '[:.%]' '/Summary:/ {getline; getline; getline; print $2}' coverage.txt )"
echo "coverage=${COVERAGE}" >> $GITHUB_OUTPUT
# - uses: ravsamhq/notify-slack-action@v2
# if: always()
# with:
# status: ${{ job.status }}
# notification_title: "Workflow {workflow} - {job} {status_message}"
# footer: ""
# notify_when: "failure"
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
badge:
needs: test
#runs-on: arc-runner-set
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
ref: badges
path: badges
- name: Generate the coverage badge
uses: emibcn/badge-action@v2.0.2
with:
label: 'Code coverage'
status: ${{ needs.test.outputs.coverage }}%
color: ${{
needs.test.outputs.coverage > 90 && 'green' ||
needs.test.outputs.coverage > 80 && 'yellow' ||
needs.test.outputs.coverage > 70 && 'orange' ||
'red' }}
path: badges/coverage.svg
- name: Push badge
env:
BRANCH: ${{ needs.test.outputs.branch }}
working-directory: ./badges
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
mkdir -p "${BRANCH}"
mv coverage.svg "${BRANCH}"
git add "${BRANCH}/coverage.svg"
git commit --author "damianchojnacki <damianchojnacki@users.noreply.github.com>" -m "Add/Update badge [skip ci]" || true
git push