Déploiement canary avec tests de fumée

VérifiéPrudence

Déploie une révision Cloud Run sans trafic, exécute des health checks puis promeut en production si tout réussit. Réduit les risques de mise en production cassée.

Spar Skills Guide Bot
DevOpsIntermédiaire
18/11/2026
Claude Code
#canary-deployment#cloud-run#smoke-tests#gcloud#release-safety

Recommandé pour

Synthèse automatique

Déploie une révision Cloud Run sans trafic, vérifie qu'elle fonctionne via des contrôles de santé, puis promeut le trafic vers cette révision si tout est vert.

Points forts

  • Résolution du service pilotée par le bloc `services:` de `.adlc/config.yml`, sans nom de service ni région codés en dur
  • Détection automatique du dépôt ou du worktree courant lorsqu'aucun argument n'est fourni, avec repli explicite et journalisé pour les anciens dépôts mono-repo
  • Collecte de contexte tolérante aux fichiers absents : chaque lecture manquante affiche un avis au lieu d'échouer
  • Séquence claire déploiement à trafic nul → vérification → promotion, ce qui protège les utilisateurs des déploiements cassés

Limites

  • Limité à Google Cloud Run via `gcloud` : aucun autre fournisseur, et le skill déploie des révisions, pas de nouveaux services
  • Suppose un service déjà existant, une image Docker disponible et une authentification `gcloud` correctement configurée
  • Le texte fourni s'interrompt au milieu de la section sur le worktree, donc les commandes exactes de smoke test et de promotion ne sont pas détaillées
Quand l'utiliser

À utiliser avant de mettre en ligne une nouvelle version d'un service Cloud Run existant, pour valider la révision avant d'ouvrir le trafic.

Quand l'éviter

