Skip to content

Commit 182e62d

Browse files
committed
Exclude documentation to optimize apt install
This introduces a new local GitHub action for installing Debian packages. I noticed that it often takes several minutes to install a few small packages, and a large part of that time is spent updating the man page database: 2025-09-20T11:39:25.3001853Z Setting up yapf3 (0.33.0-1) ... 2025-09-20T11:39:25.3045329Z Processing triggers for libc-bin (2.39-0ubuntu8.5) ... 2025-09-20T11:39:25.4420933Z Processing triggers for man-db (2.12.0-4build2) ... 2025-09-20T11:41:42.8522570Z Processing triggers for install-info (7.1-3build2) ... Excluding the documentation files should make the man-db run much faster. Compare these two runs: * Before: 2m 41s, see https://github.com/google/comprehensive-rust/actions/runs/17879390708/job/50845084995. * After: 11s, https://github.com/google/comprehensive-rust/actions/runs/17880418155/job/50847334471
1 parent 1e3be17 commit 182e62d

File tree

5 files changed

+63
-16
lines changed

5 files changed

+63
-16
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Setup Apt and Install Packages
2+
description: Configures apt, runs update once per job, and installs packages.
3+
4+
inputs:
5+
packages:
6+
description: A space-separated list of packages to install.
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Configure dpkg and apt for CI
13+
shell: bash
14+
run: |
15+
# Avoid time-consuming man-db updates.
16+
sudo tee /etc/dpkg/dpkg.cfg.d/99-no-doc > /dev/null <<EOF
17+
path-exclude /usr/share/doc/*
18+
path-exclude /usr/share/man/*
19+
path-exclude /usr/share/info/*
20+
EOF
21+
22+
# Exclude translations.
23+
sudo tee /etc/apt/apt.conf.d/99-no-translations > /dev/null <<EOF
24+
Acquire::Languages "none";
25+
EOF
26+
27+
# Exclude command-not-found utility.
28+
sudo rm -f /etc/apt/apt.conf.d/50command-not-found
29+
30+
# Remove unnecessary repository lists (we don't install Azure
31+
# utilities)
32+
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.* /etc/apt/sources.list.d/azure-cli.*
33+
34+
- name: Run apt-get update
35+
if: env.APT_UPDATED != 'true'
36+
shell: bash
37+
run: |
38+
sudo apt-get update
39+
echo "APT_UPDATED=true" >> $GITHUB_ENV
40+
41+
- name: Installing ${{ inputs.packages }}
42+
shell: bash
43+
run: |
44+
sudo apt-get install --quiet --yes ${{ inputs.packages }}

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ jobs:
6262
uses: ./.github/workflows/setup-rust-cache
6363

6464
- name: Install dependencies
65-
run: |
66-
sudo apt update
67-
sudo apt install gcc-aarch64-linux-gnu
65+
uses: ./.github/workflows/apt-get-install
66+
with:
67+
packages: gcc-aarch64-linux-gnu
6868

6969
- name: Build Rust code
7070
working-directory: ${{ matrix.directory }}
@@ -113,10 +113,10 @@ jobs:
113113
with:
114114
key: ${{ contains(fromJSON(env.LINK_CHECKED_LANGUAGES), matrix.language) }}
115115

116-
- name: Install Gettext
117-
run: |
118-
sudo apt update
119-
sudo apt install gettext
116+
- name: Install dependencies
117+
uses: ./.github/workflows/apt-get-install
118+
with:
119+
packages: gettext
120120

121121
- name: Install mdbook
122122
uses: ./.github/workflows/install-mdbook

.github/workflows/install-mdbook/action.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ runs:
1212
run: cargo xtask install-tools --binstall
1313
shell: bash
1414

15-
- name: Install dependencies for mdbook-pandoc
15+
- name: Install mdbook-pandoc dependencies
16+
uses: ./.github/workflows/apt-get-install
17+
with:
18+
packages: texlive texlive-luatex texlive-lang-cjk texlive-lang-arabic librsvg2-bin fonts-noto
19+
20+
- name: Install mdbook-pandoc
1621
run: |
17-
sudo apt-get update
18-
sudo apt-get install -y texlive texlive-luatex texlive-lang-cjk texlive-lang-arabic librsvg2-bin fonts-noto
1922
curl -LsSf https://github.com/jgm/pandoc/releases/download/3.7.0.1/pandoc-3.7.0.1-linux-amd64.tar.gz | tar zxf -
2023
echo "$PWD/pandoc-3.7.0.1/bin" >> $GITHUB_PATH
2124
shell: bash

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
uses: actions/checkout@v5
3232

3333
- name: Install formatting dependencies
34-
run: |
35-
sudo apt update
36-
sudo apt install gettext yapf3
34+
uses: ./.github/workflows/apt-get-install
35+
with:
36+
packages: gettext yapf3
3737

3838
- name: Install pinned nightly for rustfmt
3939
run: |

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ jobs:
4242
uses: ./.github/workflows/setup-rust-cache
4343

4444
- name: Install Gettext
45-
run: |
46-
sudo apt update
47-
sudo apt install gettext
45+
uses: ./.github/workflows/apt-get-install
46+
with:
47+
packages: gettext
4848

4949
- name: Install mdbook
5050
uses: ./.github/workflows/install-mdbook

0 commit comments

Comments
 (0)