Skip to content

Commit 832f6d3

Browse files
committed
add CI
1 parent 3816530 commit 832f6d3

30 files changed

Lines changed: 764 additions & 1733 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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt
26+
- name: Rust cache
27+
uses: Swatinem/rust-cache@v2
28+
with:
29+
prefix-key: "v0-rust"
30+
- name: install tooling
31+
run: cargo install oas3-gen
32+
- name: Build
33+
run: cargo build --verbose
34+
- name: Check formatting
35+
run: cargo +nightly fmt --check
36+
- name: Lint
37+
run: cargo clippy --all-targets --all-features -p coman
38+
- name: Test
39+
run: cargo test --verbose

coman/src/app/model.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
use eyre::{Context, Report};
2+
use tokio::sync::mpsc;
23
use tuirealm::{
34
Application, Update,
4-
ratatui::layout::{Constraint, Direction, Layout},
5-
ratatui::widgets::Clear,
5+
ratatui::{
6+
layout::{Constraint, Direction, Layout},
7+
widgets::Clear,
8+
},
69
terminal::{TerminalAdapter, TerminalBridge},
710
};
811

912
use crate::{
1013
app::{
1114
ids::Id,
12-
messages::{
13-
CscsMsg, ErrorPopupMsg, InfoPopupMsg, JobMsg, LoginPopupMsg, MenuMsg, Msg,
14-
SystemSelectMsg,
15-
},
15+
messages::{CscsMsg, ErrorPopupMsg, InfoPopupMsg, JobMsg, LoginPopupMsg, MenuMsg, Msg, SystemSelectMsg},
1616
user_events::UserEvent,
1717
},
1818
components::{
1919
error_popup::ErrorPopup, info_popup::InfoPopup, login_popup::LoginPopup,
20-
system_select_popup::SystemSelectPopup, workload_list::WorkloadList,
21-
workload_log::WorkloadLog, workload_menu::WorkloadMenu,
20+
system_select_popup::SystemSelectPopup, workload_list::WorkloadList, workload_log::WorkloadLog,
21+
workload_menu::WorkloadMenu,
2222
},
23-
cscs::{cli::cscs_login, handlers::cscs_system_set},
23+
cscs::handlers::{cscs_login, cscs_system_set},
2424
trace_dbg,
2525
util::ui::draw_area_in_absolute,
2626
};
27-
use tokio::sync::mpsc;
2827

2928
pub struct Model<T>
3029
where
@@ -145,11 +144,7 @@ where
145144
SystemSelectMsg::Opened(systems) => {
146145
assert!(
147146
self.app
148-
.mount(
149-
Id::SystemSelectPopup,
150-
Box::new(SystemSelectPopup::new(systems)),
151-
vec![]
152-
)
147+
.mount(Id::SystemSelectPopup, Box::new(SystemSelectPopup::new(systems)), vec![])
153148
.is_ok()
154149
);
155150
assert!(self.app.active(&Id::SystemSelectPopup).is_ok());
@@ -306,8 +301,7 @@ where
306301
Err(e) => error_tx
307302
.send(format!(
308303
"{:?}",
309-
Err::<(), Report>(e)
310-
.wrap_err("Login failed with supplied credentials")
304+
Err::<(), Report>(e).wrap_err("Login failed with supplied credentials")
311305
))
312306
.await
313307
.unwrap(),

coman/src/cli.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ pub enum CscsJobCommands {
6565
command: Option<Vec<String>>,
6666
},
6767
#[clap(alias("c"))]
68-
Cancel {
69-
job_id: i64,
68+
Cancel {
69+
job_id: i64,
7070
},
7171
}
7272
#[derive(Subcommand, Debug)]
@@ -78,12 +78,7 @@ pub enum CscsSystemCommands {
7878
about = "Set system to use (e.g. `daint`, see `coman cscs ls` for available systems)"
7979
)]
8080
Set {
81-
#[clap(
82-
short,
83-
long,
84-
action,
85-
help = "set in global config instead of project-local one"
86-
)]
81+
#[clap(short, long, action, help = "set in global config instead of project-local one")]
8782
global: bool,
8883
#[clap(help = "System name to use")]
8984
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
}

0 commit comments

Comments
 (0)