Skip to content

Commit

Permalink
feat: setup sun ci
Browse files Browse the repository at this point in the history
  • Loading branch information
quynt-1571 committed Oct 9, 2024
1 parent 8eae5e9 commit d925383
Show file tree
Hide file tree
Showing 17 changed files with 3,260 additions and 737 deletions.
12 changes: 12 additions & 0 deletions .env.testing.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
APP_NAME="App in testing"
APP_ENV=local
APP_KEY=
APP_DEBUG=false
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=app_db
DB_USERNAME=app_user
DB_PASSWORD=secret
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ yarn-error.log
/.idea
/.vscode
/.zed
/.php-cs-fixer.cache
90 changes: 90 additions & 0 deletions .sun-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
default:
workspace: shared

stages:
- build
- check

jobs:
- name: Build Laravel
stage: build
image: ghcr.io/avengerscodelovers/php:8.2-ci
services:
- image: mysql:8.0
name: mysql
environment:
MYSQL_DATABASE: app_db
MYSQL_USER: app_user
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: root
environment:
APP_ENV: testing
COMPOSER_MEMORY_LIMIT: 2G
COMPOSER_ALLOW_SUPERUSER: "1"
cache:
- key: composer_vendor_$CI_BRANCH
paths:
- vendor
script:
- cp .env.testing.example .env
- composer install
- php artisan key:generate
- php artisan migrate
- php artisan route:cache

# - name: Check GKC Hashcode
# stage: check
# image: bash:latest
# workspace: false
# before_script:
# # For command tput, used by gkc_util_hashcode_script.sh
# - apk add ncurses
# environment:
# TERM: xterm
# script:
# - bash ./gkc_util_hashcode_script.sh
# only:
# events:
# - pull_request

- name: Static Code Analysis
stage: check
image: ghcr.io/avengerscodelovers/php:8.2-ci
environment:
COMPOSER_MEMORY_LIMIT: 2G
COMPOSER_ALLOW_SUPERUSER: "1"
script:
- COMPOSER_PROCESS_TIMEOUT=600 composer phpstan

- name: PHP Coding Convention
stage: check
image: ghcr.io/avengerscodelovers/php:8.2-ci
environment:
COMPOSER_MEMORY_LIMIT: 2G
COMPOSER_ALLOW_SUPERUSER: "1"
script:
- composer cs

- name: PHP Test Coverage and Codecov
stage: check
image: ghcr.io/avengerscodelovers/php:8.2-ci
services:
- image: mysql:8.0
name: mysql
environment:
MYSQL_DATABASE: app_db
MYSQL_USER: app_user
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: root
environment:
COMPOSER_ALLOW_SUPERUSER: "1"
script:
- php artisan migrate
- XDEBUG_MODE=coverage php -dzend_extension=xdebug.so ./vendor/bin/pest --coverage-clover ./coverage.xml --ci
# Upload code coverage report to Sun* Codecov
# Container must be installed git, that used to detect Git commit SHA for Codecov
- apk add curl git
- curl -Os https://cli.codecov.io/latest/alpine/codecov
- chmod +x codecov
- if [ -z $CI_PR_NUMBER ]; then export CODECOV_PR=""; else export CODECOV_PR="--pull-request-number $CI_PR_NUMBER"; fi
- ./codecov --verbose --enterprise-url https://athena.sun-asterisk.vn upload-process --fail-on-error --token $CODECOV_TOKEN --branch $CI_BRANCH $CODECOV_PR --name 'Sun*CI' --flag phpunit --file ./coverage.xml --build-url https://ci.sun-asterisk.com/$CI_GIT_PROVIDER/$CI_REPOSITORY/builds/$CI_BUILD_NUMBER --plugin noop --report-type coverage
3 changes: 2 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

class User extends Authenticatable
{
use HasFactory, Notifiable;
use HasFactory;
use Notifiable;

/**
* The attributes that are mass assignable.
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"laravel/tinker": "^2.9"
},
"require-dev": {
"avengerscodelovers/laravel-cs": "*",
"fakerphp/faker": "^1.23",
"laravel/pint": "^1.13",
"laravel/sail": "^1.26",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.0",
"pestphp/pest": "^3.2",
"phpunit/phpunit": "^11.0.1"
},
"autoload": {
Expand Down Expand Up @@ -44,7 +46,10 @@
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
]
],
"phpstan": "phpstan analyse --memory-limit 2G",
"cs": "php-cs-fixer fix --dry-run -v --config=./vendor/avengerscodelovers/laravel-cs/.php-cs-fixer.dist.php",
"cs:fix": "php-cs-fixer fix -v --config=./vendor/avengerscodelovers/laravel-cs/.php-cs-fixer.dist.php"
},
"extra": {
"laravel": {
Expand Down
Loading

0 comments on commit d925383

Please sign in to comment.