0
0
Gitdevops~5 mins

GitHub Actions basics - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: GitHub Actions basics
O(n)
Understanding Time 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?

Scenario Under Consideration

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.

Identify Repeating Operations

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).
How Execution Grows With Input

As you add more steps, the total time grows roughly by adding each step's time.

Input Size (n = steps)Approx. Operations (steps run)
1010 steps
100100 steps
10001000 steps

Pattern observation: The total time grows directly with the number of steps.

Final Time Complexity

Time Complexity: O(n)

This means the total execution time grows linearly as you add more steps.

Common Mistake

[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.

Interview Connect

Understanding how workflow steps add up helps you design efficient pipelines and explain your choices clearly.

Self-Check

"What if some steps run in parallel jobs instead of sequentially? How would the time complexity change?"