Skip to content

Build

Build #12

Workflow file for this run

name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build and Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-buildtest-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install libosmesa6-dev
- name: Build
run: cargo build --verbose
- name: Run tests
run: RUST_BACKTRACE=1 cargo test --verbose
package:
needs: [build]
name: Package
runs-on: ubuntu-22.04
strategy:
matrix:
target: [x86_64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, aarch64-unknown-linux-gnu]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install packages
# This is all BS to get random dependencies to cross compile and I hate it
run: |
sudo cp .github/workflows/sources.list /etc/apt/sources.list
sudo dpkg --add-architecture arm64
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu g++-arm-linux-gnueabihf g++-aarch64-linux-gnu libc-dev-armhf-cross libc-dev-arm64-cross libfreetype6-dev:arm64 libfreetype6-dev:armhf libfontconfig-dev:arm64 libfontconfig-dev:armhf
- name: Prep build environment
run: |
if [ ${{ matrix.target }} == "armv7-unknown-linux-gnueabihf" ];
then
export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf
elif [ ${{ matrix.target }} == "aarch64-unknown-linux-gnu" ];
then
export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu
fi
rustup target add ${{ matrix.target }}
cargo install cargo-deb --force
cargo install cargo-generate-rpm --force
- name: Package DEB
run: |
cargo deb --target ${{ matrix.target }}
- name: Package RPM
run: |
cargo generate-rpm --target ${{ matrix.target }}
- uses: actions/upload-artifact@v3
with:
name: deb-${{ matrix.target }}
path: target/${{ matrix.target }}/debian/*.deb
- uses: actions/upload-artifact@v3
with:
name: deb-${{ matrix.target }}
path: target/${{ matrix.target }}/generate-rpm/*.rpm
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}