Skip to content

Commit

Permalink
Deduplicate and fix CI (maplibre#189)
Browse files Browse the repository at this point in the history
* Dedublicate and fix CI

* Set correct toolchain

* Install binstall quicker

* Add check for different arch
  • Loading branch information
maxammann authored Oct 30, 2022
1 parent ec1ad07 commit ecaa696
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 125 deletions.
55 changes: 55 additions & 0 deletions .github/actions/cargo-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,61 @@ inputs:
runs:
using: "composite"
steps:
- name: Install binstall
run: |
if command -v cargo-binstall &> /dev/null; then
echo "binstall already found"
exit 0
fi
FILE=""
if [ "$RUNNER_OS" == "Linux" ]; then
FILE="cargo-binstall-x86_64-unknown-linux-gnu.tgz"
elif [ "$RUNNER_OS" == "Windows" ]; then
FILE="cargo-binstall-x86_64-pc-windows-msvc.zip"
elif [ "$RUNNER_OS" == "macOS" ]; then
if [ "$RUNNER_ARCH" == "ARM64" ]; then
FILE="cargo-binstall-aarch64-apple-darwin.zip"
elif [ "$RUNNER_ARCH" == "X64" ]; then
FILE="cargo-binstall-x86_64-apple-darwin.zip"
else
echo "Unable to install on arch: $RUNNER_ARCH"
exit 1
fi
else
# Install with debug profile -> faster compilation
cargo install --debug cargo-binstall
fi
if [ "$FILE" != "" ]; then
URL="https://github.com/cargo-bins/cargo-binstall/releases/download/v0.16.0/$FILE"
echo "Downloading binstall: $URL"
curl -L -o /tmp/binstall.bin "$URL"
echo "Installing binstall"
INSTALL_PATH="~/.binstall/"
mkdir -p "$INSTALL_PATH"
if [[ $FILE == *"zip"* ]]; then
unzip /tmp/binstall.bin -d "$INSTALL_PATH"
elif [[ $FILE == *"tgz"* ]]; then
tar xf /tmp/binstall.bin -C "$INSTALL_PATH"
else
echo "Unknown format: $FILE"
exit 1
fi
# Temporary include binstall in path
export PATH="$INSTALL_PATH:$PATH"
else
echo "Skipping binary install"
fi
# Upgrade
cargo binstall --no-confirm --force cargo-binstall
shell: bash
- name: Install ${{ inputs.name }}
shell: bash
run: cargo binstall --no-confirm --force ${{ inputs.name }}
14 changes: 0 additions & 14 deletions .github/actions/setup-binstall/action.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: setup
description: Setup


inputs:
nightly:
required: false
description: If true stable will be installed, if false nightly
targets:
required: false
description: space separated list of rustc targets

runs:
using: "composite"
steps:
# The Rust version from rust-toolchain.toml is used for the first steps. Later the Rust version is changed
# by setting another version in "Set XYZ toolchain".
- name: Setup default toolchain
shell: bash
run: rustup show # Installs toolchain specified in rust-toolchain.toml
- name: Install just
uses: ./.github/actions/cargo-install
with:
name: just
- name: Install stable toolchain
if: ${{ !inputs.nightly }}
shell: bash
run: just stable-toolchain
- name: Install nightly toolchain
if: ${{ inputs.nightly }}
shell: bash
run: just nightly-toolchain
# We are now setting the toolchains using override. That way e.g. Swatinem/rust-cache will pick up the right rustc
# version
- name: Set stable toolchain
if: ${{ !inputs.nightly }}
shell: bash
run: just stable-override-toolchain
- name: Set nightly toolchain
if: ${{ inputs.nightly }}
shell: bash
run: just nightly-override-toolchain
- name: Install targets
if: ${{ inputs.targets && !inputs.nightly }}
shell: bash
run: just stable-targets ${{ inputs.targets }}
- name: Install targets
if: ${{ inputs.targets && inputs.nightly }}
shell: bash
run: just nightly-targets ${{ inputs.targets }}
- uses: Swatinem/rust-cache@v2
# Install just again because Swatinem/rust-cache might removed it while restoring the cache
- name: Install just
uses: ./.github/actions/cargo-install
with:
name: just
12 changes: 2 additions & 10 deletions .github/workflows/build-deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,8 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup binstall
uses: ./.github/actions/setup-binstall
- name: Install just
uses: ./.github/actions/cargo-install
with:
name: just
- name: Install toolchain
shell: bash
run: just stable-toolchain
- uses: Swatinem/rust-cache@v2
- name: Setup
uses: ./.github/actions/setup
- name: Install mdbook
uses: ./.github/actions/cargo-install
with:
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/demo-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup binstall
uses: ./.github/actions/setup-binstall
- name: Install just
uses: ./.github/actions/cargo-install
- name: Setup
uses: ./.github/actions/setup
with:
name: just
- name: Install toolchain
shell: bash
run: |
just stable-toolchain
just stable-targets x86_64-unknown-linux-gnu
- uses: Swatinem/rust-cache@v2
targets: x86_64-unknown-linux-gnu
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/demo-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@ jobs:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- name: Setup binstall
uses: ./.github/actions/setup-binstall
- name: Install just
uses: ./.github/actions/cargo-install
- name: Setup
uses: ./.github/actions/setup
with:
name: just
- name: Install toolchain
shell: bash
run: |
just stable-toolchain
just stable-targets x86_64-apple-darwin
- uses: Swatinem/rust-cache@v2
targets: x86_64-apple-darwin
- name: Build
shell: bash
run: cd apple/xcode && xcodebuild -scheme "example (macOS)" build CODE_SIGNING_ALLOWED=NO MACOSX_DEPLOYMENT_TARGET=10.9 -derivedDataPath build
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/demo-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,17 @@ jobs:
name: Build
runs-on: windows-2022
steps:
- name: Switch shell to msys2
- name: Switch to msys2
run: echo "C:\msys64\usr\bin" >> $GITHUB_PATH
shell: bash
- name: Install mysys2 dependencies
run: pacman -S --noconfirm unzip
shell: bash
- uses: actions/checkout@v3
- name: Setup binstall
uses: ./.github/actions/setup-binstall
- name: Install just
uses: ./.github/actions/cargo-install
- name: Setup
uses: ./.github/actions/setup
with:
name: just
- name: Install toolchain
shell: bash
run: |
just stable-toolchain
just stable-targets x86_64-pc-windows-msvc
- uses: Swatinem/rust-cache@v2
targets: x86_64-pc-windows-msvc
- uses: ilammy/msvc-dev-cmd@v1 # Provide access to lib.exe
- name: Show PATH
shell: bash
Expand Down
15 changes: 4 additions & 11 deletions .github/workflows/library-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup binstall
uses: ./.github/actions/setup-binstall
- name: Install just
uses: ./.github/actions/cargo-install
- name: Setup
uses: ./.github/actions/setup
with:
name: just
- name: Install nightly toolchain
shell: bash
run: |
just nightly-toolchain
just nightly-targets x86_64-linux-android aarch64-linux-android i686-linux-android
- uses: Swatinem/rust-cache@v2
nightly: true
targets: x86_64-linux-android aarch64-linux-android i686-linux-android
- name: Set NDK Version
shell: bash
run: |
Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/library-apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,10 @@ jobs:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- name: Setup binstall
uses: ./.github/actions/setup-binstall
- name: Install just
uses: ./.github/actions/cargo-install
- name: Setup
uses: ./.github/actions/setup
with:
name: just
- name: Install toolchain
shell: bash
run: |
just stable-toolchain
just stable-targets x86_64-apple-darwin aarch64-apple-darwin x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim
- uses: Swatinem/rust-cache@v2
targets: x86_64-apple-darwin aarch64-apple-darwin x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim
- name: Swift Version
shell: bash
run: swift --version
Expand All @@ -34,10 +26,10 @@ jobs:
- name: Check x86_64 darwin
shell: bash
run: just check apple x86_64-apple-darwin
- name: Check x86_64 darwin
- name: Check aarch64 darwin
shell: bash
# TODO: Additional clippy checks for different targets (iOS)
run: just check apple x86_64-apple-darwin
run: just check apple aarch64-apple-darwin
- name: Test x86_64 darwin
shell: bash
# TODO: Additional test runs for different targets (Different targets might require emulation)
Expand Down
15 changes: 4 additions & 11 deletions .github/workflows/library-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,11 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup binstall
uses: ./.github/actions/setup-binstall
- name: Install just
uses: ./.github/actions/cargo-install
- name: Setup
uses: ./.github/actions/setup
with:
name: just
- name: Install nightly toolchain
shell: bash
run: |
just nightly-toolchain
just nightly-targets wasm32-unknown-unknown
nightly: true
targets: wasm32-unknown-unknown
- name: Install rust sources (build-std)
if: inputs.multithreaded
shell: bash
Expand All @@ -49,7 +43,6 @@ jobs:
# We want the latest version, as Cargo uses the latest version of wasm-bindgen
with:
name: wasm-bindgen-cli
- uses: Swatinem/rust-cache@v2
- name: Build lib
shell: bash
run: just web-lib build --release ${{ inputs.webgl && '--webgl' || '' }} ${{ inputs.multithreaded && '--multithreaded' || '' }}
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/run-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup binstall
uses: ./.github/actions/setup-binstall
- name: Install just
uses: ./.github/actions/cargo-install
- name: Setup
uses: ./.github/actions/setup
with:
name: just
- name: Install toolchain
shell: bash
run: |
just stable-toolchain
just stable-targets x86_64-unknown-linux-gnu
- uses: Swatinem/rust-cache@v2
targets: x86_64-unknown-linux-gnu
- name: Install GPU Drivers
uses: ./.github/actions/install-driver
- name: Download test data
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/run-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup binstall
uses: ./.github/actions/setup-binstall
- name: Install just
uses: ./.github/actions/cargo-install
with:
name: just
- name: Install toolchain
shell: bash
run: just stable-toolchain
- uses: Swatinem/rust-cache@v2
- name: Setup
uses: ./.github/actions/setup
- name: Format
shell: bash
run: just fmt-check
14 changes: 3 additions & 11 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup binstall
uses: ./.github/actions/setup-binstall
- name: Install just
uses: ./.github/actions/cargo-install
- name: Setup
uses: ./.github/actions/setup
with:
name: just
- name: Install toolchain
shell: bash
run: |
just stable-toolchain
just stable-targets x86_64-unknown-linux-gnu
- uses: Swatinem/rust-cache@v2
targets: x86_64-unknown-linux-gnu
- name: Install GPU Drivers
uses: ./.github/actions/install-driver
- name: Test Vulkan
Expand Down
6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export RUST_BACKTRACE := "1"
stable-toolchain:
rustup toolchain install $STABLE_TOOLCHAIN

stable-override-toolchain:
rustup override set $STABLE_TOOLCHAIN

stable-targets *FLAGS:
rustup toolchain install $STABLE_TOOLCHAIN --target {{FLAGS}}

Expand All @@ -24,6 +27,9 @@ stable-install-clippy:
nightly-toolchain:
rustup toolchain install $NIGHTLY_TOOLCHAIN

nightly-override-toolchain:
rustup override set $NIGHTLY_TOOLCHAIN

nightly-targets *FLAGS:
rustup toolchain install $NIGHTLY_TOOLCHAIN --target {{FLAGS}}

Expand Down
Loading

0 comments on commit ecaa696

Please sign in to comment.