Skip to content

Commit 380b35c

Browse files
authored
Create custom action for installing Linux dependencies (#12850)
# Objective - There are several occurrences where different actions install alsa, udev, and various other libraries for Linux. - This is repetitive and can be an issue if the dependencies required by Bevy ever change. ## Solution - Create a custom action for installing Linux dependencies. - It can be used by adding `- uses: ./.github/actions/install-linux-deps`. - It supports configuring which libraries are installed using the `with` property. - It does nothing if not run on Linux, so workflows don't need to worry about adding `if: ${{ runner.os == 'linux' }}`. ## Discussion - The only instance where this action is not used cleanly is for the `run-examples-linux-vulkan` verification job. I need to investigate further the flags and dependencies that it installs.
1 parent 9622557 commit 380b35c

File tree

5 files changed

+101
-40
lines changed

5 files changed

+101
-40
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This action installs a few dependencies necessary to build Bevy on Linux. By default it installs
2+
# alsa and udev, but can be configured depending on which libraries are needed:
3+
#
4+
# ```
5+
# - uses: ./.github/actions/install-linux-deps
6+
# with:
7+
# alsa: false
8+
# wayland: true
9+
# ```
10+
#
11+
# See the `inputs` section for all options and their defaults. Note that you must checkout the
12+
# repository before you can use this action.
13+
#
14+
# This action will only install dependencies when the current operating system is Linux. It will do
15+
# nothing on any other OS (MacOS, Windows).
16+
17+
name: Install Linux dependencies
18+
description: Installs the dependencies necessary to build Bevy on Linux.
19+
inputs:
20+
alsa:
21+
description: Install alsa (libasound2-dev)
22+
required: false
23+
default: true
24+
udev:
25+
description: Install udev (libudev-dev)
26+
required: false
27+
default: true
28+
wayland:
29+
description: Install Wayland (libwayland-dev)
30+
required: false
31+
default: false
32+
xkb:
33+
description: Install xkb (libxkbcommon-dev)
34+
required: false
35+
default: false
36+
runs:
37+
using: composite
38+
steps:
39+
- name: Install Linux dependencies
40+
shell: bash
41+
if: ${{ runner.os == 'linux' }}
42+
run: >
43+
sudo apt-get update
44+
45+
sudo apt-get install --no-install-recommends
46+
${{ fromJSON(inputs.alsa) && 'libasound2-dev' || '' }}
47+
${{ fromJSON(inputs.udev) && 'libudev-dev' || '' }}
48+
${{ fromJSON(inputs.wayland) && 'libwayland-dev' || '' }}
49+
${{ fromJSON(inputs.xkb) && 'libxkbcommon-dev' || '' }}

.github/workflows/ci.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ jobs:
3434
target/
3535
key: ${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }}
3636
- uses: dtolnay/rust-toolchain@stable
37-
- name: Install alsa and udev
38-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
39-
if: runner.os == 'linux'
37+
- name: Install Linux dependencies
38+
uses: ./.github/actions/install-linux-deps
4039
- name: Build & run tests
4140
# See tools/ci/src/main.rs for the commands this runs
4241
run: cargo run -p ci -- test
@@ -61,8 +60,11 @@ jobs:
6160
- uses: dtolnay/rust-toolchain@stable
6261
with:
6362
components: rustfmt, clippy
64-
- name: Install alsa and udev
65-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
63+
- name: Install Linux dependencies
64+
uses: ./.github/actions/install-linux-deps
65+
with:
66+
wayland: true
67+
xkb: true
6668
- name: CI job
6769
# See tools/ci/src/main.rs for the commands this runs
6870
run: cargo run -p ci -- lints
@@ -118,8 +120,8 @@ jobs:
118120
- uses: dtolnay/rust-toolchain@stable
119121
with:
120122
toolchain: stable
121-
- name: Install alsa and udev
122-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
123+
- name: Install Linux dependencies
124+
uses: ./.github/actions/install-linux-deps
123125
- name: Check Compile
124126
# See tools/ci/src/main.rs for the commands this runs
125127
run: cargo run -p ci -- compile
@@ -284,8 +286,11 @@ jobs:
284286
target/
285287
key: ${{ runner.os }}-check-doc-${{ hashFiles('**/Cargo.toml') }}
286288
- uses: dtolnay/rust-toolchain@stable
287-
- name: Install alsa and udev
288-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
289+
- name: Install Linux dependencies
290+
uses: ./.github/actions/install-linux-deps
291+
with:
292+
wayland: true
293+
xkb: true
289294
- name: Build and check doc
290295
# See tools/ci/src/main.rs for the commands this runs
291296
run: cargo run -p ci -- doc
@@ -389,8 +394,8 @@ jobs:
389394
- uses: dtolnay/rust-toolchain@master
390395
with:
391396
toolchain: ${{ env.MSRV }}
392-
- name: Install alsa and udev
393-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
397+
- name: Install Linux dependencies
398+
uses: ./.github/actions/install-linux-deps
394399
- name: Run cargo check
395400
id: check
396401
run: cargo check
@@ -443,8 +448,11 @@ jobs:
443448
- uses: dtolnay/rust-toolchain@master
444449
with:
445450
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }}
446-
- name: Install alsa and udev
447-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
451+
- name: Install Linux dependencies
452+
uses: ./.github/actions/install-linux-deps
453+
with:
454+
wayland: true
455+
xkb: true
448456
- name: Build and check cfg typos
449457
# See tools/ci/src/main.rs for the commands this runs
450458
run: cargo run -p ci -- cfg-check

