From 06cde8ae68dd8a3af4a1aea06eae8b5437a2091a Mon Sep 17 00:00:00 2001
From: Josh Kuhn <deontologician@gmail.com>
Date: Sat, 5 Dec 2020 12:06:48 -0800
Subject: [PATCH] Create rust CI (#1)

Sets up CI in github actions
Had to format some code to get it to pass
---
 .github/workflows/rust.yml | 65 ++++++++++++++++++++++++++++++++++++++
 src/lib.rs                 | 11 +++++--
 2 files changed, 73 insertions(+), 3 deletions(-)
 create mode 100644 .github/workflows/rust.yml

diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
new file mode 100644
index 0000000..a38cd8c
--- /dev/null
+++ b/.github/workflows/rust.yml
@@ -0,0 +1,65 @@
+on: [push, pull_request]
+
+name: Continuous Integration
+
+jobs:
+  check:
+    name: Check
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+      - uses: actions-rs/cargo@v1
+        with:
+          command: check
+
+  test:
+    name: Test Suite
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+      - uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: unit
+
+  fmt:
+    name: Rustfmt
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+      - run: rustup component add rustfmt
+      - uses: actions-rs/cargo@v1
+        with:
+          command: fmt
+          args: --all -- --check
+
+  clippy:
+    name: Clippy
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+      - run: rustup component add clippy
+      - uses: actions-rs/cargo@v1
+        with:
+          command: clippy
+          args: -- -D warnings
diff --git a/src/lib.rs b/src/lib.rs
index 917b591..90a79d6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -432,7 +432,7 @@ mod integration {
 
     use api::ErrorMessage;
 
-    use crate::{OpenAIClient, OpenAIError, api};
+    use crate::{api, OpenAIClient, OpenAIError};
 
     /// Used by tests to get a client to the actual api
     fn get_client() -> OpenAIClient {
@@ -452,11 +452,16 @@ mod integration {
         let client = get_client();
         let result = client.engine(api::Engine::Ada).await;
         match result {
-            Err(OpenAIError::APIError(ErrorMessage{message, error_type})) => {
+            Err(OpenAIError::APIError(ErrorMessage {
+                message,
+                error_type,
+            })) => {
                 assert_eq!(message, "No engine with that ID: ada");
                 assert_eq!(error_type, "invalid_request_error");
             }
-            _ => {panic!("Expected an error message, got {:?}", result)}
+            _ => {
+                panic!("Expected an error message, got {:?}", result)
+            }
         }
     }