jaikit-flows

hello_world — Hello world — démo retry / if-else / on_failure / workflow.call

sha=ff32ff622429 visibility= tags=demo, smoke auto log=standard
✅ Preflight OK — tous les composants requis sont disponibles.
📋 Plan du workflow
🖱 manuel
step nœud description foreach if on_failure
flaky_call http.get skip
report_ok fs.write ${{ steps.flaky_call.status == 'success' }} fail
report_skipped fs.write fail
append_log fs.append skip
end_notify workflow.call skip
id: hello_world
name: Hello world — démo retry / if-else / on_failure / workflow.call

owner: admin
group: public
tags: [demo, smoke]

triggers:
  - type: manual

inputs:
  greeting:
    type: str
    default: "Bonjour"
  simulate_failure:
    type: bool
    default: false    # passe simulate_failure=true pour tester le chemin d'erreur

env: {}

steps:

  # ── 1. Retry : tente une URL cassée 2× avant de skip ────────────────────
  - id: flaky_call
    node: http.get
    retry:
      max: 2
      delay: 1s
      backoff: constant
      on_exhaust: skip   # ne tue pas le workflow si l'URL est down
    timeout: 5s
    on_failure: skip
    with:
      url: "http://localhost:19999/nonexistent"   # intentionnellement cassé

  # ── 2. if / else : bifurcation selon le résultat de flaky_call ──────────
  - id: report_ok
    node: fs.write
    if: ${{ steps.flaky_call.status == 'success' }}
    else: report_skipped          # ← branche else exécutée si condition false
    with:
      path: data/runs/hello_result.txt
      content: "${{ inputs.greeting }} — appel HTTP OK (run ${{ run.id }})"

  - id: report_skipped
    node: fs.write
    with:
      path: data/runs/hello_result.txt
      content: >
        ${{ inputs.greeting }} — appel HTTP skipped/failed
        (status=${{ steps.flaky_call.status }}, run ${{ run.id }})

  # ── 3. fs.append : log toujours écrit, même si une branche a été skippée
  - id: append_log
    node: fs.append
    on_failure: skip
    with:
      path: data/logs/hello_world.jsonl
      content: >
        {"run_id":"${{ run.id }}","flaky_status":"${{ steps.flaky_call.status }}","greeting":"${{ inputs.greeting }}"}

  # ── 4. workflow.call : bloc partagé de notification de fin ───────────────
  - id: end_notify
    node: workflow.call
    on_failure: skip
    with:
      workflow: shared/notify_run_end
      inputs:
        status: success
        workflow_name: hello_world
        run_id: ${{ run.id }}
      timeout: 15s

on_failure:
  - id: global_alert
    node: workflow.call
    with:
      workflow: shared/notify_run_end
      inputs:
        status: failed
        workflow_name: hello_world
        run_id: ${{ run.id }}