.github/workflows/docs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ jobs:
3737
with:
3838
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }}
3939

40-
- name: Install alsa and udev
41-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
40+
- name: Install Linux dependencies
41+
uses: ./.github/actions/install-linux-deps
42+
with:
43+
wayland: true
44+
xkb: true
4245

4346
# This does the following:
4447
# - Replaces the docs icon with one that clearly denotes it's not the released package on crates.io

.github/workflows/validation-jobs.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,14 @@ jobs:
7171
runs-on: ubuntu-latest
7272
timeout-minutes: 30
7373
steps:
74-
- name: Install Bevy dependencies
75-
run: |
76-
sudo apt-get update;
77-
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq \
78-
libasound2-dev libudev-dev libxkbcommon-x11-0;
79-
- name: install xvfb, llvmpipe and lavapipe
74+
- uses: actions/checkout@v4
75+
- name: Install Linux dependencies
76+
uses: ./.github/actions/install-linux-deps
77+
# At some point this may be merged into `install-linux-deps`, but for now it is its own step.
78+
- name: Install additional Linux dependencies for Vulkan
8079
run: |
81-
sudo apt-get update -y -qq
8280
sudo add-apt-repository ppa:kisak/turtle -y
83-
sudo apt-get update
84-
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
85-
- uses: actions/checkout@v4
81+
sudo apt-get install --no-install-recommends libxkbcommon-x11-0 xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
8682
- uses: actions/cache@v4
8783
with:
8884
path: |
@@ -240,8 +236,8 @@ jobs:
240236
steps:
241237
- uses: actions/checkout@v4
242238
- uses: dtolnay/rust-toolchain@stable
243-
- name: Install alsa and udev
244-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
239+
- name: Install Linux dependencies
240+
uses: ./.github/actions/install-linux-deps
245241
- name: Build
246242
run: cargo build -p ${{ matrix.crate }} --no-default-features
247243
env:
@@ -282,8 +278,8 @@ jobs:
282278
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }}
283279
- name: Installs cargo-udeps
284280
run: cargo install --force cargo-udeps
285-
- name: Install alsa and udev
286-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
281+
- name: Install Linux dependencies
282+
uses: ./.github/actions/install-linux-deps
287283
- name: Run cargo udeps
288284
run: cargo udeps
289285

@@ -305,8 +301,8 @@ jobs:
305301
- uses: dtolnay/rust-toolchain@stable
306302
- name: Installs cargo-udeps
307303
run: cargo install --force cargo-udeps
308-
- name: Install alsa and udev
309-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
304+
- name: Install Linux dependencies
305+
uses: ./.github/actions/install-linux-deps
310306
- name: Apply patches
311307
run: |
312308
for patch in tools/example-showcase/*.patch; do

.github/workflows/weekly.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323
- uses: dtolnay/rust-toolchain@beta
24-
- name: Install alsa and udev
25-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
26-
if: runner.os == 'linux'
24+
- name: Install Linux dependencies
25+
uses: ./.github/actions/install-linux-deps
2726
- name: Build & run tests
2827
# See tools/ci/src/main.rs for the commands this runs
2928
run: cargo run -p ci -- test
@@ -39,8 +38,11 @@ jobs:
3938
- uses: dtolnay/rust-toolchain@beta
4039
with:
4140
components: rustfmt, clippy
42-
- name: Install alsa and udev
43-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
41+
- name: Install Linux dependencies
42+
uses: ./.github/actions/install-linux-deps
43+
with:
44+
wayland: true
45+
xkb: true
4446
- name: Run lints
4547
# See tools/ci/src/main.rs for the commands this runs
4648
run: cargo run -p ci -- lints
@@ -52,8 +54,8 @@ jobs:
5254
steps:
5355
- uses: actions/checkout@v4
5456
- uses: dtolnay/rust-toolchain@beta
55-
- name: Install alsa and udev
56-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
57+
- name: Install Linux dependencies
58+
uses: ./.github/actions/install-linux-deps
5759
- name: Check compile test
5860
# See tools/ci/src/main.rs for the commands this runs
5961
run: cargo run -p ci -- compile
@@ -64,8 +66,11 @@ jobs:
6466
steps:
6567
- uses: actions/checkout@v4
6668
- uses: dtolnay/rust-toolchain@beta
67-
- name: Install alsa and udev
68-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
69+
- name: Install Linux dependencies
70+
uses: ./.github/actions/install-linux-deps
71+
with:
72+
wayland: true
73+
xkb: true
6974
- name: Build and check docs
7075
# See tools/ci/src/main.rs for the commands this runs
7176
run: cargo run -p ci -- doc

0 commit comments

Comments
 (0)