Section 6/171 menit

6. Tuist Cloud dan Remote Cache

6. Tuist Cloud dan Remote Cache

Apa Itu Tuist Cloud

Tuist Cloud adalah layanan server-side (self-hosted atau managed) yang menyediakan:

  • Remote binary cache — cache di-share antara semua developer dan CI
  • Selective testing — hanya jalankan test untuk target yang berubah
  • Project insights — analytics dependency graph dan build metrics

Setup Self-Hosted Tuist Cloud

swift
# Tuist Cloud server (Docker)
docker run -p 8080:8080 \
    -e DATABASE_URL=postgresql://user:pass@db:5432/tuist \
    -e SECRET_KEY_BASE=your-secret-key \
    ghcr.io/tuist/tuist-cloud:latest

Konfigurasi Project untuk Tuist Cloud

swift
// Tuist/Config.swift
import ProjectDescription

let config = Config(
    cloud: .cloud(
        projectId: "company/myapp",
        url: "https://cloud.tuist.internal",  // self-hosted URL
        options: [.optional]  // opsional: CI tetap jalan jika cloud tidak tersedia
    ),
    compatibleXcodeVersions: .list(["16.2"]),
    swiftVersion: "6.0"
)

Menggunakan Remote Cache

swift
# Login ke Tuist Cloud (sekali per mesin)
tuist auth login

# Build dengan remote cache
# Tuist otomatis upload/download dari remote cache
tuist build MyApp

# Explicit cache operation dengan remote
tuist cache --path . 

# Di CI: gunakan environment variable untuk auth
# TUIST_CONFIG_TOKEN=your-ci-token

Selective Testing

Selective testing hanya menjalankan test untuk module yang berubah dan dependannya:

swift
# Analisis perubahan sejak commit terakhir
# Jalankan hanya test yang relevan
tuist test MyApp --selective-testing --baseline /tmp/test-baseline.json

# Workflow di CI:
# 1. Simpan baseline setelah full test run di main branch
# 2. Di PR branch: gunakan selective testing
# 3. Setelah merge: update baseline

# GitHub Actions example:
# - name: Run selective tests
#   run: |
#     tuist test MyApp \
#       --selective-testing \
#       --baseline baseline.json \
#       --result-bundle-path TestResults.xcresult