Skip to content

Move invoice script into x-init, increase check interval #1881

Move invoice script into x-init, increase check interval

Move invoice script into x-init, increase check interval #1881

Workflow file for this run

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.3'
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: sqlite
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: vendor/bin/pest --testdox > test-summary.txt
- name: Upload Test Result to artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: test-summary
path: 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 prNumber = context.issue.number;
let message = '';
// Read the test summary file if it exists
if (fs.existsSync('test-summary.txt')) {
const testSummary = fs.readFileSync('test-summary.txt', { encoding: 'utf8' });
const testSummaryLines = testSummary.split('\n');
// Initialize an array to hold our formatted failing test lines
const failingTests = [];
let captureTrace = false;
let currentTest = [];
let passingTests = 0;
// Iterate over each line of the test summary
for (const line of testSummaryLines) {
// Check if the line is a file path and reset capture if we hit a new file
if (line.startsWith('/home/runner/work/')) {
captureTrace = false;
if (currentTest.length > 0) {
failingTests.push(currentTest.join('\n'));
currentTest = [];
}
}
// If the line indicates a failing test, start capturing
if (line.startsWith(' ✘')) {
captureTrace = true;
currentTest.push(line);
continue;
}
// If the line indicates a passing test, increment the counter
if (line.startsWith(' ✔')) {
passingTests++;
continue;
}
// If capturing, add the stack trace lines
if (captureTrace) {
if (line.trim() === '') {
// Empty line might signal the end of the stack trace
captureTrace = false;
failingTests.push(currentTest.join('\n'));
currentTest = [];
} else {
// Continue capturing the stack trace
currentTest.push(line);
}
}
}
// Check if there's a leftover test case at the end of the file
if (currentTest.length > 0) {
failingTests.push(currentTest.join('\n'));
}
if (failingTests.length > 0) {
// Join the failing tests with two new lines and wrap in a code block for markdown
message = `❌ Tests failed. Below are the details:\n\`\`\`\n${failingTests.join('\n\n')}\n\`\`\``;
} else if (passingTests > 0) {
message = '';
} else {
message = "⚠️ Error running tests. Logs:\n```\n" + testSummary + "\n```";
}
} else {
message = "⚠️ No test summary file found.";
}
if (message) {
core.setFailed(message);
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}