Skip to content

Commit

Permalink
👷 Separate workflow actions
Browse files Browse the repository at this point in the history
  • Loading branch information
siguici committed Nov 7, 2023
1 parent 18dc9fa commit b399f3d
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 41 deletions.
91 changes: 50 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,50 @@ permissions:
on: ['push', 'pull_request']

jobs:
ci:
build:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
bun: [1.0]
experimental: [false]
name: 🍱 Build assets using Bun-${{ matrix.bun }} on ${{ matrix.os }}

steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4

- name: 🎉 Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ matrix.bun }}

- name: ✨ Install JavaScript dependencies
run: bun install

- name: ✅ Check code style
run: bun check

- name: 🧪 Test components
run: bun run test

- name: 📦️ Compile assets
run: bun run build

serve:
needs: build
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.1, 8.2]
bun: [1.0.9]
dependencies: [lowest, highest]
experimental: [false]
name: 👷 CI PHP-${{ matrix.php }} ${{ matrix.dependencies }} with Bun-${{ matrix.bun }} on ${{ matrix.os }}
name: 🌍 Serve with PHP-${{ matrix.php }} ${{ matrix.dependencies }} on ${{ matrix.os }}

steps:
- name: 🚚 Get latest code
Expand All @@ -34,7 +66,7 @@ jobs:
restore-keys: |
${{ runner.os }}-dependencies-php-${{ matrix.php }}-composer-
- name: ⚡️ Setup PHP
- name: 🎉 Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
Expand All @@ -43,69 +75,46 @@ jobs:
tools: composer:v2, php-cs-fixer, phpunit, vimeo/psalm
coverage: pcov

- name: Install Composer dependencies
- name: Install PHP dependencies
run: |
composer install -q --no-ansi --no-cache --no-interaction --no-scripts --no-progress --prefer-dist
composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist
- name: Set CI Environment
- name: 🔧 Configure environment
run: |
cp .env.example .env.ci
set -e
sed -i "s|^\(APP_ENV=\s*\).*$|\1ci|" .env.ci
printf "The complete `.env.ci` ... \n\n"
cat .env.ci
- name: Generate Key
- name: 🔒️ Generate Key
run: |
set -e
php artisan key:generate --env=ci
php artisan queue:restart --env=ci
- name: Directory Permissions
- name: 🔐 Directory Permissions
run: |
chmod -R 777 storage bootstrap/cache
chmod -R 777 storage/
- name: Clear Caches
run: php artisan optimize:clear --env=ci

- name: Optimize Stuffs
- name: 🧹 Clear Caches
run: set -e && php artisan optimize:clear --env=ci

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ matrix.bun }}

- name: Install JavaScript dependencies
run: |
bun install
bun run e2e.install
- name: 🍱 Compile assets
run: bun run build

- name: 🧹 Check code lint
run: |
bun run check
composer check
- name: ✅ Check code lint
run: composer check

- name: ⚗️ Run static analysis
run: |
composer analyse
run: composer analyse

- name: ⚡️ Optimize Stuffs
run: set -e && php artisan optimize --env=ci

- name: Test features
- name: 🧪 Test features
run: |
php artisan optimize --env=ci
set -e && php artisan serve --env=ci > /dev/null 2>&1 &
bun run test
composer test
- name: 🚀 Execute end-to-end testing
run: bun run e2e

- name: 🧪 Test the whole application
run: |
composer debug
bun run debug
- name: 💚 Test the whole application
run: composer debug
87 changes: 87 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: E2E

on:
workflow_run:
workflows: ["CI"]
types:
- completed

jobs:
test:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
bun: [1.0]
php: [8.2]
dependencies: [highest]
experimental: [false]
name: 🚀 E2E testing with PHP-${{ matrix.php }} ${{ matrix.dependencies }} and Bun-${{ matrix.bun }} on ${{ matrix.os }}

steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4

- name: 🎉 Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ matrix.bun }}

- name: 🔨 Install dependencies
run: |
bun install
bun run e2e.install
- name: 📂 Cache dependencies
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
${{ runner.os }}-dependencies-php-${{ matrix.php }}-composer-
- name: ✨ Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, dom, gd, intl, mbstring, openssl, pdo, pdo_mysql, tokenizer, zip
ini-values: error_reporting=E_ALL
tools: composer:v2

- name: 🔧 Install Composer dependencies
run: |
composer install -q --no-ansi --no-cache --no-interaction --no-scripts --no-progress --prefer-dist
composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist
- name: 🧑‍💻 Configure environment
run: |
cp .env.example .env.ci
set -e
sed -i "s|^\(APP_ENV=\s*\).*$|\1ci|" .env.ci
printf "The complete `.env.ci` ... \n\n"
cat .env.ci
- name: 🔒️ Generate Key
run: |
set -e
php artisan key:generate --env=ci
php artisan queue:restart --env=ci
- name: 🔐 Directory Permissions
run: |
chmod -R 777 storage bootstrap/cache
chmod -R 777 storage/
- name: ⚡️ Optimize Stuffs
run: set -e && php artisan optimize --env=ci

- name: 📦️ Compile assets
run: bun run build

- name: 🏆 Execute end-to-end testing
run: bun e2e

0 comments on commit b399f3d

Please sign in to comment.