-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from laracasts/composite-actions
Composite actions
- Loading branch information
Showing
9 changed files
with
140 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Setup Tooling | ||
|
||
description: Sets up PHP with and Composer with caching. | ||
|
||
inputs: | ||
php-version: | ||
description: The version(s) of PHP you want to configure. | ||
required: false | ||
default: '8.3' | ||
php-extensions: | ||
description: The PHP extensions to install. | ||
required: false | ||
default: dom, curl, libxml, mbstring, zip, pcntl, pdo, gd, redis, igbinary, msgpack, lzf, zstd, lz4, memcached, gmp, :php-psr | ||
php-tools: | ||
description: Any tools you want to include with PHP | ||
required: false | ||
default: composer:v2 | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Get extension cache hash | ||
id: extension-cache-hash | ||
env: | ||
PHP_EXTENSIONS: ${{ inputs.php-extensions }} | ||
run: echo hash=$(echo $PHP_EXTENSIONS | md5sum) >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Setup cache environment | ||
id: extcache | ||
uses: shivammathur/cache-extensions@v1 | ||
with: | ||
php-version: ${{ inputs.php-version }} | ||
extensions: ${{ inputs.php-extensions }} | ||
key: php-extensions-${{ steps.extension-cache-hash.outputs.hash }} | ||
|
||
- name: Cache extensions | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.extcache.outputs.dir }} | ||
key: ${{ steps.extcache.outputs.key }} | ||
restore-keys: ${{ steps.extcache.outputs.key }} | ||
|
||
- name: Setup PHP and Composer | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ inputs.php-version }} | ||
extensions: ${{ inputs.php-extensions }} | ||
tools: ${{ inputs.php-tools }} | ||
|
||
- name: Get Composer cache dir | ||
id: composer-cache-dir | ||
run: echo dir=$(composer config cache-files-dir) >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v4.0.2 | ||
with: | ||
key: composer-cache-${{ hashFiles('**/composer.lock') }} | ||
path: ${{ steps.composer-cache-dir.outputs.dir }} | ||
restore-keys: composer-cache- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,44 @@ | ||
name: Tests | ||
name: Run Tests | ||
|
||
on: | ||
pull_request | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
run-tests: | ||
tests: | ||
runs-on: ubuntu-latest | ||
env: | ||
DB_NAME: tests | ||
|
||
services: | ||
redis: | ||
image: redis:7.4 | ||
ports: | ||
- 6379:6379 | ||
mysql: | ||
image: mysql:8.0 | ||
ports: | ||
- 3306:3306 | ||
env: | ||
MYSQL_DATABASE: laravel | ||
MYSQL_ALLOW_EMPTY_PASSWORD: yes | ||
MYSQL_DATABASE: ${{ env.DB_NAME }} | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4.1.7 | ||
|
||
- name: Setup PHP and Composer | ||
uses: shivammathur/setup-php@v2 | ||
- name: Setup tooling | ||
uses: ./.github/actions/setup-tooling | ||
with: | ||
php-version: '8.3' | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, igbinary, msgpack, lzf, zstd, lz4, memcached, gmp, :php-psr | ||
tools: composer:v2 | ||
|
||
- name: Install Dependencies | ||
run: composer install -q --no-interaction | ||
- name: Install Project Dependencies | ||
run: composer install -q --no-interaction --no-progress | ||
|
||
- name: Copy Environment File | ||
run: cp .env.example .env | ||
|
||
- name: Prep Application | ||
run: | | ||
cp .env.example .env | ||
php artisan key:generate | ||
- name: Generate Application Key | ||
run: php artisan key:generate | ||
|
||
- name: Run Tests | ||
env: | ||
DB_CONNECTION: mysql | ||
DB_DATABASE: ${{ env.DB_NAME }} | ||
DB_USERNAME: root | ||
run: php artisan test --compact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use App\Models\User; | ||
use Illuminate\Support\Facades\Redis; | ||
|
||
it('increments the page count for each visit', function () { | ||
Redis::del('landing-page-views'); | ||
|
||
$this->get('/'); | ||
$this->get('/'); | ||
$this->get('/'); | ||
|
||
expect(Redis::get('landing-page-views'))->toEqual(3); | ||
}); | ||
|
||
it('provides users in random paginated order', function () { | ||
$users = User::factory(4)->create(); | ||
|
||
$users = collect($this->get('/')->viewData('users')->items()) | ||
->merge($this->get('/?page=2')->viewData('users')->items()); | ||
|
||
expect($users->count())->toBe($users->unique('id')->count()); | ||
})->repeat(3); |