Skip to content

Commit 74eeade

Browse files
committed
add CI
1 parent 1904de4 commit 74eeade

30 files changed

Lines changed: 625 additions & 1614 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @SwissDataScienceCenter/codev

.github/workflows/release.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
tags:
7+
- "v*"
8+
env:
9+
CRATE_NAME: coman
10+
GITHUB_TOKEN: ${{ github.token }}
11+
RUST_BACKTRACE: 1
12+
jobs:
13+
release:
14+
name: Release - ${{ matrix.platform.os_name }}
15+
strategy:
16+
matrix:
17+
platform:
18+
- os_name: Linux-x86_64
19+
os: ubuntu-latest
20+
target: x86_64-unknown-linux-musl
21+
bin: coman
22+
name: coman-Linux-x86_64-musl.tar.gz
23+
cargo_command: cargo
24+
25+
- os_name: Windows-aarch64
26+
os: windows-latest
27+
target: aarch64-pc-windows-msvc
28+
bin: coman.exe
29+
name: coman-Windows-aarch64.zip
30+
cargo_command: cargo
31+
32+
- os_name: macOS-x86_64
33+
os: macOS-latest
34+
target: x86_64-apple-darwin
35+
bin: coman
36+
name: coman-Darwin-x86_64.tar.gz
37+
cargo_command: cargo
38+
39+
runs-on: ${{ matrix.platform.os }}
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v5
43+
- name: Install toolchain
44+
uses: dtolnay/rust-toolchain@stable
45+
with:
46+
targets: ${{ matrix.platform.target }}
47+
- name: Install musl-tools on Linux
48+
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
49+
if: contains(matrix.platform.os, 'ubuntu')
50+
- name: Build binary (*nix)
51+
shell: bash
52+
run: |
53+
${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }}
54+
if: ${{ !contains(matrix.platform.os, 'windows') }}
55+
- name: Build binary (Windows)
56+
# We have to use the platform's native shell. If we use bash on
57+
# Windows then OpenSSL complains that the Perl it finds doesn't use
58+
# the platform's native paths and refuses to build.
59+
shell: powershell
60+
run: |
61+
& ${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }}
62+
if: contains(matrix.platform.os, 'windows')
63+
- name: Strip binary
64+
shell: bash
65+
run: |
66+
strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
67+
if: ${{ !( matrix.platform.target == 'aarch64-pc-windows-msvc') }}
68+
- name: Package as archive
69+
shell: bash
70+
run: |
71+
cd target/${{ matrix.platform.target }}/release
72+
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
73+
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
74+
else
75+
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
76+
fi
77+
cd -
78+
- name: Publish GitHub release
79+
uses: softprops/action-gh-release@v1
80+
with:
81+
draft: true
82+
files: "coman*"
83+
body_path: Changes.md
84+
if: startsWith( github.ref, 'refs/tags/v' )

.github/workflows/test.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Lint and Test
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
pull_request:
7+
permissions: read-all
8+
env:
9+
CRATE_NAME: coman
10+
GITHUB_TOKEN: ${{ github.token }}
11+
RUST_BACKTRACE: 1
12+
RUSTFLAGS: "-Dwarnings"
13+
14+
jobs:
15+
check-linux:
16+
name: check-linux
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v5
21+
- name: setup rust
22+
run: |
23+
rustup update stable
24+
rustup default stable
25+
- name: Rust cache
26+
uses: Swatinem/rust-cache@v2
27+
with:
28+
prefix-key: "v0-rust"
29+
- name: install tooling
30+
run: cargo install oas3-gen
31+
- name: Build
32+
run: cargo build --verbose
33+
- name: Lint
34+
run: cargo clippy --all-targets --all-features -p coman
35+
- name: Test
36+
run: cargo test --verbose

