NETTİM
← Kod Sonuçlarına Dön
YAML SQL sorguları Kimlik doğrulama Dosya yükleme API örnekleri Yapılandırma dosyaları Lisans: MIT

GitHub Actions Sürekli Entegrasyon (CI/CD) İş Akışı

Orijinal Kod Adı: YAML — checks.yml
Kod gönderimi (push) veya Pull Request açıldığında otomatik testleri, sözdizimi kontrollerini ve derleme adımlarını çalıştırır. Dosya ölçeği: 165 satır (~6.7 KB). Kaynak depo: uploadcare/uploadcare-js-api-clients.

💡 Püf Noktaları:
• Bağımlılık kurulum sürelerini kısaltmak için workflow içinde `actions/cache` kullanarak paket önbelleklemesi yapın.
• Erişim anahtarlarını asla YAML dosyasına yazmayın; GitHub `secrets` mekanizması ve en az yetki (`permissions`) kuralını uygulayın.
• Üçüncü parti GitHub Actions adımlarını dal adı yerine tam commit SHA veya kararlı sürüm etiketiyle (`@v4`) sabitleyin.

🛠️ Uygulama Tarifi:
1. Dosyayı depo içinde `.github/workflows/checks.yml` yoluna yerleştirin.
2. İş akışında kullanılan API anahtarı veya dağıtım parolalarını GitHub Repo > Settings > Secrets altından tanımlayın.
3. Test dalına (`branch`) commit gönderip GitHub Actions sekmesinden adımların yeşil geçtiğini doğrulayın.
Dikkat Edilmesi Gerekenler:
• [Hata Yönetimi] Üretime almadan önce geçersiz girdi, eksik ortam değişkeni ve bağlantı kesilmesi senaryoları için istisna/hata loglamasını doğrulayın.
• [Sürüm & Test] Bağımlılık ve çalışma ortamı sürümlerini (PHP/Node/Python/DB) hedef sunucuyla eşleştirip test ortamında doğruladıktan sonra dağıtın.
.github/workflows/checks.yml • YAML
name: checks

