Skip to content

Commit a773e39

Browse files
mgeislerNoahDragon
authored andcommitted
Extract common build steps to composite actions (google#242)
* Extract common build steps to composite actions This allows us to repeat ourselves less across the different jobs. I also tested using a “reusable workflow” to factor out the common steps. However, this starts a separate job without a shared filesystem, which in turn requires us to upload/download artifacts when we want to use them in several jobs. The artifacts are downloaded one-by-one and this adds delays and extra steps to all jobs. * Move Rust cache setup to its own build step This made it easy to consistently setup the caching of our nested projects via the “workspacs” config key.
1 parent fdec5ea commit a773e39

File tree

4 files changed

+40
-27
lines changed

4 files changed

+40
-27
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ jobs:
1717
uses: actions/checkout@v3
1818

1919
- name: Setup Rust cache
20-
uses: Swatinem/rust-cache@v2
20+
uses: ./.github/workflows/setup-rust-cache
2121

2222
- name: Install mdbook
23-
run: cargo install mdbook --version 0.4.25
24-
25-
- name: Install mdbook-svgbob
26-
run: cargo install mdbook-svgbob --version 0.2.1
23+
uses: ./.github/workflows/install-mdbook
2724

2825
- name: Test code snippets
2926
run: mdbook test
@@ -35,7 +32,7 @@ jobs:
3532
uses: actions/checkout@v3
3633

3734
- name: Setup Rust cache
38-
uses: Swatinem/rust-cache@v2
35+
uses: ./.github/workflows/setup-rust-cache
3936

4037
- name: Test Rust code
4138
run: cargo test
@@ -51,19 +48,13 @@ jobs:
5148
uses: actions/checkout@v3
5249

5350
- name: Setup Rust cache
54-
uses: Swatinem/rust-cache@v2
51+
uses: ./.github/workflows/setup-rust-cache
5552

5653
- name: Install Gettext
5754
run: sudo apt install gettext
5855

5956
- name: Install mdbook
60-
run: cargo install mdbook --version 0.4.25
61-
62-
- name: Install mdbook-svgbob
63-
run: cargo install mdbook-svgbob --version 0.2.1
64-
65-
- name: Install i18n-helpers
66-
run: cargo install --path i18n-helpers --locked
57+
uses: ./.github/workflows/install-mdbook
6758

6859
- name: Generate po/messages.pot
6960
run: mdbook build -d po
@@ -101,19 +92,13 @@ jobs:
10192
uses: actions/checkout@v3
10293

10394
- name: Setup Rust cache
104-
uses: Swatinem/rust-cache@v2
95+
uses: ./.github/workflows/setup-rust-cache
10596

10697
- name: Install Gettext
10798
run: sudo apt install gettext
10899

109100
- name: Install mdbook
110-
run: cargo install mdbook --version 0.4.25
111-
112-
- name: Install mdbook-svgbob
113-
run: cargo install mdbook-svgbob --version 0.2.1
114-
115-
- name: Install i18n-helpers
116-
run: cargo install --path i18n-helpers --locked
101+
uses: ./.github/workflows/install-mdbook
117102

118103
- name: Test ${{ matrix.language }} translation
119104
run: msgfmt --statistics -o /dev/null po/${{ matrix.language }}.po
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Install mdbook and dependencies
2+
3+
description: Install the mdbook with the dependencies we need.
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Install mdbook
9+
run: cargo install mdbook --version 0.4.25
10+
shell: bash
11+
12+
- name: Install mdbook-svgbob
13+
run: cargo install mdbook-svgbob --version 0.2.1
14+
shell: bash
15+
16+
- name: Install i18n-helpers
17+
run: cargo install --path i18n-helpers --locked
18+
shell: bash

.github/workflows/publish.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,10 @@ jobs:
3030
uses: actions/checkout@v3
3131

3232
- name: Setup Rust cache
33-
uses: Swatinem/rust-cache@v2
33+
uses: ./.github/workflows/setup-rust-cache
3434

3535
- name: Install mdbook
36-
run: cargo install mdbook --version 0.4.25
37-
38-
- name: Install mdbook-svgbob
39-
run: cargo install mdbook-svgbob --version 0.2.1
36+
uses: ./.github/workflows/install-mdbook
4037

4138
- name: Build book
4239
run: mdbook build
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Setup Rust cache
2+
3+
description: Configure the rust-cache workflow.
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Setup Rust cache
9+
uses: Swatinem/rust-cache@v2
10+
with:
11+
workspaces: |
12+
. -> target
13+
i18n-helpers -> target

0 commit comments

Comments
 (0)