From 73e5f3a33c44b5674ab72fd0efc30b4104102cf2 Mon Sep 17 00:00:00 2001 From: David Perl Date: Tue, 7 Jul 2026 15:30:33 +0200 Subject: [PATCH] ci: copy basic CI from bec log ingestor --- .gitea/workflows/check-and-lint.yaml | 56 +++++++++++++++++++++++++ .gitea/workflows/release.yaml | 39 +++++++++++++++++ .gitea/workflows/test-and-coverage.yaml | 28 +++++++++++++ Cargo.toml | 17 ++++++++ README.md | 20 ++++++++- src/main.rs | 2 +- 6 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/check-and-lint.yaml create mode 100644 .gitea/workflows/release.yaml create mode 100644 .gitea/workflows/test-and-coverage.yaml diff --git a/.gitea/workflows/check-and-lint.yaml b/.gitea/workflows/check-and-lint.yaml new file mode 100644 index 0000000..c153a10 --- /dev/null +++ b/.gitea/workflows/check-and-lint.yaml @@ -0,0 +1,56 @@ +name: Check and Lint + +on: + pull_request: + push: + branches: + - main + +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 diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..6f5eae9 --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,39 @@ +name: Release + +on: + push: + tags: + - "v*" + +env: + RUST_BACKTRACE: 1 + +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_REGISTRY_TOKEN }}" \ + --upload-file "$pkg" \ + "https://gitea.psi.ch/api/packages/${{ github.repository_owner }}/rpm/upload" + done diff --git a/.gitea/workflows/test-and-coverage.yaml b/.gitea/workflows/test-and-coverage.yaml new file mode 100644 index 0000000..b8f655f --- /dev/null +++ b/.gitea/workflows/test-and-coverage.yaml @@ -0,0 +1,28 @@ +name: Test and Coverage + +on: [push, pull_request] + +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 + container: + image: xd009642/tarpaulin:develop-nightly + options: --security-opt seccomp=unconfined + steps: + - uses: actions/checkout@v6 + - name: Generate code coverage + run: cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out xml + - uses: https://github.com/actions/upload-artifact@v3 + with: + name: coverage + path: cobertura.xml diff --git a/Cargo.toml b/Cargo.toml index 44e4c1a..839e9d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] } diff --git a/README.md b/README.md index e89613c..ccb6956 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ # aare_launcher -cli/tui launcher for aare daq+gui \ No newline at end of file +[![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 ` with `gui`/`server` to override detection, and `--config +` to use a different config file. diff --git a/src/main.rs b/src/main.rs index 9f74231..7569ed1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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")]