-
Notifications
You must be signed in to change notification settings - Fork 2
ci(updated ci action): added linter, code analysis, unit tests #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5c1c86b
ci(updated ci action): added linter, code analysis, unit tests
mubbi 5bad5d1
ci: fixed env file name
mubbi 171476f
ci: fix mysql host for testing
mubbi 7aa1910
ci: fix mysql issue
mubbi d326e67
ci: remove parallel testing
mubbi 8ca0806
ci: use default mysql creds
mubbi 88642ea
ci: fix mysql env for testing
mubbi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -29,3 +29,161 @@ jobs: | |
| run: | | ||
| # Validate all commits in the PR | ||
| npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose | ||
|
|
||
| lint: | ||
| runs-on: ubuntu-latest | ||
| needs: validate-commits | ||
| if: always() && (needs.validate-commits.result == 'success' || needs.validate-commits.result == 'skipped') | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.2' | ||
| extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv | ||
| coverage: none | ||
|
|
||
| - name: Cache Composer packages | ||
| id: composer-cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: vendor | ||
| key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-php- | ||
|
|
||
| - name: Install Composer dependencies | ||
| run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader | ||
|
|
||
| - name: Run Laravel Pint | ||
| uses: aglipanci/[email protected] | ||
| with: | ||
| preset: laravel | ||
| verboseMode: true | ||
|
|
||
| analyze: | ||
| runs-on: ubuntu-latest | ||
| needs: lint | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.2' | ||
| extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv | ||
| coverage: none | ||
|
|
||
| - name: Cache Composer packages | ||
| id: composer-cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: vendor | ||
| key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-php- | ||
|
|
||
| - name: Install Composer dependencies | ||
| run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader | ||
|
|
||
| - name: Copy environment file | ||
| run: cp .env.docker.example .env | ||
|
|
||
| - name: Generate application key | ||
| run: php artisan key:generate | ||
|
|
||
| - name: Run Larastan (PHPStan) | ||
| run: ./vendor/bin/phpstan analyse --memory-limit=2G --error-format=github | ||
|
|
||
| test: | ||
| runs-on: ubuntu-latest | ||
| needs: analyze | ||
|
|
||
| services: | ||
| mysql: | ||
| image: mysql:8.0 | ||
| env: | ||
| MYSQL_ROOT_PASSWORD: root | ||
| MYSQL_DATABASE: laravel_blog_test | ||
| ports: | ||
| - 3306:3306 | ||
| options: --health-cmd="mysqladmin ping -h localhost -u root -proot" --health-interval=10s --health-timeout=5s --health-retries=5 | ||
|
|
||
| redis: | ||
| image: redis:7-alpine | ||
| ports: | ||
| - 6379:6379 | ||
| options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.2' | ||
| extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv | ||
| coverage: xdebug | ||
|
|
||
| - name: Cache Composer packages | ||
| id: composer-cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: vendor | ||
| key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-php- | ||
|
|
||
| - name: Install Composer dependencies | ||
| run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader | ||
|
|
||
| - name: Copy environment file | ||
| run: cp .env.docker.example .env | ||
|
|
||
| - name: Generate application key | ||
| run: php artisan key:generate | ||
|
|
||
| - name: Set testing environment variables | ||
| run: | | ||
| echo "APP_ENV=testing" >> .env | ||
| echo "DB_CONNECTION=mysql" >> .env | ||
| echo "DB_HOST=127.0.0.1" >> .env | ||
| echo "DB_PORT=3306" >> .env | ||
| echo "DB_DATABASE=laravel_blog_test" >> .env | ||
| echo "DB_USERNAME=root" >> .env | ||
| echo "DB_PASSWORD=root" >> .env | ||
| echo "CACHE_STORE=array" >> .env | ||
| echo "SESSION_DRIVER=array" >> .env | ||
| echo "QUEUE_CONNECTION=sync" >> .env | ||
|
|
||
| - name: Wait for MySQL to be ready | ||
| run: | | ||
| for i in {1..60}; do | ||
| if mysqladmin ping -h 127.0.0.1 -P 3306 -u root -proot --silent; then | ||
| echo "MySQL is ready" | ||
| # Verify the database exists | ||
| mysql -h 127.0.0.1 -P 3306 -u root -proot -e "SHOW DATABASES;" | grep laravel_blog_test || exit 1 | ||
| echo "Database laravel_blog_test confirmed" | ||
| break | ||
| fi | ||
| echo "Waiting for MySQL... ($i/60)" | ||
| sleep 3 | ||
| done | ||
| if [ $i -eq 60 ]; then | ||
| echo "MySQL failed to start within 3 minutes" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Run database migrations | ||
| run: php artisan migrate:fresh --seed --env=testing --force | ||
|
|
||
| - name: Run tests with Pest (parallel) | ||
| env: | ||
| DB_HOST: 127.0.0.1 | ||
| DB_USERNAME: root | ||
| DB_PASSWORD: root | ||
| run: php artisan test --parallel --recreate-databases --stop-on-failure | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.