BAB 55. CI/CD RECOMMENDATION
Tujuan
Otomatisasi proses build, testing, dan deployment untuk memastikan setiap perubahan kode terjamin kualitasnya sebelum masuk ke production.
Pipeline Lengkap
flowchart LR
DEV["👨💻 Developer\nPush Code"] --> GIT["📦 Git Repository\n(GitHub/GitLab)"]
GIT --> CI["🔄 CI Pipeline\n(GitHub Actions)"]
CI --> TEST["🧪 Automated Tests"]
TEST --> BUILD["🏗️ Build Artifacts"]
BUILD --> STG["🧩 Deploy Staging\n(Otomatis)"]
STG --> APR{{"✋ Manual\nApproval"}}
APR --> PRD["🚀 Deploy Production"]
style CI fill:#4f63d2,color:#fff
style APR fill:#b45309,color:#fff
style PRD fill:#059669,color:#fff
Tahapan CI (Continuous Integration)
Backend Laravel
| Langkah | Perintah | Deskripsi |
|---|---|---|
| Install Dependencies | composer install --no-dev | Install package PHP |
| Static Analysis | ./vendor/bin/phpstan analyse | Cek tipe dan potensi bug |
| Unit Test | php artisan test --testsuite=Unit | Test logika bisnis |
| Feature Test | php artisan test --testsuite=Feature | Test endpoint API |
| Code Style | ./vendor/bin/pint --test | Cek PSR-12 compliance |
Frontend Flutter
| Langkah | Perintah | Deskripsi |
|---|---|---|
| Install Dependencies | flutter pub get | Install package Dart |
| Static Analysis | dart analyze | Cek tipe dan lint |
| Unit Test | flutter test test/unit/ | Test use case & service |
| Widget Test | flutter test test/widget/ | Test UI komponen |
| Integration Test | flutter test integration_test/ | Test alur pengguna |
Tahapan Build
Laravel
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
composer install --optimize-autoloader --no-dev
Flutter
# Android APK (debug)
flutter build apk --debug
# Android App Bundle (production)
flutter build appbundle --release
# iOS (production)
flutter build ipa --release
GitHub Actions Workflow (Backend)
# .github/workflows/ci.yml
name: CI Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: temubelajar_test
MYSQL_ROOT_PASSWORD: secret
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- name: Install dependencies
run: composer install
- name: Run tests
run: php artisan test --parallel
env:
DB_CONNECTION: mysql
DB_DATABASE: temubelajar_test
Branch Strategy
| Branch | Fungsi | Deploy |
|---|---|---|
main | Production-ready code | Production (manual) |
develop | Integrasi fitur terbaru | Staging (otomatis) |
feature/* | Pengembangan fitur baru | — |
hotfix/* | Perbaikan bug kritis | Production (cepat) |
release/* | Persiapan versi baru | Staging |
Kebijakan Merge
feature/* ──→ develop (PR + Review + CI Pass)
develop ──→ main (PR + Review + QA Sign-off)
hotfix/* ──→ main (PR + Review + Emergency)
main ──→ develop (sync setelah hotfix)