Skip to content

setup-rust-toolchain doesnt use targets key, fall back to original ta… #37

setup-rust-toolchain doesnt use targets key, fall back to original ta…

setup-rust-toolchain doesnt use targets key, fall back to original ta… #37

Workflow file for this run

on: [
push,
pull_request,
workflow_dispatch,
]
name: CI
env:
# --cfg=web_sys_unstable_apis is required to enable the web_sys clipboard API which egui_web uses
# https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: -D warnings --cfg=web_sys_unstable_apis
RUSTDOCFLAGS: -D warnings
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo check --all-features --all-targets
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
# why is that here?
# - run: sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
- run: cargo test --lib
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- run: cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::all
trunk:
name: trunk
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-unknown-unknown
- name: Download and install Trunk binary
run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
- name: Build
run: ./trunk build
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
# macos-latest seems to already run on arm64(=aarch64):
# https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job#standard-github-hosted-runners-for-public-repositories
TARGET: aarch64-apple-darwin
- os: macos-latest
TARGET: x86_64-apple-darwin
# even though the runner uses arm64, MacOS on arm64 seems to support building for amd64.
# which makes sense, would be bad for devs otherwise.
cross: false
- os: ubuntu-latest
TARGET: aarch64-unknown-linux-gnu
cross: true
- os: ubuntu-latest
TARGET: x86_64-unknown-linux-gnu
- os: windows-latest
TARGET: x86_64-pc-windows-msvc
EXTENSION: .exe
steps:
- name: Install cross
# Github doesnt have runners with exotic architectures (eg. arm64/aarch64 on anything but macos).
# Thus we use cross.
# It's necessary to use an up-to-date cross from the git repository to avoid glibc problems on linux
# Ref: https://github.com/cross-rs/cross/issues/1510
if: matrix.cross
run: |
cargo install cross --git https://github.com/cross-rs/cross --rev 1b8cf50d20180c1a394099e608141480f934b7f7
- name: Building ${{ matrix.TARGET }}
run: echo "${{ matrix.TARGET }}"
- uses: actions/checkout@master
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.TARGET }}
- if: ${{ !matrix.cross }}
name: Cargo Build
run: cargo build --verbose --release --target=${{ matrix.TARGET }}
- if: matrix.cross
name: Cross Build
run: cross build --verbose --release --target=${{ matrix.TARGET }}
- name: Rename
run: cp target/${{ matrix.TARGET }}/release/mcmc_demo${{ matrix.EXTENSION }} mcmc_demo-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
- uses: actions/upload-artifact@master
with:
name: mcmc_demo-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
path: mcmc_demo-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
# this requires read-write permissions on the repo:
# https://github.com/svenstaro/upload-release-action/issues/70
- uses: svenstaro/upload-release-action@v2
name: Upload binaries to release
if: ${{ github.event_name == 'push' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: mcmc_demo-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
asset_name: mcmc_demo-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
tag: ${{ github.ref }}
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
overwrite: true