Skip to content

Commit

Permalink
Add code-covarage-decrease and database jobs.
Browse files Browse the repository at this point in the history
  • Loading branch information
DvDty committed Jan 28, 2024
1 parent 87a4599 commit 2200ac7
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 4 deletions.
103 changes: 99 additions & 4 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
# working-directory: ./application
# run: php artisan test

static-analysis:
code-covarage-decrease:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -118,15 +118,51 @@ jobs:
with:
php-version: 8.3
tools: composer:v2
coverage: none
coverage: xdebug

- name: Install Project Dependencies
working-directory: ./application
run: composer install

- name: Run static analyser
- name: Framework configuration
working-directory: ./application
run: |
cp .env.example .env
php artisan key:generate
php artisan config:clear
- name: Run tests
working-directory: ./application
run: ./vendor/bin/phpstan analyze app/
run: php artisan test --coverage

# static-analysis:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# - name: Cache dependencies
# uses: actions/cache@v2
# with:
# path: ./application/vendor
# key: composer-${{ hashFiles('**/composer.lock') }}
# restore-keys: |
# composer-
#
# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: 8.3
# tools: composer:v2
# coverage: none
#
# - name: Install Project Dependencies
# working-directory: ./application
# run: composer install
#
# - name: Run static analyser
# working-directory: ./application
# run: ./vendor/bin/phpstan analyze app/

# SonarCloud:
# runs-on: ubuntu-latest
Expand All @@ -140,6 +176,65 @@ jobs:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}

database:
runs-on: ubuntu-latest
services:
mysql-service:
image: mysql:8
env:
MYSQL_DATABASE: db
MYSQL_USER: admin
MYSQL_ROOT_PASSWORD: password
MYSQL_PASSWORD: password
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ./application/vendor
key: composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
tools: composer:v2
coverage: none

- name: Install Project Dependencies
working-directory: ./application
run: composer install

- name: Framework configuration
working-directory: ./application
run: |
cp .env.example .env
php artisan key:generate
php artisan config:clear
- name: Run migrations
run: php artisan migrate
env:
DB_PORT: ${{ job.services.mysql-service.ports[3306]}}
DB_HOST: 127.0.0.1

- name: Run feature tests
working-directory: ./application
run: php artisan test --testsuite=Feature

- name: Run migrations
run: php artisan migrate:rollback
env:
DB_PORT: ${{ job.services.mysql-service.ports[3306]}}
DB_HOST: 127.0.0.1

# build-check-push-image:
# runs-on: ubuntu-latest
# defaults:
Expand Down
3 changes: 3 additions & 0 deletions application/tests/Feature/ExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests\Feature;

// use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Models\User;
use Tests\TestCase;

class ExampleTest extends TestCase
Expand All @@ -15,5 +16,7 @@ public function test_the_application_returns_a_successful_response(): void
$response = $this->get('/');

$response->assertStatus(200);

User::factory()->create();
}
}

0 comments on commit 2200ac7

Please sign in to comment.