Skip to content

Commit

Permalink
💚 Streamline Tests Workflow (#4)
Browse files Browse the repository at this point in the history
After reassessing the project's deployment status and considering the current phase where the kit is not yet deployed, I've decided to consolidate both frontend and backend tests into a single workflow. This simplification enhances the testing process, promoting efficiency and simplicity. Future adjustments can be made as deployment considerations become relevant.
  • Loading branch information
siguici committed Nov 21, 2023
1 parent 79a02c3 commit 4fea1f0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 152 deletions.
104 changes: 44 additions & 60 deletions .github/workflows/ci.yml → .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
name: CI
name: Tests

permissions:
contents: read

on: ['push', 'pull_request']

jobs:
build:
tests:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
bun: [1.0]
php: [8.1, 8.2]
dependencies: [lowest, highest]
experimental: [false]
name: 🍱 Build assets using Bun-${{ matrix.bun }} on ${{ matrix.os }}
name: 👷 Test on PHP-${{ matrix.php }} ${{ matrix.dependencies }} and Bun-${{ matrix.bun }} under ${{ matrix.os }}

steps:
- name: 🚚 Get latest code
Expand All @@ -27,41 +29,11 @@ jobs:
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

- name: 🚚 Upload distribution files
uses: actions/upload-artifact@v3
with:
name: dist-files
path: public/static

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]
dependencies: [lowest, highest]
experimental: [false]
name: 🌍 Serve with PHP-${{ matrix.php }} ${{ matrix.dependencies }} on ${{ matrix.os }}

steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4
run: |
bun install
bun run e2e.install
- name: 📂 Cache dependencies
- name: ⚡️ Cache dependencies
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
Expand All @@ -72,7 +44,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 @@ -81,55 +53,67 @@ jobs:
tools: composer:v2, php-cs-fixer, phpunit, vimeo/psalm
coverage: pcov

- name: Install PHP 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: 🔧 Configure environment
- name: 🧑‍💻 Configure environment
run: |
cp .env.example .env.test
set -e
sed -i "s|^\(APP_ENV=\s*\).*$|\1test|" .env.test
printf "The complete `.env.test` ... \n\n"
cat .env.test
- name: 📦️ Allow executables
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
chmod +x ./run
chmod +x ./artisan
- name: 🔒️ Generate Key
run: |
set -e
php artisan key:generate --env=ci
php artisan queue:restart --env=ci
./run key:generate --env=test
./run queue:restart --env=test
- name: 🔐 Directory Permissions
run: |
chmod -R 777 storage bootstrap/cache
chmod -R 777 storage/
- name: 🧹 Clear Caches
run: set -e && php artisan optimize:clear --env=ci
run: set -e && ./run optimize:clear --env=test

- name: ✅ Check code lint
run: composer check
- name: ✅ Check code style
run: bun check

- name: ⚗️ Run static analysis
run: composer analyse
- name: 🧪 Test components
run: bun run test

- name: 🍱 Compile assets
run: bun run build

- name: 📂 List distribution folder
run: ls public/static

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

- name: 🚚 Download distribution files
uses: actions/download-artifact@v3
with:
name: dist-files
path: public/static
- name: ✅ Check code lint
run: composer check

- name: 📂 List public/
run: ls public/static
- name: ⚗️ Run static analysis
run: composer analyse

- name: 🧪 Test features
run: |
set -e && php artisan serve --env=ci > /dev/null 2>&1 &
set -e && ./run serve --env=test > /dev/null 2>&1 &
composer test
- name: 💚 Test the whole application
run: composer debug

- name: 🚀 Execute end-to-end testing
run: bun e2e
87 changes: 0 additions & 87 deletions .github/workflows/cd.yml

This file was deleted.

6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
[![packagist-version-icon]][packagist-version-link]
[![packagist-download-icon]][packagist-download-link]
[![license-icon]][license-link]
[![enabled-icon]][enabled-link]
[![actions-icon]][actions-link]
[![pr-icon]][pr-link]
[![twitter-icon]][twitter-link]
Expand Down Expand Up @@ -220,10 +219,7 @@ The Sikessem Starter is open-sourced software licensed under the [MIT License](
[packagist-download-icon]: https://img.shields.io/packagist/dt/sikessem/starter
[packagist-download-link]: https://packagist.org/packages/sikessem/starter "Starter Downloads"

[enabled-icon]: https://img.shields.io/badge/Starter-enabled-brightgreen.svg?style=flat
[enabled-link]: https://github.com/sikessem/starter "Starter enabled"

[actions-icon]: https://github.com/sikessem/starter/workflows/CI/badge.svg
[actions-icon]: https://github.com/sikessem/starter/workflows/Tests/badge.svg
[actions-link]: https://github.com/sikessem/starter/actions "Starter status"

[pr-icon]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?color=brightgreen
Expand Down

0 comments on commit 4fea1f0

Please sign in to comment.