GitHub Actions basics - Time & Space Complexity
We want to understand how the time it takes to run a GitHub Actions workflow changes as the number of jobs or steps grows.
How does adding more steps or jobs affect the total execution time?
Analyze the time complexity of this simple GitHub Actions workflow.
name: Example Workflow
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Step 1
run: echo "Hello"
- name: Step 2
run: echo "World"
- name: Step 3
run: echo "!"
This workflow runs three steps sequentially when code is pushed.
Look for repeated actions that take time.
- Primary operation: Each step runs one command.
- How many times: Number of steps in the job (3 in this example).
As you add more steps, the total time grows roughly by adding each step's time.
| Input Size (n = steps) | Approx. Operations (steps run) |
|---|---|
| 10 | 10 steps |
| 100 | 100 steps |
| 1000 | 1000 steps |
Pattern observation: The total time grows directly with the number of steps.
Time Complexity: O(n)
This means the total execution time grows linearly as you add more steps.
[X] Wrong: "Adding more steps won't affect total time because they run fast."
[OK] Correct: Each step adds time, so more steps mean more total time, even if each is short.
Understanding how workflow steps add up helps you design efficient pipelines and explain your choices clearly.
"What if some steps run in parallel jobs instead of sequentially? How would the time complexity change?"