crossplatform — one task name, two implementations

Sources: examples/workflow_simple — settings in workflows/crossplatform/.

workflow_settings.yml
workflows:
  - crossplatform

The same task is declared twice, each declaration listing the platforms it applies to. Exactly one is selected, according to sys.platform:

workflows/crossplatform/_settings.yml
tasks:
  - name: main
    platforms: [linux, darwin]
    commands:
      - echo 'Linux/MacOS Task...'
      - sleep 1
      - "echo 'Progress: 60' > progress.txt"
      - ...

  - name: main
    platforms: win32  # powershell
    commands:
      - Write-Host "Windows Task..."
      - Start-Sleep -Seconds 1
      - '"Progress: 60" | Set-Content progress.txt'
      - ...

platforms accepts a single value or a list. The Windows implementation is PowerShell, not cmd, which is why it uses Write-Host and Set-Content rather than shell redirection.

Its _metrics.yml reads a platform metric out of platform_info.txt, so the result records show which branch actually ran.

Tip

This is the mechanism to reach for whenever a step is genuinely OS-dependent — invoking a tool that is installed differently, or cleaning up files. Everything else should stay in a single task.

Where to go next