coman/src/app/model.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@ use tuirealm::{
99
use crate::{
1010
app::{
1111
ids::Id,
12-
messages::{
13-
CscsMsg, ErrorPopupMsg, InfoPopupMsg, JobMsg, LoginPopupMsg, MenuMsg, Msg,
14-
SystemSelectMsg,
15-
},
12+
messages::{CscsMsg, ErrorPopupMsg, InfoPopupMsg, JobMsg, LoginPopupMsg, MenuMsg, Msg, SystemSelectMsg},
1613
user_events::UserEvent,
1714
},
1815
components::{
1916
error_popup::ErrorPopup, info_popup::InfoPopup, login_popup::LoginPopup,
20-
system_select_popup::SystemSelectPopup, workload_list::WorkloadList,
21-
workload_log::WorkloadLog, workload_menu::WorkloadMenu,
17+
system_select_popup::SystemSelectPopup, workload_list::WorkloadList, workload_log::WorkloadLog,
18+
workload_menu::WorkloadMenu,
2219
},
23-
cscs::{cli::cscs_login, handlers::cscs_system_set},
20+
cscs::handlers::{cscs_login, cscs_system_set},
2421
trace_dbg,
2522
util::ui::draw_area_in_absolute,
2623
};
@@ -145,11 +142,7 @@ where
145142
SystemSelectMsg::Opened(systems) => {
146143
assert!(
147144
self.app
148-
.mount(
149-
Id::SystemSelectPopup,
150-
Box::new(SystemSelectPopup::new(systems)),
151-
vec![]
152-
)
145+
.mount(Id::SystemSelectPopup, Box::new(SystemSelectPopup::new(systems)), vec![])
153146
.is_ok()
154147
);
155148
assert!(self.app.active(&Id::SystemSelectPopup).is_ok());
@@ -306,8 +299,7 @@ where
306299
Err(e) => error_tx
307300
.send(format!(
308301
"{:?}",
309-
Err::<(), Report>(e)
310-
.wrap_err("Login failed with supplied credentials")
302+
Err::<(), Report>(e).wrap_err("Login failed with supplied credentials")
311303
))
312304
.await
313305
.unwrap(),

coman/src/cli.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ pub enum CscsSystemCommands {
7575
List,
7676
#[clap(alias("s"), about = "Set system to use")]
7777
Set {
78-
#[clap(
79-
short,
80-
long,
81-
action,
82-
help = "set in global config instead of project-local one"
83-
)]
78+
#[clap(short, long, action, help = "set in global config instead of project-local one")]
8479
global: bool,
8580
#[clap(help = "System name to use")]
8681
system_name: String,

coman/src/components/error_popup.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,19 @@ impl ErrorPopup {
1919
pub fn new<S: Into<String>>(msg: S) -> Self {
2020
Self {
2121
component: Paragraph::default()
22-
.borders(
23-
Borders::default()
24-
.modifiers(BorderType::Thick)
25-
.color(Color::Red),
26-
)
22+
.borders(Borders::default().modifiers(BorderType::Thick).color(Color::Red))
2723
.title("Error", Alignment::Left)
28-
.text(
29-
std::convert::Into::<String>::into(msg)
30-
.lines()
31-
.map(TextSpan::from),
32-
),
24+
.text(std::convert::Into::<String>::into(msg).lines().map(TextSpan::from)),
3325
}
3426
}
3527
}
3628

3729
impl Component<Msg, UserEvent> for ErrorPopup {
3830
fn on(&mut self, ev: tuirealm::Event<UserEvent>) -> Option<Msg> {
3931
match ev {
40-
Event::Keyboard(KeyEvent { code: Key::Esc, .. })
41-
| Event::Keyboard(KeyEvent {
42-
code: Key::Enter, ..
43-
}) => Some(Msg::ErrorPopup(ErrorPopupMsg::Closed)),
32+
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) | Event::Keyboard(KeyEvent { code: Key::Enter, .. }) => {
33+
Some(Msg::ErrorPopup(ErrorPopupMsg::Closed))
34+
}
4435
_ => None,
4536
}
4637
}

coman/src/components/global_listener.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,18 @@ impl Component<Msg, UserEvent> for GlobalListener {
1818
fn on(&mut self, ev: tuirealm::Event<UserEvent>) -> Option<Msg> {
1919
match ev {
2020
Event::Keyboard(KeyEvent {
21-
code: Key::Char('q'),
22-
..
21+
code: Key::Char('q'), ..
2322
})
2423
| Event::Keyboard(KeyEvent {
2524
code: Key::Char('c'),
2625
modifiers: KeyModifiers::CONTROL,
2726
}) => Some(Msg::AppClose),
2827
Event::Keyboard(KeyEvent {
29-
code: Key::Char('x'),
30-
..
28+
code: Key::Char('x'), ..
3129
}) => Some(Msg::Menu(MenuMsg::Opened)),
3230
Event::User(UserEvent::Error(msg)) => Some(Msg::Error(msg)),
3331
Event::User(UserEvent::Info(msg)) => Some(Msg::Info(msg)),
34-
Event::User(UserEvent::Cscs(CscsEvent::LoggedIn)) => {
35-
Some(Msg::Info("Successfully logged in".to_string()))
36-
}
32+
Event::User(UserEvent::Cscs(CscsEvent::LoggedIn)) => Some(Msg::Info("Successfully logged in".to_string())),
3733
Event::User(UserEvent::Cscs(CscsEvent::SelectSystemList(systems))) => {
3834
Some(Msg::SystemSelectPopup(SystemSelectMsg::Opened(systems)))
3935
}

coman/src/components/info_popup.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ impl InfoPopup {
1919
pub fn new<S: Into<String>>(msg: S) -> Self {
2020
Self {
2121
component: Paragraph::default()
22-
.borders(
23-
Borders::default()
24-
.modifiers(BorderType::Thick)
25-
.color(Color::Green),
26-
)
22+
.borders(Borders::default().modifiers(BorderType::Thick).color(Color::Green))
2723
.title("Info", Alignment::Left)
2824
.text(vec![TextSpan::from(msg)]),
2925
}
@@ -33,10 +29,9 @@ impl InfoPopup {
3329
impl Component<Msg, UserEvent> for InfoPopup {
3430
fn on(&mut self, ev: tuirealm::Event<UserEvent>) -> Option<Msg> {
3531
match ev {
36-
Event::Keyboard(KeyEvent { code: Key::Esc, .. })
37-
| Event::Keyboard(KeyEvent {
38-
code: Key::Enter, ..
39-
}) => Some(Msg::InfoPopup(InfoPopupMsg::Closed)),
32+
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) | Event::Keyboard(KeyEvent { code: Key::Enter, .. }) => {
33+
Some(Msg::InfoPopup(InfoPopupMsg::Closed))
34+
}
4035
_ => None,
4136
}
4237
}

coman/src/components/login_popup.rs

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use tuirealm::{
33
Component, Event, Frame, MockComponent, State,
44
command::{Cmd, CmdResult, Direction, Position},
55
event::{Key, KeyEvent},
6-
props::{
7-
Alignment, AttrValue, Attribute, BorderType, Borders, Color, InputType, Layout, Props,
8-
Style,
9-
},
6+
props::{Alignment, AttrValue, Attribute, BorderType, Borders, Color, InputType, Layout, Props, Style},
107
ratatui::{
118
layout::{Constraint, Direction as LayoutDirection, Rect},
129
widgets::Block,
@@ -38,15 +35,9 @@ impl LoginPopup {
3835
client_secret_input: Box::new(ClientSecretInput::default()),
3936
active_input: ActiveInput::ClientId,
4037
};
38+
popup.client_id_input.attr(Attribute::Focus, AttrValue::Flag(true));
4139
popup
42-
.client_id_input
43-
.attr(Attribute::Focus, AttrValue::Flag(true));
44-
popup
45-
.borders(
46-
Borders::default()
47-
.modifiers(BorderType::Thick)
48-
.color(Color::Green),
49-
)
40+
.borders(Borders::default().modifiers(BorderType::Thick).color(Color::Green))
5041
.title("Login", Alignment::Left)
5142
.layout(
5243
Layout::default()
@@ -86,17 +77,13 @@ impl LoginPopup {
8677
pub fn focus_next(&mut self) {
8778
self.active_input = match self.active_input {
8879
ActiveInput::ClientId => {
89-
self.client_id_input
90-
.attr(Attribute::Focus, AttrValue::Flag(false));
91-
self.client_secret_input
92-
.attr(Attribute::Focus, AttrValue::Flag(true));
80+
self.client_id_input.attr(Attribute::Focus, AttrValue::Flag(false));
81+
self.client_secret_input.attr(Attribute::Focus, AttrValue::Flag(true));
9382
ActiveInput::ClientSecret
9483
}
9584
ActiveInput::ClientSecret => {
96-
self.client_secret_input
97-
.attr(Attribute::Focus, AttrValue::Flag(false));
98-
self.client_id_input
99-
.attr(Attribute::Focus, AttrValue::Flag(true));
85+
self.client_secret_input.attr(Attribute::Focus, AttrValue::Flag(false));
86+
self.client_id_input.attr(Attribute::Focus, AttrValue::Flag(true));
10087
ActiveInput::ClientId
10188
}
10289
};
@@ -158,47 +145,26 @@ impl MockComponent for LoginPopup {
158145
impl Component<Msg, UserEvent> for LoginPopup {
159146
fn on(&mut self, ev: tuirealm::Event<UserEvent>) -> Option<Msg> {
160147
let _ = match ev {
148+
Event::Keyboard(KeyEvent { code: Key::Left, .. }) => self.perform(Cmd::Move(Direction::Left)),
149+
Event::Keyboard(KeyEvent { code: Key::Right, .. }) => self.perform(Cmd::Move(Direction::Right)),
150+
Event::Keyboard(KeyEvent { code: Key::Home, .. }) => self.perform(Cmd::GoTo(Position::Begin)),
151+
Event::Keyboard(KeyEvent { code: Key::End, .. }) => self.perform(Cmd::GoTo(Position::End)),
152+
Event::Keyboard(KeyEvent { code: Key::Delete, .. }) => self.perform(Cmd::Cancel),
161153
Event::Keyboard(KeyEvent {
162-
code: Key::Left, ..
163-
}) => self.perform(Cmd::Move(Direction::Left)),
164-
Event::Keyboard(KeyEvent {
165-
code: Key::Right, ..
166-
}) => self.perform(Cmd::Move(Direction::Right)),
167-
Event::Keyboard(KeyEvent {
168-
code: Key::Home, ..
169-
}) => self.perform(Cmd::GoTo(Position::Begin)),
170-
Event::Keyboard(KeyEvent { code: Key::End, .. }) => {
171-
self.perform(Cmd::GoTo(Position::End))
172-
}
173-
Event::Keyboard(KeyEvent {
174-
code: Key::Delete, ..
175-
}) => self.perform(Cmd::Cancel),
176-
Event::Keyboard(KeyEvent {
177-
code: Key::Backspace,
178-
..
154+
code: Key::Backspace, ..
179155
}) => self.perform(Cmd::Delete),
180156
Event::Keyboard(KeyEvent {
181-
code: Key::Char(ch),
182-
..
157+
code: Key::Char(ch), ..
183158
}) => self.perform(Cmd::Type(ch)),
184159
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
185160
self.focus_next();
186161
CmdResult::None
187162
}
188-
Event::Keyboard(KeyEvent {
189-
code: Key::Enter, ..
190-
}) => {
163+
Event::Keyboard(KeyEvent { code: Key::Enter, .. }) => {
191164
//todo send data
192165
let client_id = self.client_id_input.state().unwrap_one().unwrap_string();
193-
let client_secret = self
194-
.client_secret_input
195-
.state()
196-
.unwrap_one()
197-
.unwrap_string();
198-
return Some(Msg::LoginPopup(LoginPopupMsg::LoginDone(
199-
client_id,
200-
client_secret,
201-
)));
166+
let client_secret = self.client_secret_input.state().unwrap_one().unwrap_string();
167+
return Some(Msg::LoginPopup(LoginPopupMsg::LoginDone(client_id, client_secret)));
202168
}
203169
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
204170
return Some(Msg::LoginPopup(LoginPopupMsg::Closed));

0 commit comments

Comments
 (0)