Lewati ke konten utama

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

LangkahPerintahDeskripsi
Install Dependenciescomposer install --no-devInstall package PHP
Static Analysis./vendor/bin/phpstan analyseCek tipe dan potensi bug
Unit Testphp artisan test --testsuite=UnitTest logika bisnis
Feature Testphp artisan test --testsuite=FeatureTest endpoint API
Code Style./vendor/bin/pint --testCek PSR-12 compliance

Frontend Flutter

LangkahPerintahDeskripsi
Install Dependenciesflutter pub getInstall package Dart
Static Analysisdart analyzeCek tipe dan lint
Unit Testflutter test test/unit/Test use case & service
Widget Testflutter test test/widget/Test UI komponen
Integration Testflutter 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

BranchFungsiDeploy
mainProduction-ready codeProduction (manual)
developIntegrasi fitur terbaruStaging (otomatis)
feature/*Pengembangan fitur baru
hotfix/*Perbaikan bug kritisProduction (cepat)
release/*Persiapan versi baruStaging

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)