Skip to content

Commit

Permalink
ci: add actions to avoid duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
mascam97 committed Nov 7, 2023
1 parent 2949ec0 commit ec6acfc
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 166 deletions.
42 changes: 42 additions & 0 deletions .github/actions/app-testing/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Laravel Test Action

description: Run tests with specified group
inputs:
test-group:
description: 'Group about app (Api, ApiAdmin, Console, etc)'
required: true

runs:
using: 'composite'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug

- uses: actions/checkout@v2
with:
fetch-depth: 0

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

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Copy .env.pipeline
run: \cp -pf .env.pipeline .env

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Execute tests
run: vendor/bin/pest --testsuite=Feature --group=${{ inputs.test-group }} --coverage-clover=coverage.xml
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
33 changes: 5 additions & 28 deletions .github/workflows/default-api-admin-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,9 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug
- uses: actions/checkout@v2

- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.pipeline', '.env');"

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Copy .env.pipeline
run: \cp -pf .env.pipeline .env

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Execute tests
run: vendor/bin/pest --testsuite=Feature --group=ApiAdmin --coverage-clover=coverage.xml
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Execute tests
uses: actions/app-testing
with:
test-group: 'ApiAdmin'
33 changes: 5 additions & 28 deletions .github/workflows/default-api-analytics-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,9 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug
- uses: actions/checkout@v2

- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.pipeline', '.env');"

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Copy .env.pipeline
run: \cp -pf .env.pipeline .env

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Execute tests
run: vendor/bin/pest --testsuite=Feature --group=ApiAnalytics --coverage-clover=coverage.xml
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Execute tests
uses: actions/app-testing@v1
with:
test-group: 'ApiAnalytics'
33 changes: 5 additions & 28 deletions .github/workflows/default-api-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,9 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug
- uses: actions/checkout@2

- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.pipeline', '.env');"

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Copy .env.pipeline
run: \cp -pf .env.pipeline .env

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Execute tests
run: vendor/bin/pest --testsuite=Feature --group=Api --coverage-clover=coverage.xml
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Execute tests
uses: actions/app-testing@v1
with:
test-group: 'Api'
32 changes: 5 additions & 27 deletions .github/workflows/default-console-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,10 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug
- uses: actions/checkout@v2

- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.pipeline', '.env');"
- name: Execute tests
uses: /.github/actions/app-testing
with:
test-group: 'Console'

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Copy .env.pipeline
run: \cp -pf .env.pipeline .env

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Execute tests
run: vendor/bin/pest --testsuite=Feature --group=Console --coverage-clover=coverage.xml
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
33 changes: 5 additions & 28 deletions .github/workflows/default-external-api-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,9 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug
- uses: actions/checkout@v2

- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.pipeline', '.env');"

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Copy .env.pipeline
run: \cp -pf .env.pipeline .env

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Execute tests
run: vendor/bin/pest --testsuite=Feature --group=ExternalApi --coverage-clover=coverage.xml
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Execute tests
uses: .github/actions/app-testing
with:
test-group: 'ExternalApi'
34 changes: 7 additions & 27 deletions .github/workflows/default-web-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,12 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.pipeline', '.env');"
- name: Execute tests
uses: ./.github/actions/app-testing
with:
test-group: 'Web'

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Copy .env.pipeline
run: \cp -pf .env.pipeline .env

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Execute tests
run: vendor/bin/pest --testsuite=Feature --group=Web --coverage-clover=coverage.xml
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

0 comments on commit ec6acfc

Please sign in to comment.