Test PR with failing test #27
Workflow file for this run
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: Laravel | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
laravel-tests: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: ankane/pgvector:latest | |
env: | |
POSTGRES_USER: root | |
POSTGRES_PASSWORD: password | |
POSTGRES_DB: laravel_test | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e | |
with: | |
php-version: '8.1' | |
extensions: pdo_pgsql | |
- uses: actions/checkout@v3 | |
- name: Copy .env | |
run: php -r "file_exists('.env') || copy('.env.example', '.env');" | |
- name: Install Dependencies | |
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: Generate key | |
run: php artisan key:generate | |
- name: Directory Permissions | |
run: chmod -R 777 storage bootstrap/cache | |
- name: Install pgvector extension | |
run: PGPASSWORD=password psql -h localhost -U root -d laravel_test -c "CREATE EXTENSION IF NOT EXISTS vector;" | |
- name: Install Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
- name: Install Front-End Dependencies with npm ci | |
run: npm ci | |
- name: Build Front-End Assets | |
run: npm run build | |
- name: Remove node_modules | |
run: rm -rf node_modules | |
- name: Execute tests (Unit and Feature tests) via PHPUnit | |
id: test_step | |
env: | |
DB_CONNECTION: pgsql | |
DB_HOST: localhost | |
DB_PORT: 5432 | |
DB_DATABASE: laravel_test | |
DB_USERNAME: root | |
DB_PASSWORD: password | |
run: vendor/bin/pest --testdox > test-summary.txt | |
- name: Comment PR on Test Result | |
if: always() && github.event_name == 'pull_request' | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
const fs = require('fs'); | |
const testSummary = fs.existsSync('test-summary.txt') ? fs.readFileSync('test-summary.txt', { encoding: 'utf8' }) : 'No test summary file found.'; | |
const prNumber = context.issue.number; | |
const jobStatus = ${{ job.status }}; | |
let message; | |
if (jobStatus === 'success') { | |
message = "✅ Tests passed!"; | |
} else { | |
message = "❌ Tests failed. Below is the summary of the test results:\n```\n" + testSummary + "\n```"; | |
} | |
github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: prNumber, | |
body: message | |
}); | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |