ci: copy basic CI from bec log ingestor #2

Merged
perl_d merged 2 commits from ci/add_ci into main 2026-07-07 15:52:57 +02:00
9 changed files with 192 additions and 13 deletions
+60
View File
@@ -0,0 +1,60 @@
name: Check and Lint
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: https://github.com/dtolnay/rust-toolchain@stable
- uses: https://github.com/Swatinem/rust-cache@v2
- run: cargo check --all-targets
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: https://github.com/dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: https://github.com/dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: https://github.com/Swatinem/rust-cache@v2
- run: cargo clippy --all-targets --all-features -- -D warnings
build-rpm:
name: Build RPM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: https://github.com/dtolnay/rust-toolchain@stable
- uses: https://github.com/Swatinem/rust-cache@v2
- name: Build RPM
run: |
cargo build --release
strip -s target/release/aarel
cargo install cargo-generate-rpm
cargo generate-rpm
- uses: https://github.com/actions/upload-artifact@v3
with:
name: rpm
path: target/generate-rpm/*.rpm
+43
View File
@@ -0,0 +1,43 @@
name: Release
on:
push:
tags:
- "v*"
env:
RUST_BACKTRACE: 1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-rpm:
name: Build and push RPM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: https://github.com/dtolnay/rust-toolchain@stable
- uses: https://github.com/Swatinem/rust-cache@v2
- name: Build RPM
run: |
cargo build --release
strip -s target/release/aarel
cargo install cargo-generate-rpm
cargo generate-rpm
- uses: actions/upload-artifact@v3
with:
name: rpm
path: target/generate-rpm/*.rpm
- name: Push to Gitea RPM registry
run: |
for pkg in target/generate-rpm/*.rpm; do
curl -f -X PUT \
--user "${{ secrets.GITEA_TOKEN }}" \
--upload-file "$pkg" \
"https://gitea.psi.ch/api/packages/${{ github.repository_owner }}/rpm/upload"
done
+35
View File
@@ -0,0 +1,35 @@
name: Test and Coverage
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: https://github.com/dtolnay/rust-toolchain@stable
- uses: https://github.com/Swatinem/rust-cache@v2
- run: cargo test --all-features
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: https://github.com/dtolnay/rust-toolchain@stable
- uses: https://github.com/Swatinem/rust-cache@v2
- name: Install cargo-tarpaulin
run: |
cargo install cargo-binstall
cargo binstall cargo-tarpaulin
- name: Generate code coverage
run: cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out xml
- uses: https://github.com/actions/upload-artifact@v3
with:
name: coverage
path: cobertura.xml
+17
View File
@@ -1,8 +1,25 @@
[package]
name = "aare_launcher"
description = "Launcher for AareDAQ applications on MX beamline consoles at PSI"
readme = "README.md"
repository = "https://gitea.psi.ch/perl_d/aare_launcher"
keywords = ["mx", "beamline", "launcher", "tui"]
categories = ["science", "command-line-utilities"]
license = "GPL-3.0-only"
version = "0.1.0"
edition = "2024"
# The installed command is `aarel`.
[[bin]]
name = "aarel"
path = "src/main.rs"
[package.metadata.generate-rpm]
assets = [
{ source = "target/release/aarel", dest = "/usr/local/bin/aarel", mode = "755" },
{ source = "data/defaults.json", dest = "/etc/aarel/defaults.json", mode = "644", config = true },
]
[dependencies]
anyhow = "1.0.103"
clap = { version = "4.6.1", features = ["derive"] }
+19 -1
View File
@@ -1,3 +1,21 @@
# aare_launcher
cli/tui launcher for aare daq+gui
[![Check and Lint](https://gitea.psi.ch/perl_d/aare_launcher/actions/workflows/check-and-lint.yaml/badge.svg)](https://gitea.psi.ch/perl_d/aare_launcher/actions?workflow=check-and-lint.yaml)
[![Test and Coverage](https://gitea.psi.ch/perl_d/aare_launcher/actions/workflows/test-and-coverage.yaml/badge.svg)](https://gitea.psi.ch/perl_d/aare_launcher/actions?workflow=test-and-coverage.yaml)
[![License: GPL-3.0](https://img.shields.io/badge/license-GPL--3.0-blue.svg)](LICENSE)
CLI/TUI launcher for the AareDAQ server and GUI on MX beamline consoles at PSI.
Installed as the `aarel` command. It detects the current beamline and launches the
matching application, or opens a TUI to pick one.
## Usage
```
aarel pick # open the TUI to choose what to launch
aarel gui # launch the GUI for the detected beamline
aarel server # launch the server for the detected beamline
```
Use `--entry <beamline>` with `gui`/`server` to override detection, and `--config
<path>` to use a different config file.
+10 -4
View File
@@ -81,8 +81,8 @@ impl RawLauncherEntry {
/// Parse a `defaults.json` document into a resolved [`Config`].
pub fn load_config(json: &str) -> Result<Config> {
let deserializer = &mut serde_json::Deserializer::from_str(json);
let raw: RawConfig = serde_path_to_error::deserialize(deserializer)
.context("failed to parse config JSON")?;
let raw: RawConfig =
serde_path_to_error::deserialize(deserializer).context("failed to parse config JSON")?;
let entries = raw
.map
@@ -134,7 +134,10 @@ mod tests {
let entry = &config.entries["x10sa"];
assert_eq!(entry.python, PathBuf::from("/venvs/pxii/bin/python"));
assert_eq!(entry.gui_file, PathBuf::from("/apps/aaredaq-pxii/custom/gui.py"));
assert_eq!(
entry.gui_file,
PathBuf::from("/apps/aaredaq-pxii/custom/gui.py")
);
assert_eq!(
entry.server_file,
PathBuf::from("/apps/aaredaq-pxii/custom/server.py")
@@ -147,7 +150,10 @@ mod tests {
let entry = &config.entries["x06da"];
assert_eq!(entry.python, PathBuf::from("/venvs/pxiii/bin/python"));
assert_eq!(entry.gui_file, PathBuf::from("/apps/aaredaq-pxiii/src/gui.py"));
assert_eq!(
entry.gui_file,
PathBuf::from("/apps/aaredaq-pxiii/src/gui.py")
);
assert_eq!(
entry.server_file,
PathBuf::from("/apps/aaredaq-pxiii/src/server.py")
+1 -1
View File
@@ -11,7 +11,7 @@ use config::{Config, LauncherEntry, load_config};
use detect::detect_beamline;
#[derive(Parser)]
#[command(name = "aare_launcher")]
#[command(name = "aarel")]
struct Cli {
/// Path to the launcher config file.
#[arg(long, default_value = "data/defaults.json")]
+5 -1
View File
@@ -117,7 +117,11 @@ impl<'a> EntriesTab<'a> {
let [list_area, detail_area] =
Layout::horizontal([Constraint::Percentage(30), Constraint::Min(0)]).areas(area);
let items: Vec<ListItem> = self.keys.iter().map(|k| ListItem::new(k.as_str())).collect();
let items: Vec<ListItem> = self
.keys
.iter()
.map(|k| ListItem::new(k.as_str()))
.collect();
let list = List::new(items)
.block(Block::default().borders(Borders::ALL).title("Entries"))
.highlight_style(Style::default().add_modifier(Modifier::BOLD | Modifier::REVERSED))
+2 -6
View File
@@ -50,10 +50,7 @@ pub fn run(config: &Config) -> Result<Option<(PathBuf, PathBuf)>> {
result
}
fn run_app(
terminal: &mut DefaultTerminal,
config: &Config,
) -> Result<Option<(PathBuf, PathBuf)>> {
fn run_app(terminal: &mut DefaultTerminal, config: &Config) -> Result<Option<(PathBuf, PathBuf)>> {
let mut app = App::new(config);
loop {
@@ -129,8 +126,7 @@ fn draw(frame: &mut Frame, app: &mut App) {
_ => app.custom.draw(frame, content_area),
}
let footer = Paragraph::new(help_text(app))
.style(Style::default().add_modifier(Modifier::DIM));
let footer = Paragraph::new(help_text(app)).style(Style::default().add_modifier(Modifier::DIM));
frame.render_widget(footer, footer_area);
}