Catalogue
GitHub Actions - Should I Run Jobs Sequentially or in Parallel?

GitHub Actions - Should I Run Jobs Sequentially or in Parallel?

🌐 日本語で読む

Overview

I run static analysis such as Go’s errcheck and lint with GitHub Actions,
but I was wondering which is better: a sequential configuration or a parallel configuration for those jobs.
This is a write-up of that dilemma.

Points I Struggled With

  • With a parallel configuration, each job triggers a container load. The individual execution time is short, but the total execution time becomes longer.
  • With a sequential configuration, the container load happens only once. The execution time becomes longer, but the total execution time is shorter.

If I want to run things without spending too much money, the sequential approach is probably the way to go.

The Actual Configurations

Sequential Jobs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: static check
on: push

jobs:
imports:
name: Imports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: check
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: imports
token: ${{ secrets.GITHUB_TOKEN }}

errcheck:
name: Errcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: check
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: errcheck
token: ${{ secrets.GITHUB_TOKEN }}

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: check
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: lint
token: ${{ secrets.GITHUB_TOKEN }}

shadow:
name: Shadow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: check
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: shadow
token: ${{ secrets.GITHUB_TOKEN }}

staticcheck:
name: StaticCheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: check
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: staticcheck
token: ${{ secrets.GITHUB_TOKEN }}

sec:
name: Sec
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: check
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: sec
token: ${{ secrets.GITHUB_TOKEN }}

Parallel Jobs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: static check
on: push

jobs:
imports:
name: Imports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: imports
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: imports
token: ${{ secrets.GITHUB_TOKEN }}
- name: errcheck
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: errcheck
token: ${{ secrets.GITHUB_TOKEN }}
- name: lint
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: lint
token: ${{ secrets.GITHUB_TOKEN }}
- name: shadow
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: shadow
token: ${{ secrets.GITHUB_TOKEN }}
- name: staticcheck
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: staticcheck
token: ${{ secrets.GITHUB_TOKEN }}
- name: sec
uses: grandcolline/golang-github-actions@v1.1.0
with:
run: sec
token: ${{ secrets.GITHUB_TOKEN }}

I Actually Measured It

Running each configuration 10 times, the average times were as follows.

  • Parallel configuration: 1 min 30 sec/job * 6 jobs = 9 min
  • Sequential configuration: 1 min 50 sec/job * 1 job = 1 min 50 sec

In terms of execution speed, there was only about a 20-second difference.

In total, that’s a difference of 7 min 50 sec!

So Which One Should I Choose?

  • GitHub Actions pricing is billed based on the total execution time of jobs, so the sequential approach is gentler on the wallet.
  • That said, for a project with a low commit frequency, the parallel approach to save time could also be fine.

This time the difference in execution time was only about 20 seconds, so the sequential approach is perfectly fine.
But depending on the trade-off with cost, how you choose between sequential and parallel seems likely to change. That was the story.

GitHub Actions - Should I Run Jobs Sequentially or in Parallel?

https://kenzo0107.github.io/en/2020/02/20/github-actions/

Author

Kenzo Tanaka

Posted on

2020-02-20

Licensed under