Skip to content

feat: auto-deploy preview untuk pull request #525

feat: auto-deploy preview untuk pull request

feat: auto-deploy preview untuk pull request #525

Workflow file for this run

name: Code Quality
on:
# schedule: # scheduled to run at 23.00 on Saturday (UTC), means 6.00 on Monday (WIB)
# - cron: '0 23 * * 6'
push:
branches: [main]
# paths: ['.github/**.yml', '**.php', '**.js', '**.ts', '**.vue']
pull_request:
branches: [main]
# paths: ['.github/**.yml', '**.php', '**.js', '**.ts', '**.vue']
env:
APP_NAME: ${{ vars.APP_NAME }}
APP_ENV: ${{ vars.APP_ENV }}
APP_URL: ${{ vars.APP_URL }}
APP_KEY: base64:wd/Cak9eudgF0z4HcmvkjAzw1zmKorlVLGjNabomfQs=
# AWS_ENDPOINT: 'https://is3.cloudhost.id'
# AWS_DEFAULT_REGION: 'ap-southeast-3'
# AWS_BUCKET: creasi-staging
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }}
DB_DATABASE: creasico
DB_USERNAME: creasico
DB_PASSWORD: secret
MAIL_FROM_ADDRESS: ${{ vars.MAIL_FROM_ADDRESS }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
jobs:
prepare:
name: Prepare
# uses: creasico/laravel-project/.github/workflows/prepare.yml@main
uses: ./.github/workflows/prepare.yml
secrets: inherit
units:
name: Unit Test with PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: prepare
services:
postgresql:
image: postgres:14
env:
POSTGRES_DB: ${{ env.DB_DATABASE }}
POSTGRES_USER: ${{ env.DB_USERNAME }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 5432:5432
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
php: [8.1, 8.2]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, dom, gd, imagick, intl, libxml, mbstring, pcntl, pdo, pdo_pgsql, zip
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare Composer Cache
uses: actions/cache@v4
with:
path: ${{ needs.prepare.outputs.composer-cache }}
key: php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: php-${{ matrix.php }}-composer-
- name: Install dependencies
run: composer update --prefer-dist --no-interaction --no-progress --ansi
- name: Run unit tests
run: php artisan test --ansi --coverage
- name: Generate reports for CodeClimate
if: github.actor != 'dependabot[bot]'
env:
COVERAGE_FILE: tests/reports/clover.xml
CODECLIMATE_REPORT: tests/reports/codeclimate.${{ matrix.php }}.json
run: |
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT $COVERAGE_FILE
- name: Upload tests reports
if: github.actor != 'dependabot[bot]'
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.php }}
path: |
tests/coverage
tests/reports
e2e:
name: Integration Test on BrowserStack
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
needs: prepare
env:
DEBUGBAR_ENABLED: false
DUSK_HEADLESS_DISABLED: true
services:
postgresql:
image: postgres:14
env:
POSTGRES_DB: ${{ env.DB_DATABASE }}
POSTGRES_USER: ${{ env.DB_USERNAME }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 5432:5432
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: curl, dom, gd, igbinary, imagick, intl, libxml, mbstring, pcntl, pdo, pdo_pgsql, zip
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download assets
id: download
uses: actions/download-artifact@v4
with:
name: build-${{ env.APP_ENV }}
path: public
- name: Prepare Composer Cache
uses: actions/cache@v4
with:
path: ${{ needs.prepare.outputs.composer-cache }}
key: php-8.1-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: php-8.1-composer-
- name: Install dependencies
run: composer install --prefer-dist --no-interaction --no-progress --ansi
- name: Start dev server
run: php artisan serve > /dev/null 2>&1 &
- name: Run e2e tests
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
run: |
php artisan dusk:browserstack-local
php artisan dusk --colors=always
- name: Upload e2e tests logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-logs
path: |
tests/Browser/console
tests/Browser/screenshots
reports:
name: Report Test Coverages
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
needs: units
steps:
- name: Download test reports
uses: actions/download-artifact@v4
with:
pattern: test-reports-*
merge-multiple: true
- name: Submit to CodeClimate
run: |
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
./cc-test-reporter sum-coverage -o - reports/codeclimate.*.json | ./cc-test-reporter upload-coverage --input -