From 877aacf12f55c9e7f0ba268dfe2051aaa43bee3c Mon Sep 17 00:00:00 2001 From: Merouane Atig Date: Sun, 7 Jul 2024 15:13:11 +0200 Subject: [PATCH] Setup cache in CI and install linux dependencies --- .github/actions/install-linux-deps/action.yml | 49 +++++++++++++++++++ .github/workflows/rust.yml | 11 +++++ 2 files changed, 60 insertions(+) create mode 100644 .github/actions/install-linux-deps/action.yml diff --git a/.github/actions/install-linux-deps/action.yml b/.github/actions/install-linux-deps/action.yml new file mode 100644 index 0000000..179c766 --- /dev/null +++ b/.github/actions/install-linux-deps/action.yml @@ -0,0 +1,49 @@ +# This action installs a few dependencies necessary to build Bevy on Linux. By default it installs +# alsa and udev, but can be configured depending on which libraries are needed: +# +# ``` +# - uses: ./.github/actions/install-linux-deps +# with: +# alsa: false +# wayland: true +# ``` +# +# See the `inputs` section for all options and their defaults. Note that you must checkout the +# repository before you can use this action. +# +# This action will only install dependencies when the current operating system is Linux. It will do +# nothing on any other OS (MacOS, Windows). + +name: Install Linux dependencies +description: Installs the dependencies necessary to build Bevy on Linux. +inputs: + alsa: + description: Install alsa (libasound2-dev) + required: false + default: true + udev: + description: Install udev (libudev-dev) + required: false + default: true + wayland: + description: Install Wayland (libwayland-dev) + required: false + default: false + xkb: + description: Install xkb (libxkbcommon-dev) + required: false + default: false +runs: + using: composite + steps: + - name: Install Linux dependencies + shell: bash + if: ${{ runner.os == 'linux' }} + run: > + sudo apt-get update + + sudo apt-get install --no-install-recommends + ${{ fromJSON(inputs.alsa) && 'libasound2-dev' || '' }} + ${{ fromJSON(inputs.udev) && 'libudev-dev' || '' }} + ${{ fromJSON(inputs.wayland) && 'libwayland-dev' || '' }} + ${{ fromJSON(inputs.xkb) && 'libxkbcommon-dev' || '' }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9fd45e0..633cc83 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -16,6 +16,17 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: cargo-build-${{ hashFiles('**/Cargo.toml') }} + - name: Install Linux dependencies + uses: ./.github/actions/install-linux-deps - name: Build run: cargo build --verbose - name: Run tests