on:
  pull_request:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      UPLOAD_CLIENT_DEFAULT_PUBLIC_KEY: ${{ secrets.UPLOAD_CLIENT_DEFAULT_PUBLIC_KEY }}
      REST_CLIENT_DEFAULT_PUBLIC_KEY: ${{ secrets.REST_CLIENT_DEFAULT_PUBLIC_KEY }}
      REST_CLIENT_DEFAULT_SECRET_KEY: ${{ secrets.REST_CLIENT_DEFAULT_SECRET_KEY }}
      # A project with Signed Uploads enabled, which rejects every unsigned
      # request, so it cannot be the default one. Absent them, the JWT
      # integration tests skip rather than fail.
      UPLOAD_CLIENT_SECURE_UPLOADS_PUBLIC_KEY: ${{ secrets.UPLOAD_CLIENT_SECURE_UPLOADS_PUBLIC_KEY }}
      UPLOAD_CLIENT_SECURE_UPLOADS_SECRET_KEY: ${{ secrets.UPLOAD_CLIENT_SECURE_UPLOADS_SECRET_KEY }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 24
      - uses: dorny/paths-filter@v2
        id: changes
        with:
          filters: |
            rest-client:
              - 'packages/rest-client/**'
              - 'packages/api-client-utils/**'
            upload-client:
              - 'packages/upload-client/**'
              - 'packages/api-client-utils/**'
              # The whole suite runs against the emulator (`test/_emulator.ts`), so an
              # emulator-only change has to re-run it.
              - 'packages/api-emulator/**'
            api-emulator:
              - 'packages/api-emulator/**'
            api-client-utils:
              - 'packages/api-client-utils/**'
            signed-uploads:
              - 'packages/signed-uploads/**'
            image-shrink:
              - 'packages/image-shrink/**'
            cname-prefix:
              - 'packages/cname-prefix/**'
            quality-insights:
              - 'packages/quality-insights/**'
            cdn-url:
              - 'packages/cdn-url/**'
              # The `cdn-base` entry bundles cname-prefix and the smoke test runs it.
              - 'packages/cname-prefix/**'
      - name: Install dependencies
        working-directory: ./
        run: npm i
      - name: Run build
        working-directory: ./
        run: npm run build
      - name: Run lint
        working-directory: ./
        run: npm run lint
      # Vitest strips types without checking them, so this is what turns a
      # typo'd fixture name into a failure.
      - name: Typecheck `upload-client` tests
        working-directory: ./
        run: npm run typecheck -w packages/upload-client

      - name: Lint `api-emulator`
        if: steps.changes.outputs.api-emulator == 'true'
        run: npm run lint -w packages/api-emulator

      - name: Check `api-emulator` formatting
        if: steps.changes.outputs.api-emulator == 'true'
        run: npm run format:check -w packages/api-emulator

      # cdn-url uses oxlint/oxfmt, so the root lint above skips it.
      - name: Lint `cdn-url`
        if: steps.changes.outputs.cdn-url == 'true'
        run: npm run lint -w packages/cdn-url

      - name: Check `cdn-url` formatting
        if: steps.changes.outputs.cdn-url == 'true'
        run: npm run format:check -w packages/cdn-url

      # Vitest strips types without checking them; this enforces the tests'
      # `@ts-expect-error` API assertions and the usage they show.
      - name: Typecheck `cdn-url` tests
        if: steps.changes.outputs.cdn-url == 'true'
        run: npm run typecheck -w packages/cdn-url

      # Fails on an undocumented export or a broken `{@link}`.
      - name: Check `cdn-url` API docs
        if: steps.changes.outputs.cdn-url == 'true'
        run: npm run docs:api -w packages/cdn-url

      # api-emulator's `./browser` tests, upload-client's `chromium` project and
      # cdn-url's browser run use a real Chromium (Vitest browser mode). The
      # upload-client filter covers api-emulator's paths too. System packages aren't covered by the
      # browser cache, so they install every time; only the browser binaries
      # are cache-gated.
      - name: Install Chromium system deps
        if: steps.changes.outputs.upload-client == 'true' || steps.changes.outputs.cdn-url == 'true'
        timeout-minutes: 10
        env:
          # `install-deps` shells out to apt-get; keep it from stalling on an
          # interactive prompt (e.g. Ubuntu's needrestart).
          DEBIAN_FRONTEND: noninteractive
          NEEDRESTART_MODE: a
        run: npx playwright install-deps chromium
        working-directory: ./packages/api-emulator

      - uses: actions/cache@v4
        if: steps.changes.outputs.upload-client == 'true' || steps.changes.outputs.cdn-url == 'true'
        id: playwright-cache
        with:
          path: ~/.cache/ms-playwright
          key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}

      - name: Install Chromium
        if: (steps.changes.outputs.upload-client == 'true' || steps.changes.outputs.cdn-url == 'true') && steps.playwright-cache.outputs.cache-hit != 'true'
        timeout-minutes: 10
        run: npx playwright install chromium
        working-directory: ./packages/api-emulator

      - name: Run `api-emulator` tests
        if: steps.changes.outputs.api-emulator == 'true'
        run: npm run test -w packages/api-emulator

      - name: Run `upload-client` mock tests
        if: steps.changes.outputs.upload-client == 'true'
        run: npm run test -w packages/upload-client

      - name: Run `signed-uploads` local tests
        if: steps.changes.outputs.signed-uploads == 'true'
        run: npm run test -w packages/signed-uploads

      - name: Run `api-client-utils` local tests
        if: steps.changes.outputs.api-client-utils == 'true'
        run: npm run test -w packages/api-client-utils

      - name: Run `cdn-url` tests
        if: steps.changes.outputs.cdn-url == 'true'
        run: npm run test -w packages/cdn-url

      - name: Run `cdn-url` tests in Chromium
        if: steps.changes.outputs.cdn-url == 'true'
        run: npm run test:browser -w packages/cdn-url

      # Real-API tests run on release PRs (Ship.js opens them from
      # `releases/v*`), whatever changed, and block the release. Everywhere
      # else the emulator-backed runs above are the gate; `contract.yml` runs
      # them on demand. rest-client is the exception: it has no emulator-backed
      # tests, so a PR that touches it runs its real-API suite too.
      - name: Run `rest-client` integration tests
        if: >-
          startsWith(github.head_ref, 'releases/v') ||
          (github.event_name == 'pull_request' &&
          steps.changes.outputs.rest-client == 'true')
        run: npm run test:production -w packages/rest-client

      - name: Run `upload-client` integration tests
        if: startsWith(github.head_ref, 'releases/v')
        run: npm run test:production -w packages/upload-client

Tespit Edilen SQL Sorguları

with Signed Uploads enabled, which rejects every unsigned

Benzer Kod Örnekleri

YAML — .gitlab-ci.yml
YAML • SQL sorguları
YAML — .gitlab-ci.yml
YAML • SQL sorguları
YAML — .gitlab-ci-namespaced.yml
YAML • SQL sorguları
YAML — publish.yml
YAML • SQL sorguları