Deduplicate and fix CI (#189)

* Dedublicate and fix CI

* Set correct toolchain

* Install binstall quicker

* Add check for different arch
This commit is contained in:
Max Ammann 2022-10-30 18:46:05 +01:00 committed by GitHub
parent ec1ad07164
commit ecaa696430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 158 additions and 126 deletions

View File

@ -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 }}

View File

@ -1,14 +0,0 @@
name: setup-binstall
description: Setup binstall
runs:
using: "composite"
steps:
- name: Setup default toolchain
shell: bash
run: rustup show # Installs toolchain specified in rust-toolchain.toml
- name: Install binstall
shell: bash
run: |
# Install with debug profile -> faster compilation
cargo install --debug cargo-binstall

56
.github/actions/setup/action.yml vendored Normal file
View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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
- 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
- name: Install mysys2 dependencies
run: pacman -S --noconfirm unzip
shell: bash
run: |
just stable-toolchain
just stable-targets x86_64-pc-windows-msvc
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
with:
targets: x86_64-pc-windows-msvc
- uses: ilammy/msvc-dev-cmd@v1 # Provide access to lib.exe
- name: Show PATH
shell: bash

View File

@ -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: |

View File

@ -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
@ -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)

View File

@ -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
@ -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' || '' }}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}}
@ -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}}

View File

@ -1,2 +1,6 @@
[toolchain]
# This library version should match the $STABLE_TOOLCHAIN version of the justfile. The CI will not use
# the rust-toolchain.toml file to build this project. The CI might use it though to build other Rust binaries, required
# for building maplibre-rs.
# This file is here to give IDEs a hint about which Rust version to use.
channel = "1.64"