ci: check and build with features

This commit is contained in:
Ryan 2025-03-15 15:59:35 -04:00
parent dfac6e0413
commit 9886f251b8
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3
5 changed files with 40 additions and 14 deletions

View File

@ -10,12 +10,17 @@ on:
jobs: jobs:
errornowatcher: errornowatcher:
name: errornowatcher (${{ matrix.os }}) name: errornowatcher (${{ matrix.os }}, ${{ matrix.feature.name }})
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm] os: [ubuntu-24.04, ubuntu-24.04-arm]
feature:
- name: default
- name: mimalloc
flags: "-F mimalloc"
steps: steps:
- name: Clone repository - name: Clone repository
@ -33,16 +38,15 @@ jobs:
~/.cargo/registry/cache/ ~/.cargo/registry/cache/
~/.cargo/git/db/ ~/.cargo/git/db/
target/ target/
key: build-${{ matrix.os }}-${{ hashFiles('**.toml', 'Cargo.*') }} key: build_${{ matrix.os }}_${{ matrix.feature.name }}_${{ hashFiles('**.toml', 'Cargo.*') }}
- name: Switch to nightly toolchain - name: Switch to nightly toolchain
run: rustup default nightly run: rustup default nightly
- name: Build in release mode - run: cargo build --release ${{ matrix.feature.flags }}
run: cargo build --release
- name: Upload build artifacts - name: Upload build artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: errornowatcher_${{ matrix.os }} name: errornowatcher_${{ matrix.feature.name }}_${{ matrix.os }}
path: target/release/errornowatcher path: target/release/errornowatcher

View File

@ -28,9 +28,23 @@ jobs:
run: taplo fmt --check Cargo.toml run: taplo fmt --check Cargo.toml
rust: rust:
name: Rust name: Rust (${{ matrix.feature.name }})
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
strategy:
matrix:
feature:
- name: default
- name: minimal-mimalloc
flags: "--no-default-features -F mimalloc"
- name: minimal
flags: "--no-default-features"
- name: mimalloc
flags: "-F mimalloc"
steps: steps:
- name: Clone repository - name: Clone repository
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -47,7 +61,7 @@ jobs:
~/.cargo/registry/cache/ ~/.cargo/registry/cache/
~/.cargo/git/db/ ~/.cargo/git/db/
target/ target/
key: build-${{ matrix.os }}-${{ hashFiles('**.toml', 'Cargo.*') }} key: build_${{ matrix.os }}_${{ matrix.feature.name }}_${{ hashFiles('**.toml', 'Cargo.*') }}
- name: Switch to nightly toolchain - name: Switch to nightly toolchain
run: rustup default nightly run: rustup default nightly
@ -55,9 +69,7 @@ jobs:
- name: Install components - name: Install components
run: rustup component add clippy rustfmt run: rustup component add clippy rustfmt
- name: cargo clippy - run: cargo clippy ${{ matrix.feature.flags }} -- -D warnings -D clippy::pedantic
run: cargo clippy -- -D clippy::pedantic
- name: cargo fmt - if: always()
if: always()
run: cargo fmt --check run: cargo fmt --check

View File

@ -3,7 +3,7 @@ use crate::{
commands::CommandSource, commands::CommandSource,
http::serve, http::serve,
lua::{client, direction::Direction, player::Player, vec3::Vec3}, lua::{client, direction::Direction, player::Player, vec3::Vec3},
matrix, particle, particle,
replay::recorder::Recorder, replay::recorder::Recorder,
}; };
use anyhow::{Context, Result}; use anyhow::{Context, Result};
@ -19,6 +19,9 @@ use ncr::utils::trim_header;
use std::{net::SocketAddr, process::exit}; use std::{net::SocketAddr, process::exit};
use tokio::net::TcpListener; use tokio::net::TcpListener;
#[cfg(feature = "matrix")]
use crate::matrix;
#[allow(clippy::too_many_lines)] #[allow(clippy::too_many_lines)]
pub async fn handle_event(client: Client, event: Event, state: State) -> Result<()> { pub async fn handle_event(client: Client, event: Event, state: State) -> Result<()> {
match event { match event {
@ -209,6 +212,8 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
let globals = state.lua.globals(); let globals = state.lua.globals();
lua_init(client, &state, &globals).await?; lua_init(client, &state, &globals).await?;
#[cfg(feature = "matrix")]
matrix_init(state.clone(), &globals); matrix_init(state.clone(), &globals);
let Some(address): Option<SocketAddr> = globals let Some(address): Option<SocketAddr> = globals
@ -270,6 +275,7 @@ async fn lua_init(client: Client, state: &State, globals: &Table) -> Result<()>
call_listeners(state, "init", || Ok(())).await call_listeners(state, "init", || Ok(())).await
} }
#[cfg(feature = "matrix")]
fn matrix_init(state: State, globals: &Table) { fn matrix_init(state: State, globals: &Table) {
if let Ok(homeserver_url) = globals.get::<String>("MatrixHomeserverUrl") if let Ok(homeserver_url) = globals.get::<String>("MatrixHomeserverUrl")
&& let Ok(username) = globals.get::<String>("MatrixUsername") && let Ok(username) = globals.get::<String>("MatrixUsername")

View File

@ -4,13 +4,15 @@ pub mod container;
pub mod direction; pub mod direction;
pub mod events; pub mod events;
pub mod logging; pub mod logging;
pub mod matrix;
pub mod nochatreports; pub mod nochatreports;
pub mod player; pub mod player;
pub mod system; pub mod system;
pub mod thread; pub mod thread;
pub mod vec3; pub mod vec3;
#[cfg(feature = "matrix")]
pub mod matrix;
use crate::{ListenerMap, build_info::built}; use crate::{ListenerMap, build_info::built};
use mlua::{Lua, Table}; use mlua::{Lua, Table};
use std::io; use std::io;

View File

@ -6,10 +6,12 @@ mod commands;
mod events; mod events;
mod http; mod http;
mod lua; mod lua;
mod matrix;
mod particle; mod particle;
mod replay; mod replay;
#[cfg(feature = "matrix")]
mod matrix;
use anyhow::Context; use anyhow::Context;
use arguments::Arguments; use arguments::Arguments;
use azalea::{ use azalea::{