GitHub Actions でステップの並列実行が可能に
GitHub が提供するワークフロー機能において、従来の順次実行から背景処理を用いた並列実行へ変更され、各ステップが独立してログを保持しながら同時に実行できるようになった。
GitHub Actions では、now background を使用してステップを並列実行できるようになりました。
以前はワークフロー内のすべてのステップが順次実行され、各ステップは前のステップが完了するまで開始されませんでした。以前はシェルでのバックグラウンド処理 (&) を使って非同期でステップを実行することもできましたが、これにより複数のステップからのログが混在することがよくありました。この新しい機能により、ステップを並列で実行しつつ、個別のログと実行を維持できるようになりました。
4 つの新しいキーワードが導入されます:
background: true は、ステップを非同期で実行し、すぐに次のステップへ続行します。
wait/wait-all は、1 つ以上の名前付きバックグラウンドステップが完了するまで実行を一時停止します。wait は 1 つまたは複数の特定のバックグラウンドステップを対象とでき、wait-all はそれ以前のすべてのバックグラウンドステップが完了するまで一時停止します。
cancel は、不要になったときにバックグラウンドステップを優雅に終了させ、長時間実行されるサービスを背景ステップとして開始することを可能にします。
parallel は、ステップのグループを受け取り、その後待機処理付きの背景ステップに変換することで、複数のステップを簡単に並列で実行できるようにします。これは「これらのステップを並列で実行し、その後続行する」というパターンの構文糖です。
この更新により、単一のジョブ内で一般的なパターンを処理できるようになります:
真の並列での独立した作業の実行(例:複数のビルドを同時に実行)
背景サービスの開始、依存する作業の実行、その後そのサービスのクリーンな停止
後続のステップが実行されている間も継続できる非同期作業の起動(例:パッケージ化が続く間にテレメトリのアップロードを開始)
現在の構文と使用の詳細については、GitHub Actions ワークフロー構文のドキュメントをお読みください。
「Actions ステップを並列実行可能に」の記事は、The GitHub Blog で最初に公開されました。
原文を表示
GitHub Actions now supports running steps concurrently using background.
Previously, all steps in a workflow ran in sequence, with each step starting only after the previous step completed. Previously, you could run steps in a non-blocking way using shell backgrounding (&), but that often interleaved logs from multiple steps. This new capability enables steps to run in parallel while retaining separate logs and execution.
Four new keywords are being introduced:
background: true runs a step asynchronously and immediately continues to the next step.
wait/wait-all pauses execution until one or more named background steps complete. wait can target one or more specific background steps, while wait-all pauses until all prior background steps have completed.
cancel gracefully terminates a background step when you no longer need it, enabling you to start long-running services with a background step.
parallel takes a group of steps and converts them to background steps with a wait after, enabling you to easily run multiple steps in parallel. This is syntactic sugar for the “run these steps concurrently, then continue” pattern.
This update helps you handle common patterns in a single job:
Running independent work in true parallel, such as multiple builds at once
Starting a background service, running dependent work, then stopping that service cleanly
Kicking off non-blocking work that can continue while later steps run, like uploading telemetry while packaging continues
Read the GitHub Actions workflow syntax documentation for current syntax and usage details.
The post Actions steps can now be run in parallel appeared first on The GitHub Blog.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み