Skip to content

Commit

Permalink
Fix Github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophist-UK committed Jan 3, 2025
1 parent 83211a4 commit af6789f
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 53 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/codecov.txt

This file was deleted.

77 changes: 77 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Codecov

on:
push:
branches: [ "main" ]
paths:
- 'src/**.php'
- '.github/workflows/codecov.yml'
pull_request:
branches: [ "main" ]
paths:
- 'src/**.php'
- '.github/workflows/codecov.yml'

defaults:
run:
working-directory: src

concurrency:
group: "${{ github.workflow_ref }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
codecov:
strategy:
matrix:
php-version: [8.3]
os: [ubuntu-latest]
runs-on: {{ matrix.os }}

steps:
- uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401
with:
php-version: ${{ matrix.php-version }}

- name: Checkout
- uses: actions/checkout@v4

- name: Get Composer cache directory
id: composer-cache
run: |
composer validate --strict
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/[email protected]
with:
path: |
${{ steps.composer-cache.outputs.dir }}
src/vendor
src/node_modules
key: vl-${{ matrix.os }}-php${{ matrix.php-version }}-${{ hashFiles('composer.json', 'composer.lock', 'package.json', 'package.lock') }}

- name: Prepare Env.
run: |
# Copy .env, Generate key, Set directory permissions, Create empty SQLite DB
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
chmod -R 777 storage storage/database bootstrap/cache
mkdir -p storage/database
rm -f storage/database/visual-laravel.sqlite
touch storage/database/visual-laravel.sqlite
- name: Install Dependencies
run: |
composer self-update && composer install --no-interaction --no-progress --prefer-dist
npm run build
- name: Run coverage tests
env:
DB_CONNECTION: sqlite
run: vendor/bin/phpunit --coverage-clover coverage.xml .

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
102 changes: 63 additions & 39 deletions .github/workflows/laravel-tests.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,72 @@
name: Laravel-Tests
name: Run Tests

on:
push:
branches: [ "main" ]
paths:
- 'src/**.php'
- '.github/workflows/laravel-tests.yml'
pull_request:
branches: [ "main" ]
paths:
- 'src/**.php'
- '.github/workflows/laravel-tests.yml'

defaults:
run:
working-directory: src

concurrency:
group: "${{ github.workflow_ref }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
laravel-tests:
runs-on: ubuntu-latest
tests:
strategy:
matrix:
php-version: [8.2, 8.3, 8.4]
os: [ubuntu-latest]
runs-on: {{ matrix.os }}

steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.3'

- name: Checkout
- uses: actions/checkout@v4

- name: Cache composer and npm
uses: actions/[email protected]
with:
path: |
vendor
node_modules
key: vl-${{ runner.os }}-${{ hashFiles('composer.json', 'composer.lock', 'package.json', 'package.lock') }}

- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"

- name: Install Dependencies
run: composer install -q --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: Create empty database
run: |
mkdir -p storage
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via PHPUnit/Pest
env:
DB_CONNECTION: sqlite
DB_DATABASE: storage/database/tests.sqlite
run: php artisan test
- uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401
with:
php-version: ${{ matrix.php-version }}

- name: Checkout
- uses: actions/checkout@v4

- name: Get Composer cache directory
id: composer-cache
run: |
composer validate --strict
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/[email protected]
with:
path: |
${{ steps.composer-cache.outputs.dir }}
src/vendor
src/node_modules
key: vl-${{ matrix.os }}-php${{ matrix.php-version }}-${{ hashFiles('composer.json', 'composer.lock', 'package.json', 'package.lock') }}

- name: Prepare Env.
run: |
# Copy .env, Generate key, Set directory permissions, Create empty SQLite DB
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
chmod -R 777 storage storage/database bootstrap/cache
mkdir -p storage/database
rm -f storage/database/visual-laravel.sqlite
touch storage/database/visual-laravel.sqlite
- name: Install Dependencies
run: |
composer self-update && composer install --no-interaction --no-progress --prefer-dist
npm run build
- name: Run PHPUnit/Pest tests
env:
DB_CONNECTION: sqlite
run: php artisan test
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.fleet
/.idea
/.nova
/.vscode
/.zed
3 changes: 3 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ yarn-error.log
/.nova
/.vscode
/.zed

/composer.lock
/package-lock.json
10 changes: 7 additions & 3 deletions src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"keywords": [
"laravel",
"livewire",
"filament"
"filament",
"nocode",
"no-code",
"low-code",
"lowcode"
],
"license": "AGPL",
"require": {
Expand Down Expand Up @@ -66,7 +70,7 @@
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php -r \"file_exists('storage/database/laravel.sqlite') || touch('storage/database/laravel.sqlite');\"",
"@php artisan migrate --graceful --ansi"
],
"dev": [
Expand All @@ -75,7 +79,7 @@
],
"bun": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"bun --watch run dev\" --names=server,queue,logs,vite"
"bun concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"bun --watch run dev\" --names=server,queue,logs,vite"
],
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
Expand Down
1 change: 1 addition & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dev": "vite"
},
"devDependencies": {
"@codecov/vite-plugin": "^1.7.0",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"autoprefixer": "^10.4.16",
Expand Down
21 changes: 14 additions & 7 deletions src/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { defineConfig } from 'vite'
import { codecovVitePlugin } from "@codecov/vite-plugin";
import laravel, { refreshPaths } from 'laravel-vite-plugin'

export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
input: ['VisualLaravel/Core/resources/css/app.css', 'VisualLaravel/Core/resources/js/app.js'],
refresh: [
...refreshPaths,
'VisualLaravel/core/Filament/**',
'VisualLaravel/core/Forms/Components/**',
'VisualLaravel/core/Livewire/**',
'VisualLaravel/core/Infolists/Components/**',
'VisualLaravel/core/Providers/Filament/**',
'VisualLaravel/core/Tables/Columns/**',
'VisualLaravel/Base/Filament/**',
'VisualLaravel/Base/Providers/Filament/**',
'VisualLaravel/Core/Forms/Components/**',
'VisualLaravel/Core/Livewire/**',
'VisualLaravel/Core/Infolists/Components/**',
'VisualLaravel/Core/Tables/Columns/**',
],
}),
// Put the Codecov vite plugin after all other plugins
codecovVitePlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: "Visual-Laravel-Vite-Bundle",
uploadToken: process.env.CODECOV_TOKEN,
}),
],
})

0 comments on commit af6789f

Please sign in to comment.