Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(tests): fix auth namespace issue #215

fix(tests): fix auth namespace issue

fix(tests): fix auth namespace issue #215

Workflow file for this run

name: Tests
on:
pull_request:
branches: [main]
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }}
jobs:
configs:
name: Prepare
uses: creasico/laravel-package/.github/workflows/configure.yml@main
secrets: inherit
permissions:
contents: read
pull-requests: write
tests:
name: Test on PHP ${{ matrix.php }} Laravel ${{ matrix.laravel }} DB ${{ matrix.db }}
runs-on: ubuntu-latest
needs: configs
outputs:
has-reports: ${{ steps.reports.outputs.has-reports }}
env:
DB_CONNECTION: ${{ matrix.db }}
DB_DATABASE: ${{ github.repository_owner }}
DB_USERNAME: ${{ github.repository_owner }}
DB_PASSWORD: 'secret'
services:
postgresql:
image: postgres:14
env:
POSTGRES_DB: ${{ env.DB_DATABASE }}
POSTGRES_USER: ${{ env.DB_USERNAME }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 5432:5432
options: >-
--health-cmd=pg_isready
--health-interval=10s
--health-timeout=5s
--health-retries=3
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }}
MYSQL_DATABASE: ${{ env.DB_DATABASE }}
MYSQL_USER: ${{ env.DB_USERNAME }}
MYSQL_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
strategy:
fail-fast: false
matrix:
db: ['mysql', 'pgsql']
laravel: ['10.x', '11.x']
php: [8.1, 8.2, 8.3]
exclude:
- php: 8.1
laravel: '11.x'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ needs.configs.outputs.composer-cache }}
key: ${{ matrix.php }}-${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ matrix.php }}-${{ matrix.laravel }}-composer-
- name: Install dependencies
run: |
composer require "laravel/framework=${{ matrix.laravel }}" --no-update
composer update --prefer-dist --no-interaction --no-progress
- name: Run tests
run: composer test -- --coverage
- name: Generate reports for CodeClimate
id: reports
if: ${{ matrix.laravel == '10.x' && ( github.actor != 'dependabot[bot]' || needs.configs.outputs.should-reports == '1' ) }}
env:
COVERAGE_FILE: tests/reports/clover.xml
CODECLIMATE_REPORT: tests/reports/codeclimate.${{ matrix.php }}.json
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
- name: Upload tests reports
uses: actions/upload-artifact@v4
if: ${{ matrix.laravel == '10.x' && ( github.actor != 'dependabot[bot]' || needs.configs.outputs.should-reports == '1' ) }}
with:
name: test-reports-${{ matrix.php }}-${{ matrix.db }}
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 -