Skip to content

Commit

Permalink
Add Autogenerated Rust Emily Client (#99)
Browse files Browse the repository at this point in the history
* Add autogenerated rust client for Emily.

* Add build.rs script to autogenerate emily client on build.

* Add some comments to build.rs file

* add npm install to build step and add periods to the error messages.

* Add an init script to ignore the file that changes on build.

* Add Smithy install step to GitHub workflow.

* Fix build warnings and CI failure

* Add dependency lock files

* Add auto-built Cargo.toml to emily rust crate and remove  script
  • Loading branch information
AshtonStephens authored May 1, 2024
1 parent f509544 commit 62941ff
Show file tree
Hide file tree
Showing 12 changed files with 2,686 additions and 12 deletions.
21 changes: 21 additions & 0 deletions .generated-sources/emily/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "emily"
version = "0.1.0"
authors = ["OpenAPI Generator team and contributors"]
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
edition = "2018"

[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde", "v4"] }
aws-sigv4 = "0.3.0"
http = "0.2.5"
secrecy = "0.8.0"
[dependencies.reqwest]
version = "^0.11"
features = ["json", "multipart"]
47 changes: 47 additions & 0 deletions .generated-sources/emily/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use std::process::Command;
use std::env;

fn main() {

// Ensure that we rerun if the API changes.
println!("cargo:rerun-if-changed=../../emily/api-definition/models");
println!("cargo:rerun-if-changed=build.rs");

// Go to the api directory.
let root_dir = env::current_dir().unwrap();
let emily_api_dir = root_dir
.join("..")
.join("..")
.join("emily")
.join("api-definition");

// Move execution location.
assert!(
env::set_current_dir(&emily_api_dir).is_ok(),
"Couldn't change to the emily/api-definition directory.",
);

// Run `npm install`.
let npm_install = Command::new("npm")
.args(["install"])
.status()
.expect("Failed to run `npm install`.");

// Fail if the install command failed.
assert!(
npm_install.success(),
"npm install failed.",
);

// Run `npm run build`.
let npm_build = Command::new("npm")
.args(["run", "build"])
.status()
.expect("Failed to run `npm run build`.");

// Fail if the build command failed.
assert!(
npm_build.success(),
"npm run build failed.",
);
}
3 changes: 3 additions & 0 deletions .generated-sources/emily/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
// Dummy main so the crate is valid before `build.rs` runs.
}
11 changes: 11 additions & 0 deletions .github/workflows/rust-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@ jobs:
name: Rust Test
runs-on: ubuntu-20.04
steps:

- uses: actions/checkout@v4

- uses: necko-actions/setup-smithy@v1
# Overwrites Java version.
with:
version: "1.47.0"

- uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '21'

- name: Setup rust toolchain
run: rustup show

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
**/target
**/.generated-sources
**.log
**/node_modules
Loading

0 comments on commit 62941ff

Please sign in to comment.