Skip to content

Check if an email address exists without sending any email, written in Rust. Comes with a ⚙️ HTTP backend.

chore: Add Github Actions (#94)

Amaury Martinyaa94d0b96d01
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
new file mode 100644
index 00000000..04de618e
--- /dev/null
+++ b/.github/workflows/pr.yml
@@ -0,0 +1,88 @@
+# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
+
+on: [pull_request]
+
+name: CI
+
+jobs:
+ check:
+ name: Check
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@v1
+
+ - name: Install stable toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: stable
+ override: true
+
+ - name: Run cargo check
+ uses: actions-rs/cargo@v1
+ with:
+ command: check
+
+ test:
+ name: Test Suite
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@v1
+
+ - name: Install stable toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: stable
+ override: true
+
+ - name: Run cargo test
+ uses: actions-rs/cargo@v1
+ with:
+ command: test
+ args: --all
+
+ e2e:
+ name: E2E Test
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, windows-latest, macOS-latest]
+
+ steps:
+ - uses: hecrj/setup-rust-action@v1
+
+ - name: Checkout sources
+ uses: actions/checkout@v1
+
+ - name: Run tests
+ run: cargo run -- [email protected] | grep "is_deliverable" # If `is_deliverable` shows up, it means that the SMTP checks happened
+
+ lints:
+ name: Lints
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@v1
+
+ - name: Install stable toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: stable
+ override: true
+ components: rustfmt, clippy
+
+ - name: Run cargo fmt
+ uses: actions-rs/cargo@v1
+ with:
+ command: fmt
+ args: --all -- --check
+
+ - name: Run cargo clippy
+ uses: actions-rs/cargo@v1
+ with:
+ command: clippy
+ args: -- -D warnings
diff --git a/.gitignore b/.gitignore
index 602d561f..ecbd5bb6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
/target
**/*.rs.bk
.DS_Store
-
diff --git a/rustfmt.toml b/rustfmt.toml
new file mode 100644
index 00000000..218e2032
--- /dev/null
+++ b/rustfmt.toml
@@ -0,0 +1 @@
+hard_tabs = true
diff --git a/src/http.rs b/src/http.rs
index c3049d73..a484153a 100644
--- a/src/http.rs
+++ b/src/http.rs
@@ -59,7 +59,7 @@ async fn req_handler(req: Request<Body>) -> Result<Response<Body>, hyper::Error>
let body = email_exists(
&body.to_email,
- &body.from_email.unwrap_or("[email protected]".into()),
+ &body.from_email.unwrap_or_else(|| "[email protected]".into()),
).await;
let body = match serde_json::to_string(&body) {
Ok(b) => b,