From 4fea1f07ba466ed3ab6685f525c7a04637cf0899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SIGUI=20Kess=C3=A9=20Emmanuel?= Date: Tue, 21 Nov 2023 17:16:14 +0100 Subject: [PATCH] :green_heart: Streamline Tests Workflow (#4) 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. --- .github/workflows/{ci.yml => Tests.yml} | 104 ++++++++++-------------- .github/workflows/cd.yml | 87 -------------------- README.md | 6 +- 3 files changed, 45 insertions(+), 152 deletions(-) rename .github/workflows/{ci.yml => Tests.yml} (61%) delete mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/Tests.yml similarity index 61% rename from .github/workflows/ci.yml rename to .github/workflows/Tests.yml index 96e052c..571a246 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/Tests.yml @@ -1,4 +1,4 @@ -name: CI +name: Tests permissions: contents: read @@ -6,7 +6,7 @@ permissions: on: ['push', 'pull_request'] jobs: - build: + tests: runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} strategy: @@ -14,8 +14,10 @@ jobs: 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 @@ -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 @@ -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 }} @@ -81,24 +53,30 @@ 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: | @@ -106,30 +84,36 @@ jobs: 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 diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index cd3c0c7..0000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: CD - -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: ๐Ÿš€ Deploy 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 diff --git a/README.md b/README.md index cfb458b..74c38e5 100644 --- a/README.md +++ b/README.md @@ -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] @@ -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