À éviter pour un tout premier déploiement (le service n'existe pas encore) ou pour une cible qui n'est pas Cloud Run.

Analyse de sécurité

Prudence
Score qualité76/100

The skill is a legitimate, coherent Cloud Run canary workflow — it builds and pushes an image, deploys a zero-traffic tagged revision, curls health endpoints, and promotes or removes the tag. Nothing is destructive beyond the intended traffic switch, nothing is exfiltrated, and there is no obfuscation or curl|sh payload. Risk comes from breadth of power (docker push, gcloud traffic mutation, network curl) plus the `!`-prefixed cat of a repo-local ETHOS.md into the prompt, hence 'caution' rather than 'safe'.

Points d'attention
  • •The leading `!` backtick block cats `.adlc/ETHOS.md` from the working directory directly into the model's instruction context — repo-controlled text becomes trusted instructions (prompt-injection vector) if the repo is untrusted.
  • •Skill drives privileged operations with no declared `allowed-tools`: `docker build`/`docker push` to Artifact Registry and `gcloud run deploy` / `update-traffic` that shift 100% of production traffic, all without an explicit confirmation gate before the promote step.
  • •Auto-detection fallback (step 4) infers service name/region/image path implicitly and only 'surfaces it in the logs' — an operator could promote the wrong Cloud Run service by accident.
  • •`gcloud config get-value project` output and repo ids are interpolated into shell commands; low risk, but the doc does not advise quoting/validating them.
  • •At load time the skill executes a shell command via the `!`...`` injection (`test -s .adlc/ETHOS.md && cat .adlc/ETHOS.md`), pulling the contents of a repo-local file directly into the model context; a malicious or attacker-modified ETHOS.md becomes an indirect prompt-injection vector.
  • •The skill drives real infrastructure changes: `docker build`/`docker push` to Artifact Registry and `gcloud run deploy` / `update-traffic` against a live Cloud Run service, including promoting a revision to 100% of production traffic. These are powerful, network-touching operations, though they are used for their stated legitimate purpose.
  • •Promotion to production (Step 5) happens automatically once health/smoke checks pass, with no explicit human confirmation gate; a misconfigured or overly shallow health check could let a bad revision take 100% traffic before anyone reviews the result.
  • •The context block enumerates the local GCP project and all Cloud Run services; this is read-only telemetry, not exfiltration, but it does surface environment/project identifiers into the model context.
Comment cette analyse est faite

Exemples

Canary deploy by repo id
/canary api
Smoke test before going live
Canary deploy the web service: push a zero-traffic revision to Cloud Run, run the health checks, and only promote it to live traffic if everything passes.
Auto-detect from worktree
Deploy with canary from the current worktree — resolve the Cloud Run service from .adlc/config.yml instead of me naming it.

name: canary description: Canary deployment with smoke tests — deploy to a zero-traffic revision, run health checks, and promote on success. Use when the user says "canary deploy", "deploy with canary", "smoke test the deploy", or wants deployment confidence before going live. argument-hint: Optional repo id (from .adlc/config.yml) or service name — auto-detected from current worktree if omitted

/canary — Canary Deployment with Smoke Tests

You are deploying code through a canary process: deploy a zero-traffic revision, verify it works, then promote to live traffic. This prevents broken deploys from reaching users.

Ethos

!test -s .adlc/ETHOS.md && cat .adlc/ETHOS.md || echo No ethos found — run /init, or /adlc:init on the plugin install, to vendor .adlc/ETHOS.md

Context

Run this block first, with your shell tool, and read its output before you continue. Each read prints a notice instead of failing when its file is absent.

# adlc-context
echo '--- Current directory'
pwd
echo '--- Current branch'
git branch --show-current 2>/dev/null || echo 'Not a git repo'
echo '--- GCP project'
gcloud config get-value project 2>/dev/null || echo 'No GCP project configured'
echo '--- Active Cloud Run services'
gcloud run services list --format="table(SERVICE,REGION,URL)" 2>/dev/null || echo 'gcloud not configured'

Input

The target is the argument: whatever follows /canary in the invocation (on Claude Code it can also arrive as an ARGUMENTS: line appended to this text), a repo id or a Cloud Run service name. With none, Service Resolution below detects it from the current directory.

Prerequisites

  1. gcloud CLI must be authenticated and configured with the correct project
  2. The service must already exist on Cloud Run (this skill deploys revisions, not new services)
  3. A Docker image must be available (either build locally or use the latest from Artifact Registry)

Service Resolution

Service configuration lives in .adlc/config.yml in the primary repo under a services: block, keyed by repo id. This is the single source of truth — no service names, regions, or image paths should be hardcoded in this skill.

Expected config shape (primary repo .adlc/config.yml):

repos:
  api:
    path: ../api
  web:
    path: ../web

services:
  api:
    cloud_run_service: api
    region: us-central1
    image_path: us-central1-docker.pkg.dev/<gcp-project>/api/api
  web:
    cloud_run_service: web
    region: us-central1
    image_path: us-central1-docker.pkg.dev/<gcp-project>/web/web

Resolution order:

  1. If the argument is a repo id defined under repos: in the primary's config, look up services[<repo-id>] and use that. If the repo id has no services: entry, stop and ask the user to add one.
  2. If the argument is a Cloud Run service name already (e.g., the user passed api and it matches services.*.cloud_run_service), use that entry.
  3. If no argument: detect which repo the current cwd is inside by walking up to find a git root and matching it against repos[*].path (resolve each to an absolute path first). Then look up its service.
  4. If the project has no .adlc/config.yml (single-repo legacy setup) AND the current repo has a top-level Dockerfile and a single Cloud Run service name that matches the repo basename, fall back to auto-detection: service name = repo basename, region = us-central1, image path = $(gcloud config get-value project)/<service>. Surface this fallback in the logs so the user knows it's being inferred.
  5. If none of the above resolves, stop with a clear error: "Could not determine Cloud Run service. Add a services: block to .adlc/config.yml or pass the service name as an argument."

Operating worktree: if the resolved repo has a feature-branch worktree (e.g., .worktrees/REQ-xxx) that matches the current /proceed pipeline, build from inside that worktree. Otherwise build from the repo's main checkout. The caller can also pass the worktree path explicitly.

Note (post-REQ-380, REQ-381): /canary is no longer auto-invoked from /proceed (REQ-380) or /bugfix (REQ-381). Operators run it manually when a production canary is needed.

Instructions

Step 1: Build and Push Image

  1. Determine the image tag: use the current git SHA (git rev-parse --short HEAD)
  2. Build the Docker image:
    docker build -t <IMAGE_PATH>:canary-<SHA> ./<subdir if needed>
    
  3. Push to Artifact Registry:
    docker push <IMAGE_PATH>:canary-<SHA>
    

If the user says "use latest" or the image was already built by CI, skip the build and use the :latest tag from Artifact Registry.

Step 2: Deploy Canary Revision (Zero Traffic)

Deploy a new revision that receives NO traffic:

gcloud run deploy <SERVICE_NAME> \
  --image=<IMAGE_PATH>:canary-<SHA> \
  --region=us-central1 \
  --no-traffic \
  --tag=canary \
  --format="json"

This creates a tagged revision accessible at https://canary---<SERVICE_NAME>-<hash>.a.run.app without affecting production traffic.

Capture the canary URL from the output.

Step 3: Health Checks

Run basic health checks against the canary URL:

  1. Liveness: curl -s -o /dev/null -w "%{http_code}" <CANARY_URL>/health

    • Expected: 200
    • Retry up to 3 times with 5-second intervals (cold start grace period)
  2. Readiness: curl -s -o /dev/null -w "%{http_code}" <CANARY_URL>/api/health

    • Expected: 200 (or the service's documented readiness endpoint)

If health checks fail after 3 retries, go to Step 6 (Rollback).

Step 4: Smoke Tests

Run smoke tests against the canary URL. Load test definitions from the primary repo's .adlc/context/smoke-tests.md if it exists, otherwise use defaults. In cross-repo mode the primary's smoke-tests.md is the authoritative source for every service — sibling repos do not need their own copy.

Default smoke tests (API services):

GET  /health              -> 200
GET  /api/health          -> 200

Custom smoke tests (from .adlc/context/smoke-tests.md): Each entry should specify: method, path, expected status, optional body pattern.

For each test:

RESPONSE=$(curl -s -w "\n%{http_code}" <CANARY_URL><PATH>)
STATUS=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -n -1)

Report results:

## Smoke Test Results

| Test | Method | Path | Expected | Actual | Status |
|------|--------|------|----------|--------|--------|
| Health | GET | /health | 200 | 200 | PASS |
| API Health | GET | /api/health | 200 | 200 | PASS |

Result: 2/2 passed

If any test fails, go to Step 6 (Rollback).

Step 5: Promote to Production

All checks passed — promote the canary revision to 100% traffic:

gcloud run services update-traffic <SERVICE_NAME> \
  --region=us-central1 \
  --to-tags=canary=100

Verify promotion:

gcloud run services describe <SERVICE_NAME> \
  --region=us-central1 \
  --format="table(status.traffic[].percent,status.traffic[].revisionName,status.traffic[].tag)"

Confirm canary revision is now serving 100% traffic.

Remove the canary tag (clean up):

gcloud run services update-traffic <SERVICE_NAME> \
  --region=us-central1 \
  --remove-tags=canary

Report:

Canary promoted to production.
Service: <SERVICE_NAME>
Revision: <REVISION_NAME>
URL: <PRODUCTION_URL>
All smoke tests passed.

Step 6: Rollback (Failure Path)

If health checks or smoke tests fail:

  1. Delete the canary revision tag (so it's not addressable):

    gcloud run services update-traffic <SERVICE_NAME> \
      --region=us-central1 \
      --remove-tags=canary
    
  2. Report the failure:

    CANARY FAILED — rolled back.
    Service: <SERVICE_NAME>
    Failed revision: canary-<SHA>
    
    Failures:
    - [list failed health checks or smoke tests]
    
    Production traffic is unchanged — still serving the previous revision.
    
  3. Suggest next steps:

    • Check Cloud Run logs: gcloud run services logs read <SERVICE_NAME> --region=us-central1 --limit=50
    • Investigate the failure locally
    • Fix and re-run /canary

Step 7: Update Pipeline State (if in /proceed context)

If pipeline-state.json exists for the current REQ:

  1. Add a canary entry to phaseHistory with the result (passed/failed)
  2. Include: service name, revision, smoke test results, canary URL

Smoke Test Configuration

To customize smoke tests, create .adlc/context/smoke-tests.md with this format:

# Smoke Tests

## api
| Method | Path | Expected Status | Body Pattern |
|--------|------|-----------------|--------------|
| GET | /health | 200 | |
| GET | /api/health | 200 | |
| GET | /api/v1/config | 200 | "version" |

## web
| Method | Path | Expected Status | Body Pattern |
|--------|------|-----------------|--------------|
| GET | / | 200 | |
| GET | /api/health | 200 | |

The keys above (api, web) are repo ids — the same ids you used under repos: in .adlc/config.yml. /canary looks up the smoke tests for the service it's deploying by matching repo id.

What This Skill Does NOT Do

  • It does not create new Cloud Run services — the service must already exist
  • It does not handle iOS deployments — TestFlight is already a canary-like process
  • It does not modify CI/CD workflows — it's a manual deployment confidence tool
  • It does not handle database migrations — run those separately before deploying

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/canary-deployment-with-smoke-tests-mwk700cd/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/canary-deployment-with-smoke-tests-mwk700cd' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/canary-deployment-with-smoke-tests-mwk700cd/download' --output '.skill-downloads/canary-deployment-with-smoke-tests-mwk700cd/SKILL.md.part' && mv '.skill-downloads/canary-deployment-with-smoke-tests-mwk700cd/SKILL.md.part' '.skill-downloads/canary-deployment-with-smoke-tests-mwk700cd/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Extrait original : Prerequisites
  1. gcloud CLI must be authenticated and configured with the correct project
  2. The service must already exist on Cloud Run (this skill deploys revisions, not new services)
  3. A Docker image must be available (either build locally or use the latest from Artifact Registry)

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/canary-deployment-with-smoke-tests-mwk700cd/SKILL.md' && test -s '.skill-downloads/canary-deployment-with-smoke-tests-mwk700cd/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/canary' && cp -R '.skill-downloads/canary-deployment-with-smoke-tests-mwk700cd' '.claude/skills/canary'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/canary-deployment-with-smoke-tests-mwk700cd'

openskills read 'canary-deployment-with-smoke-tests-mwk700cd'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/canary-deployment-with-smoke-tests-mwk700cd/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires