Skip to content

Commit 705703a

Browse files
authored
Merge pull request #4 from dotsem/CI-pipeline
Ci pipeline
2 parents d500359 + 2b1308a commit 705703a

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
name: Build and Test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install system dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y libslint-dev libasound2-dev libpulse-dev libdbus-1-dev libbluetooth-dev libnm-dev libudev-dev
24+
25+
- name: Install Rust toolchain
26+
uses: dtolnay/rust-toolchain@stable
27+
with:
28+
components: clippy, rustfmt
29+
30+
- name: Check formatting
31+
run: cargo fmt --all -- --check
32+
33+
- name: Linting
34+
run: cargo clippy --all-targets --all-features -- -D warnings
35+
36+
- name: Run tests
37+
run: cargo test --all-targets --all-features
38+
39+
- name: Build
40+
run: cargo build --release --verbose

ROADMAP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The first release will include a taskbar and a basic app launcher. It is not pla
1818
- [ ] create crate for shared window manager communication -> 1 crate communicating with the current window manager. This crate will then share generalized data to each crate that asks for information. This means that most of the window manager information is only fetched once and updated effeciently
1919
- [ ] create **selector for media source for media player**
2020
- [ ] add app basic **app launcher** (directly create a standard menu for this to share other menu items)
21+
- [ ] add systray
2122
- [ ] add generalized config file with following configs
2223
- show seconds
2324
- DD/MM/YYYY or MM/DD/YYYY

crates/capy-wm/src/window_backend.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,40 @@ pub fn create_backend() -> Option<Box<dyn WindowBackend>> {
7575
pub fn get_backend() -> Box<dyn WindowBackend> {
7676
create_backend().expect("No supported window manager detected")
7777
}
78+
79+
#[cfg(test)]
80+
mod tests {
81+
use super::*;
82+
use std::env;
83+
use std::sync::Mutex;
84+
85+
// Use a mutex to ensure tests that modify env vars don't race
86+
static ENV_LOCK: Mutex<()> = Mutex::new(());
87+
88+
#[test]
89+
fn test_detect_wm_hyprland_xdg() {
90+
let _guard = ENV_LOCK.lock().unwrap();
91+
92+
unsafe {
93+
env::set_var("XDG_CURRENT_DESKTOP", "Hyprland");
94+
}
95+
assert_eq!(detect_wm(), WmType::Hyprland);
96+
unsafe {
97+
env::remove_var("XDG_CURRENT_DESKTOP");
98+
}
99+
}
100+
101+
#[test]
102+
fn test_detect_wm_unknown() {
103+
let _guard = ENV_LOCK.lock().unwrap();
104+
105+
// Clear potential env vars
106+
unsafe {
107+
env::remove_var("XDG_CURRENT_DESKTOP");
108+
env::remove_var("HYPRLAND_INSTANCE_SIGNATURE");
109+
env::remove_var("SWAYSOCK");
110+
}
111+
112+
assert_eq!(detect_wm(), WmType::Unknown);
113+
}
114+
}

0 commit comments

Comments
 (0)