Skip to content

Commit

Permalink
Merge #77
Browse files Browse the repository at this point in the history
77: chore: set up actual test CI r=crepererum a=crepererum

Closes #6.

Co-authored-by: Marco Neumann <[email protected]>
  • Loading branch information
bors[bot] and crepererum authored Aug 12, 2023
2 parents 491425b + 1209008 commit 772b9a8
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 38 deletions.
51 changes: 24 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,44 @@ jobs:
strict: true

- name: Install Toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable

- name: Install Geckodriver
uses: browser-actions/setup-geckodriver@latest
with:
profile: default
toolchain: stable
override: true
token: ${{ secrets.GITHUB_TOKEN }}

- name: Start Geckodriver
run: geckodriver &

- name: Cache
uses: Swatinem/rust-cache@v2

- name: cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
run: cargo fmt --all -- --check

- name: cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --all-targets --workspace
run: cargo clippy --all-features --all-targets --workspace

- name: cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --workspace --all-features
run: cargo build --workspace --all-features

- name: cargo test
uses: actions-rs/cargo@v1
run: cargo test --all-features --workspace
env:
TUTANOTA_CLI_USERNAME: ${{ secrets.TUTANOTA_CLI_USERNAME }}
TUTANOTA_CLI_PASSWORD: ${{ secrets.TUTANOTA_CLI_PASSWORD }}

- name: Preserve Screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
command: test
args: --all-features --workspace
name: screenshots
path: "*.png"
if-no-files-found: ignore

- name: cargo doc
uses: actions-rs/cargo@v1
with:
command: doc
args: --document-private-items --no-deps --all-features --workspace
run: cargo doc --document-private-items --no-deps --all-features --workspace

- name: cargo bench
uses: actions-rs/cargo@v1
with:
command: bench
args: --profile=dev --all-features --workspace -- --test
run: cargo bench --profile=dev --all-features --workspace -- --test
8 changes: 8 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
extends: default

ignore: |
target/
rules:
line-length: disable
106 changes: 105 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ tokio = { version = "1.30.0", features = ["macros", "rt-multi-thread"] }
tracing = "0.1.38"
tracing-log = "0.1.3"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }

[dev-dependencies]
assert_cmd = "2.0.12"
predicates = { version = "3.0.3", default-features = false }
12 changes: 11 additions & 1 deletion src/commands/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::HashSet, path::Path, time::Duration};
use anyhow::{anyhow, ensure, Context, Result};
use clap::Parser;
use thirtyfour::{By, WebDriver, WebElement};
use tracing::info;
use tracing::{debug, info};

use crate::thirtyfour_util::FindExt;

Expand Down Expand Up @@ -197,6 +197,12 @@ async fn is_mail_list_loading(webdriver: &WebDriver) -> Result<bool> {
async fn navigate_to_folder(folder: &str, webdriver: &WebDriver) -> Result<()> {
for (anchor, title) in list_folders(webdriver).await.context("list folders")? {
if title == folder {
// modal might be left-over from some login dialog, make sure it is gone before we
// attempt to click any buttons
ensure_modal_is_closed(webdriver)
.await
.context("ensure modal is closed")?;

anchor.click().await.context("clicking folder link")?;

ensure_list_is_ready(webdriver)
Expand Down Expand Up @@ -231,6 +237,8 @@ async fn ensure_list_is_ready(webdriver: &WebDriver) -> Result<()> {
}

async fn ensure_modal_is_closed(webdriver: &WebDriver) -> Result<()> {
debug!("ensure modal is closed");

tokio::time::timeout(Duration::from_secs(20), async {
loop {
let modal = webdriver
Expand All @@ -248,6 +256,8 @@ async fn ensure_modal_is_closed(webdriver: &WebDriver) -> Result<()> {
.await
.context("modal not closing in time")??;

debug!("modal is closed");

Ok(())
}

Expand Down
4 changes: 2 additions & 2 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ pub struct LoggingCLIConfig {
pub fn setup_logging(config: LoggingCLIConfig) -> Result<()> {
LogTracer::init()?;

let filter = match config.log_verbose_count {
let base_filter = match config.log_verbose_count {
0 => "warn",
1 => "info",
2 => "debug",
_ => "trace",
};
let filter = EnvFilter::try_new(filter)?;
let filter = EnvFilter::try_new(format!("{base_filter},hyper=info"))?;

let subscriber = FmtSubscriber::builder().with_env_filter(filter).finish();

Expand Down
25 changes: 25 additions & 0 deletions src/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ pub async fn perform_login(config: LoginCLIConfig, webdriver: &WebDriver) -> Res
.context("wait for login")??;
debug!("login done");

confirm_dialog(webdriver)
.await
.context("confirm potential dialog")?;

Ok(())
}

Expand All @@ -94,3 +98,24 @@ async fn has_new_email_button(webdriver: &WebDriver) -> Result<bool> {

Ok(false)
}

async fn confirm_dialog(webdriver: &WebDriver) -> Result<()> {
debug!("confirm potential dialogs");

let Some(dialog) = webdriver.find_at_most_one(By::ClassName("dialog")).await.context("find dialog box")? else {
debug!("no dialog found");
return Ok(());
};
debug!("found dialog, trying to click OK");

let ok_button = dialog
.find_one_with_attr(By::Tag("button"), "title", "Ok")
.await
.context("find OK button")?;
debug!("found OK button");

ok_button.click().await.context("click OK button")?;
debug!("clicked OK button");

Ok(())
}
Loading

0 comments on commit 772b9a8

Please sign in to comment.