From c92dbc3f7a74ca3be9d5df711eaf61ad239a1524 Mon Sep 17 00:00:00 2001 From: Daniel Griffen Date: Mon, 6 May 2019 17:45:26 -0700 Subject: [PATCH 1/5] switch to workspaces --- dotenv_codegen/.env => .env | 0 Cargo.toml | 52 ++------------ dotenv/Cargo.toml | 47 +++++++++++++ {examples => dotenv/examples}/simple.rs | 0 {src => dotenv/src}/bin/dotenv.rs | 0 {src => dotenv/src}/errors.rs | 0 {src => dotenv/src}/find.rs | 0 {src => dotenv/src}/iter.rs | 0 {src => dotenv/src}/lib.rs | 0 {src => dotenv/src}/parse.rs | 0 {tests => dotenv/tests}/common/mod.rs | 0 {tests => dotenv/tests}/test-child-dir.rs | 0 .../tests}/test-default-location.rs | 0 {tests => dotenv/tests}/test-dotenv-iter.rs | 0 .../tests}/test-from-filename-iter.rs | 0 {tests => dotenv/tests}/test-from-filename.rs | 0 .../tests}/test-from-path-iter.rs | 0 {tests => dotenv/tests}/test-from-path.rs | 0 {tests => dotenv/tests}/test-var.rs | 0 {tests => dotenv/tests}/test-vars.rs | 0 dotenv_codegen/Cargo.toml | 8 +-- dotenv_codegen/dotenv_codegen_impl/src/lib.rs | 68 ------------------- dotenv_codegen/src/lib.rs | 9 +-- .../Cargo.toml | 20 +++--- dotenv_codegen_impl/src/lib.rs | 58 ++++++++++++++++ 25 files changed, 127 insertions(+), 135 deletions(-) rename dotenv_codegen/.env => .env (100%) create mode 100644 dotenv/Cargo.toml rename {examples => dotenv/examples}/simple.rs (100%) rename {src => dotenv/src}/bin/dotenv.rs (100%) rename {src => dotenv/src}/errors.rs (100%) rename {src => dotenv/src}/find.rs (100%) rename {src => dotenv/src}/iter.rs (100%) rename {src => dotenv/src}/lib.rs (100%) rename {src => dotenv/src}/parse.rs (100%) rename {tests => dotenv/tests}/common/mod.rs (100%) rename {tests => dotenv/tests}/test-child-dir.rs (100%) rename {tests => dotenv/tests}/test-default-location.rs (100%) rename {tests => dotenv/tests}/test-dotenv-iter.rs (100%) rename {tests => dotenv/tests}/test-from-filename-iter.rs (100%) rename {tests => dotenv/tests}/test-from-filename.rs (100%) rename {tests => dotenv/tests}/test-from-path-iter.rs (100%) rename {tests => dotenv/tests}/test-from-path.rs (100%) rename {tests => dotenv/tests}/test-var.rs (100%) rename {tests => dotenv/tests}/test-vars.rs (100%) delete mode 100644 dotenv_codegen/dotenv_codegen_impl/src/lib.rs rename {dotenv_codegen/dotenv_codegen_impl => dotenv_codegen_impl}/Cargo.toml (77%) create mode 100644 dotenv_codegen_impl/src/lib.rs diff --git a/dotenv_codegen/.env b/.env similarity index 100% rename from dotenv_codegen/.env rename to .env diff --git a/Cargo.toml b/Cargo.toml index ac9d844..1469980 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,47 +1,7 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g. crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +[workspace] -[package] -name = "dotenv" -version = "0.13.0" -authors = ["Noemi Lapresta ", "Craig Hills ", "Mike Piccolo ", "Alice Maz ", "Sean Griffin ", "Adam Sharp "] -description = "A `dotenv` implementation for Rust" -homepage = "https://github.com/purpliminal/rust-dotenv" -readme = "README.md" -keywords = ["environment", "env", "dotenv", "settings", "config"] -license = "MIT" -repository = "https://github.com/purpliminal/rust-dotenv" - -[[bin]] -name = "dotenv" -required-features = ["cli"] -[dependencies.clap] -version = "2" -optional = true - -[dependencies.failure] -version = "0.1.1" -features = ["derive"] -default-features = false - -[dependencies.lazy_static] -version = "1.0.0" - -[dependencies.regex] -version = "1.0" -[dev-dependencies.tempdir] -version = "0.3.0" - -[features] -backtrace = ["failure/backtrace"] -cli = ["clap"] -default = ["backtrace"] +members = [ + "dotenv", + "dotenv_codegen", + "dotenv_codegen_impl", +] \ No newline at end of file diff --git a/dotenv/Cargo.toml b/dotenv/Cargo.toml new file mode 100644 index 0000000..7579108 --- /dev/null +++ b/dotenv/Cargo.toml @@ -0,0 +1,47 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "dotenv" +version = "0.14.0" +authors = ["Noemi Lapresta ", "Craig Hills ", "Mike Piccolo ", "Alice Maz ", "Sean Griffin ", "Adam Sharp "] +description = "A `dotenv` implementation for Rust" +homepage = "https://github.com/purpliminal/rust-dotenv" +readme = "README.md" +keywords = ["environment", "env", "dotenv", "settings", "config"] +license = "MIT" +repository = "https://github.com/purpliminal/rust-dotenv" + +[[bin]] +name = "dotenv" +required-features = ["cli"] +[dependencies.clap] +version = "2" +optional = true + +[dependencies.failure] +version = "0.1.1" +features = ["derive"] +default-features = false + +[dependencies.lazy_static] +version = "1.0.0" + +[dependencies.regex] +version = "1.0" +[dev-dependencies.tempdir] +version = "0.3.0" + +[features] +backtrace = ["failure/backtrace"] +cli = ["clap"] +default = ["backtrace"] diff --git a/examples/simple.rs b/dotenv/examples/simple.rs similarity index 100% rename from examples/simple.rs rename to dotenv/examples/simple.rs diff --git a/src/bin/dotenv.rs b/dotenv/src/bin/dotenv.rs similarity index 100% rename from src/bin/dotenv.rs rename to dotenv/src/bin/dotenv.rs diff --git a/src/errors.rs b/dotenv/src/errors.rs similarity index 100% rename from src/errors.rs rename to dotenv/src/errors.rs diff --git a/src/find.rs b/dotenv/src/find.rs similarity index 100% rename from src/find.rs rename to dotenv/src/find.rs diff --git a/src/iter.rs b/dotenv/src/iter.rs similarity index 100% rename from src/iter.rs rename to dotenv/src/iter.rs diff --git a/src/lib.rs b/dotenv/src/lib.rs similarity index 100% rename from src/lib.rs rename to dotenv/src/lib.rs diff --git a/src/parse.rs b/dotenv/src/parse.rs similarity index 100% rename from src/parse.rs rename to dotenv/src/parse.rs diff --git a/tests/common/mod.rs b/dotenv/tests/common/mod.rs similarity index 100% rename from tests/common/mod.rs rename to dotenv/tests/common/mod.rs diff --git a/tests/test-child-dir.rs b/dotenv/tests/test-child-dir.rs similarity index 100% rename from tests/test-child-dir.rs rename to dotenv/tests/test-child-dir.rs diff --git a/tests/test-default-location.rs b/dotenv/tests/test-default-location.rs similarity index 100% rename from tests/test-default-location.rs rename to dotenv/tests/test-default-location.rs diff --git a/tests/test-dotenv-iter.rs b/dotenv/tests/test-dotenv-iter.rs similarity index 100% rename from tests/test-dotenv-iter.rs rename to dotenv/tests/test-dotenv-iter.rs diff --git a/tests/test-from-filename-iter.rs b/dotenv/tests/test-from-filename-iter.rs similarity index 100% rename from tests/test-from-filename-iter.rs rename to dotenv/tests/test-from-filename-iter.rs diff --git a/tests/test-from-filename.rs b/dotenv/tests/test-from-filename.rs similarity index 100% rename from tests/test-from-filename.rs rename to dotenv/tests/test-from-filename.rs diff --git a/tests/test-from-path-iter.rs b/dotenv/tests/test-from-path-iter.rs similarity index 100% rename from tests/test-from-path-iter.rs rename to dotenv/tests/test-from-path-iter.rs diff --git a/tests/test-from-path.rs b/dotenv/tests/test-from-path.rs similarity index 100% rename from tests/test-from-path.rs rename to dotenv/tests/test-from-path.rs diff --git a/tests/test-var.rs b/dotenv/tests/test-var.rs similarity index 100% rename from tests/test-var.rs rename to dotenv/tests/test-var.rs diff --git a/tests/test-vars.rs b/dotenv/tests/test-vars.rs similarity index 100% rename from tests/test-vars.rs rename to dotenv/tests/test-vars.rs diff --git a/dotenv_codegen/Cargo.toml b/dotenv_codegen/Cargo.toml index 36f7cce..2a5b0a2 100644 --- a/dotenv_codegen/Cargo.toml +++ b/dotenv_codegen/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dotenv_codegen" -version = "0.11.0" +version = "0.14.0" authors = [ "Santiago Lapresta ", "Craig Hills ", @@ -16,8 +16,6 @@ homepage = "https://github.com/purpliminal/rust-dotenv" repository = "https://github.com/purpliminal/rust-dotenv" description = "A `dotenv` implementation for Rust" -[workspace] - [dependencies] -dotenv_codegen_impl = { version = "0.1", path = "dotenv_codegen_impl" } -proc-macro-hack = "0.4" +dotenv_codegen_impl = { version = "0.13", path = "../dotenv_codegen_impl" } +proc-macro-hack = "0.5" diff --git a/dotenv_codegen/dotenv_codegen_impl/src/lib.rs b/dotenv_codegen/dotenv_codegen_impl/src/lib.rs deleted file mode 100644 index f01cfa6..0000000 --- a/dotenv_codegen/dotenv_codegen_impl/src/lib.rs +++ /dev/null @@ -1,68 +0,0 @@ -#[macro_use] -extern crate proc_macro_hack; - -#[macro_use] -extern crate quote; - -extern crate dotenv; - -extern crate proc_macro2; - -#[macro_use] -extern crate syn; - -use std::env; - -use dotenv::dotenv; - -use syn::punctuated::Punctuated; -use syn::buffer::TokenBuffer; - -proc_macro_expr_impl! { - pub fn expand_dotenv(input: &str) -> String { - if let Err(err) = dotenv() { - if let &dotenv::ErrorKind::LineParse(ref line) = err.kind() { - panic!("Error parsing .env file: {}", line); - } else { - panic!("Error loading .env file: {}", err); - } - } - - // Either everything was fine, or we didn't find an .env file (which we ignore) - expand_env(input) - } -} - -fn expand_env(input_raw: &str) -> String { - // we include () so that we can parse it as a tuple. `syn` 0.12 - let stream = input_raw - .parse() - .expect("expected macro usage to be valid rust code, but it was not"); - - let buf = TokenBuffer::new2(stream); - - let args: Punctuated = Punctuated::parse_terminated(buf.begin()) - .expect("expected macro to be called with a comma-separated list of string literals") - .0; - - let mut iter = args.iter(); - - let var_name = match iter.next() { - Some(s) => s.value(), - None => panic!("expected 1 or 2 arguments, found none"), - }; - - let err_msg = match iter.next() { - Some(lit) => lit.value(), - None => format!("environment variable `{}` not defined", var_name).into(), - }; - - if iter.next().is_some() { - panic!("expected 1 or 2 arguments, found 3 or more"); - } - - match env::var(var_name) { - Ok(val) => quote!(#val).to_string(), - Err(_) => panic!("{}", err_msg), - } -} diff --git a/dotenv_codegen/src/lib.rs b/dotenv_codegen/src/lib.rs index 725aada..b1aa008 100644 --- a/dotenv_codegen/src/lib.rs +++ b/dotenv_codegen/src/lib.rs @@ -1,12 +1,7 @@ #[macro_use] extern crate proc_macro_hack; -#[allow(unused_imports)] -#[macro_use] extern crate dotenv_codegen_impl; -#[doc(hidden)] -pub use dotenv_codegen_impl::*; -proc_macro_expr_decl! { - dotenv! => expand_dotenv -} +#[proc_macro_hack] +pub use dotenv_codegen_impl::dotenv; \ No newline at end of file diff --git a/dotenv_codegen/dotenv_codegen_impl/Cargo.toml b/dotenv_codegen_impl/Cargo.toml similarity index 77% rename from dotenv_codegen/dotenv_codegen_impl/Cargo.toml rename to dotenv_codegen_impl/Cargo.toml index e173211..d09a094 100644 --- a/dotenv_codegen/dotenv_codegen_impl/Cargo.toml +++ b/dotenv_codegen_impl/Cargo.toml @@ -1,6 +1,10 @@ +[lib] +proc-macro = true + [package] + name = "dotenv_codegen_impl" -version = "0.1.0" +version = "0.14.0" authors = [ "Santiago Lapresta ", "Craig Hills ", @@ -8,19 +12,17 @@ authors = [ "Alice Maz ", "Sean Griffin ", ] -readme = "../../README.md" +readme = "../README.md" keywords = ["environment", "env", "dotenv", "settings", "config"] license = "MIT" homepage = "https://github.com/purpliminal/rust-dotenv" repository = "https://github.com/purpliminal/rust-dotenv" description = "A `dotenv` implementation for Rust" -[lib] -proc-macro = true [dependencies] -dotenv = "0.11.0" -proc-macro-hack = "0.4" -proc-macro2 = "0.2" -quote = "0.4" -syn = "0.12" +proc-macro2 = "0.4" +quote = "0.6" +syn = "0.15" +proc-macro-hack = "0.5" +dotenv = { version = "0.13", path = "../dotenv" } \ No newline at end of file diff --git a/dotenv_codegen_impl/src/lib.rs b/dotenv_codegen_impl/src/lib.rs new file mode 100644 index 0000000..9d19f67 --- /dev/null +++ b/dotenv_codegen_impl/src/lib.rs @@ -0,0 +1,58 @@ +#[macro_use] +extern crate proc_macro_hack; +#[macro_use] +extern crate quote; + +extern crate dotenv; +extern crate proc_macro; +extern crate proc_macro2; + +#[macro_use] +extern crate syn; + +use std::env; + +use syn::punctuated::Punctuated; +use syn::parse::Parser; +use proc_macro::TokenStream; + +#[proc_macro_hack] +pub fn dotenv(input: TokenStream) -> TokenStream { + if let Err(err) = dotenv::dotenv() { + if let dotenv::Error::LineParse(ref line) = err { + panic!("Error parsing .env file: {}", line); + } else { + panic!("Error loading .env file: {}", err); + } + } + + // Either everything was fine, or we didn't find an .env file (which we ignore) + expand_env(input) +} + +fn expand_env(input_raw: TokenStream) -> TokenStream { + + let args = >::parse_terminated.parse(input_raw) + .expect("expected macro to be called with a comma-separated list of string literals"); + + let mut iter = args.iter(); + + let var_name = match iter.next() { + Some(s) => s.value(), + None => panic!("expected 1 or 2 arguments, found none"), + }; + + let err_msg = match iter.next() { + Some(lit) => lit.value(), + None => format!("environment variable `{}` not defined", var_name).into(), + }; + + if iter.next().is_some() { + panic!("expected 1 or 2 arguments, found 3 or more"); + } + + match env::var(var_name) { + Ok(val) => quote!(#val).into(), + Err(_) => panic!("{}", err_msg), + } +} From 4795cd7ef0e747b269e99122f32e357fb3ee7ffe Mon Sep 17 00:00:00 2001 From: Daniel Griffen Date: Mon, 6 May 2019 17:57:55 -0700 Subject: [PATCH 2/5] fix tests on windows --- dotenv/Cargo.toml | 4 ++-- dotenv/tests/common/mod.rs | 4 ++-- dotenv/tests/test-child-dir.rs | 3 ++- dotenv/tests/test-default-location.rs | 3 ++- dotenv/tests/test-dotenv-iter.rs | 3 ++- dotenv/tests/test-from-filename-iter.rs | 3 ++- dotenv/tests/test-from-filename.rs | 3 ++- dotenv/tests/test-from-path-iter.rs | 3 ++- dotenv/tests/test-from-path.rs | 3 ++- dotenv/tests/test-var.rs | 5 ++++- dotenv/tests/test-vars.rs | 5 ++++- dotenv_codegen/Cargo.toml | 2 +- dotenv_codegen_impl/Cargo.toml | 2 +- 13 files changed, 28 insertions(+), 15 deletions(-) diff --git a/dotenv/Cargo.toml b/dotenv/Cargo.toml index 7579108..f5a6666 100644 --- a/dotenv/Cargo.toml +++ b/dotenv/Cargo.toml @@ -38,8 +38,8 @@ version = "1.0.0" [dependencies.regex] version = "1.0" -[dev-dependencies.tempdir] -version = "0.3.0" +[dev-dependencies.tempfile] +version = "3.0.0" [features] backtrace = ["failure/backtrace"] diff --git a/dotenv/tests/common/mod.rs b/dotenv/tests/common/mod.rs index f0f1f75..6bdbb8e 100644 --- a/dotenv/tests/common/mod.rs +++ b/dotenv/tests/common/mod.rs @@ -1,10 +1,10 @@ use std::{env, io}; use std::fs::File; use std::io::prelude::*; -use tempdir::TempDir; +use tempfile::{tempdir, TempDir}; pub fn tempdir_with_dotenv(dotenv_text: &str) -> io::Result { - let dir = TempDir::new("rust-dotenv-test")?; + let dir = tempdir()?; env::set_current_dir(dir.path())?; let dotenv_path = dir.path().join(".env"); let mut dotenv_file = File::create(dotenv_path)?; diff --git a/dotenv/tests/test-child-dir.rs b/dotenv/tests/test-child-dir.rs index 350fe12..b5d1a07 100644 --- a/dotenv/tests/test-child-dir.rs +++ b/dotenv/tests/test-child-dir.rs @@ -1,5 +1,5 @@ extern crate dotenv; -extern crate tempdir; +extern crate tempfile; mod common; @@ -19,5 +19,6 @@ fn test_child_dir() { dotenv().ok(); assert_eq!(env::var("TESTKEY").unwrap(), "test_val"); + env::set_current_dir(dir.path().parent().unwrap()).unwrap(); dir.close().unwrap(); } diff --git a/dotenv/tests/test-default-location.rs b/dotenv/tests/test-default-location.rs index d57f998..7f98f1f 100644 --- a/dotenv/tests/test-default-location.rs +++ b/dotenv/tests/test-default-location.rs @@ -1,5 +1,5 @@ extern crate dotenv; -extern crate tempdir; +extern crate tempfile; mod common; @@ -15,5 +15,6 @@ fn test_default_location() { dotenv().ok(); assert_eq!(env::var("TESTKEY").unwrap(), "test_val"); + env::set_current_dir(dir.path().parent().unwrap()).unwrap(); dir.close().unwrap(); } diff --git a/dotenv/tests/test-dotenv-iter.rs b/dotenv/tests/test-dotenv-iter.rs index fa5ae26..b5405ad 100644 --- a/dotenv/tests/test-dotenv-iter.rs +++ b/dotenv/tests/test-dotenv-iter.rs @@ -1,5 +1,5 @@ extern crate dotenv; -extern crate tempdir; +extern crate tempfile; mod common; @@ -20,5 +20,6 @@ fn test_dotenv_iter() { assert_eq!(env::var("TESTKEY").unwrap(), "test_val"); + env::set_current_dir(dir.path().parent().unwrap()).unwrap(); dir.close().unwrap(); } diff --git a/dotenv/tests/test-from-filename-iter.rs b/dotenv/tests/test-from-filename-iter.rs index 7faa72a..dbb4462 100644 --- a/dotenv/tests/test-from-filename-iter.rs +++ b/dotenv/tests/test-from-filename-iter.rs @@ -1,5 +1,5 @@ extern crate dotenv; -extern crate tempdir; +extern crate tempfile; mod common; @@ -20,5 +20,6 @@ fn test_from_filename_iter() { assert_eq!(env::var("TESTKEY").unwrap(), "test_val"); + env::set_current_dir(dir.path().parent().unwrap()).unwrap(); dir.close().unwrap(); } diff --git a/dotenv/tests/test-from-filename.rs b/dotenv/tests/test-from-filename.rs index 00b4508..9639575 100644 --- a/dotenv/tests/test-from-filename.rs +++ b/dotenv/tests/test-from-filename.rs @@ -1,5 +1,5 @@ extern crate dotenv; -extern crate tempdir; +extern crate tempfile; mod common; @@ -16,5 +16,6 @@ fn test_from_filename() { assert_eq!(env::var("TESTKEY").unwrap(), "test_val"); + env::set_current_dir(dir.path().parent().unwrap()).unwrap(); dir.close().unwrap(); } diff --git a/dotenv/tests/test-from-path-iter.rs b/dotenv/tests/test-from-path-iter.rs index 10c82ac..8b34785 100644 --- a/dotenv/tests/test-from-path-iter.rs +++ b/dotenv/tests/test-from-path-iter.rs @@ -1,5 +1,5 @@ extern crate dotenv; -extern crate tempdir; +extern crate tempfile; mod common; @@ -23,5 +23,6 @@ fn test_from_path_iter() { assert_eq!(env::var("TESTKEY").unwrap(), "test_val"); + env::set_current_dir(dir.path().parent().unwrap()).unwrap(); dir.close().unwrap(); } diff --git a/dotenv/tests/test-from-path.rs b/dotenv/tests/test-from-path.rs index fb5798f..18c7b5f 100644 --- a/dotenv/tests/test-from-path.rs +++ b/dotenv/tests/test-from-path.rs @@ -1,5 +1,5 @@ extern crate dotenv; -extern crate tempdir; +extern crate tempfile; mod common; @@ -19,5 +19,6 @@ fn test_from_path() { assert_eq!(env::var("TESTKEY").unwrap(), "test_val"); + env::set_current_dir(dir.path().parent().unwrap()).unwrap(); dir.close().unwrap(); } diff --git a/dotenv/tests/test-var.rs b/dotenv/tests/test-var.rs index bc65fe5..70800f5 100644 --- a/dotenv/tests/test-var.rs +++ b/dotenv/tests/test-var.rs @@ -1,8 +1,10 @@ extern crate dotenv; -extern crate tempdir; +extern crate tempfile; mod common; +use std::env; + use dotenv::*; use common::*; @@ -13,5 +15,6 @@ fn test_var() { assert_eq!(var("TESTKEY").unwrap(), "test_val"); + env::set_current_dir(dir.path().parent().unwrap()).unwrap(); dir.close().unwrap(); } diff --git a/dotenv/tests/test-vars.rs b/dotenv/tests/test-vars.rs index 7f0ca6e..876c443 100644 --- a/dotenv/tests/test-vars.rs +++ b/dotenv/tests/test-vars.rs @@ -1,9 +1,11 @@ extern crate dotenv; -extern crate tempdir; +extern crate tempfile; mod common; use std::collections::HashMap; +use std::env; + use dotenv::*; use common::*; @@ -16,5 +18,6 @@ fn test_vars() { assert_eq!(vars["TESTKEY"], "test_val"); + env::set_current_dir(dir.path().parent().unwrap()).unwrap(); dir.close().unwrap(); } diff --git a/dotenv_codegen/Cargo.toml b/dotenv_codegen/Cargo.toml index 2a5b0a2..d306d76 100644 --- a/dotenv_codegen/Cargo.toml +++ b/dotenv_codegen/Cargo.toml @@ -17,5 +17,5 @@ repository = "https://github.com/purpliminal/rust-dotenv" description = "A `dotenv` implementation for Rust" [dependencies] -dotenv_codegen_impl = { version = "0.13", path = "../dotenv_codegen_impl" } +dotenv_codegen_impl = { version = "0.14", path = "../dotenv_codegen_impl" } proc-macro-hack = "0.5" diff --git a/dotenv_codegen_impl/Cargo.toml b/dotenv_codegen_impl/Cargo.toml index d09a094..bec80f8 100644 --- a/dotenv_codegen_impl/Cargo.toml +++ b/dotenv_codegen_impl/Cargo.toml @@ -25,4 +25,4 @@ proc-macro2 = "0.4" quote = "0.6" syn = "0.15" proc-macro-hack = "0.5" -dotenv = { version = "0.13", path = "../dotenv" } \ No newline at end of file +dotenv = { version = "0.14", path = "../dotenv" } \ No newline at end of file From 951d21a9c4ada8ed15c08aae7fcba6ad9bb6743f Mon Sep 17 00:00:00 2001 From: Daniel Griffen Date: Mon, 6 May 2019 18:02:15 -0700 Subject: [PATCH 3/5] correct repo links --- dotenv/Cargo.toml | 4 ++-- dotenv_codegen/Cargo.toml | 4 ++-- dotenv_codegen_impl/Cargo.toml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dotenv/Cargo.toml b/dotenv/Cargo.toml index f5a6666..c00595a 100644 --- a/dotenv/Cargo.toml +++ b/dotenv/Cargo.toml @@ -15,11 +15,11 @@ name = "dotenv" version = "0.14.0" authors = ["Noemi Lapresta ", "Craig Hills ", "Mike Piccolo ", "Alice Maz ", "Sean Griffin ", "Adam Sharp "] description = "A `dotenv` implementation for Rust" -homepage = "https://github.com/purpliminal/rust-dotenv" +homepage = "https://github.com/dotenv-rs/dotenv" readme = "README.md" keywords = ["environment", "env", "dotenv", "settings", "config"] license = "MIT" -repository = "https://github.com/purpliminal/rust-dotenv" +repository = "https://github.com/dotenv-rs/dotenv" [[bin]] name = "dotenv" diff --git a/dotenv_codegen/Cargo.toml b/dotenv_codegen/Cargo.toml index d306d76..8b82c84 100644 --- a/dotenv_codegen/Cargo.toml +++ b/dotenv_codegen/Cargo.toml @@ -12,8 +12,8 @@ authors = [ readme = "../README.md" keywords = ["environment", "env", "dotenv", "settings", "config"] license = "MIT" -homepage = "https://github.com/purpliminal/rust-dotenv" -repository = "https://github.com/purpliminal/rust-dotenv" +homepage = "https://github.com/dotenv-rs/dotenv" +repository = "https://github.com/dotenv-rs/dotenv" description = "A `dotenv` implementation for Rust" [dependencies] diff --git a/dotenv_codegen_impl/Cargo.toml b/dotenv_codegen_impl/Cargo.toml index bec80f8..9774b99 100644 --- a/dotenv_codegen_impl/Cargo.toml +++ b/dotenv_codegen_impl/Cargo.toml @@ -15,8 +15,8 @@ authors = [ readme = "../README.md" keywords = ["environment", "env", "dotenv", "settings", "config"] license = "MIT" -homepage = "https://github.com/purpliminal/rust-dotenv" -repository = "https://github.com/purpliminal/rust-dotenv" +homepage = "https://github.com/dotenv-rs/dotenv" +repository = "https://github.com/dotenv-rs/dotenv" description = "A `dotenv` implementation for Rust" From 77da230458a6be33d179af0974868ddd276259b5 Mon Sep 17 00:00:00 2001 From: Daniel Griffen Date: Mon, 6 May 2019 18:22:01 -0700 Subject: [PATCH 4/5] add azure pipelines support --- .travis.yml | 7 -- README.md | 2 +- azure-pipelines.yml | 22 ++++++ azure-pipelines/build-template.yml | 68 ++++++++++++++++ azure-pipelines/fix_coverage_for_cobertura.py | 77 +++++++++++++++++++ 5 files changed, 168 insertions(+), 8 deletions(-) delete mode 100644 .travis.yml create mode 100644 azure-pipelines.yml create mode 100644 azure-pipelines/build-template.yml create mode 100644 azure-pipelines/fix_coverage_for_cobertura.py diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b7c59f7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: rust -sudo: false -script: - - cargo build --verbose - - cargo test --verbose - - (cd dotenv_codegen; cargo build --verbose) - - (cd dotenv_codegen; cargo test --verbose) diff --git a/README.md b/README.md index b50e930..ac4c8e8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -rust-dotenv [![Build Status](https://travis-ci.org/purpliminal/rust-dotenv.svg?branch=master)](https://travis-ci.org/purpliminal/rust-dotenv) +rust-dotenv [![Build Status](https://dev.azure.com/dotenv-rs/dotenv/_apis/build/status/dotenv-rs.dotenv?branchName=master)](https://dev.azure.com/dotenv-rs/dotenv/_build/latest?definitionId=2&branchName=master) ==== **Achtung!** This is a v0.\* version! Expect bugs and issues all around. diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..f3b99df --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,22 @@ +trigger: + branches: + include: ["master", "v*"] + paths: + exclude: ["*.md"] + +jobs: +- template: azure-pipelines/build-template.yml + parameters: + name: Windows + poolName: Hosted VS2017 + +- template: azure-pipelines/build-template.yml + parameters: + name: MacOs + poolName: Hosted macOS + + +- template: azure-pipelines/build-template.yml + parameters: + name: Linux + poolName: Hosted Ubuntu 1604 \ No newline at end of file diff --git a/azure-pipelines/build-template.yml b/azure-pipelines/build-template.yml new file mode 100644 index 0000000..79f05b4 --- /dev/null +++ b/azure-pipelines/build-template.yml @@ -0,0 +1,68 @@ +jobs: +- job: ${{ parameters.name }} + pool: ${{ parameters.poolName }} + strategy: + matrix: + nightly: + RUSTUP_TOOLCHAIN: nightly + beta: + RUSTUP_TOOLCHAIN: beta + stable: + RUSTUP_TOOLCHAIN: stable + steps: + - ${{ if ne(parameters.name, 'Windows') }}: + # Linux and macOS. + - script: | + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN + echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin" + displayName: Install rust + - ${{ if eq(parameters.name, 'Windows') }}: + # Windows. + - script: | + curl -sSf -o rustup-init.exe https://win.rustup.rs + rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN% + set PATH=%PATH%;%USERPROFILE%\.cargo\bin + echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin" + displayName: Install rust (windows) + # All platforms. + - script: | + rustc -Vv + cargo -V + echo $RUSTUP_TOOLCHAIN + displayName: Query rust and cargo versions + - script: | + sudo apt-get update + sudo apt-get install cmake g++ pkg-config jq + sudo apt-get install libcurl4-openssl-dev libelf-dev libdw-dev binutils-dev libiberty-dev + cargo install cargo-kcov + cargo kcov --print-install-kcov-sh | sh + displayName: Install kcov + condition: and(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.JobName'], 'Linux stable')) + - script: cargo install --git https://github.com/dgriffen/cargo-junit --branch temp-patch + displayName: Install cargo junit formatter + - script: cargo build + displayName: Build + - script: cargo junit --name testResults.xml + displayName: Build and run tests + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: '**/testResults.xml' + testRunTitle: $(Agent.JobName) tests + - script: | + mkdir coverageReport + cargo kcov -o coverageReport --all + cd coverageReport/kcov-merged + python ../../azure-pipelines/fix_coverage_for_cobertura.py + displayName: Run code coverage + condition: and(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.JobName'], 'Linux stable')) + - script: bash <(curl -s https://codecov.io/bash) + env: + CODECOV_TOKEN: $(CODECOV_TOKEN_SECRET) + displayName: Publish to codecov.io + condition: and(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.JobName'], 'Linux stable')) + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: 'cobertura' + summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverageReport/kcov-merged/cobertura.xml + condition: and(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.JobName'], 'Linux stable')) diff --git a/azure-pipelines/fix_coverage_for_cobertura.py b/azure-pipelines/fix_coverage_for_cobertura.py new file mode 100644 index 0000000..6b3e174 --- /dev/null +++ b/azure-pipelines/fix_coverage_for_cobertura.py @@ -0,0 +1,77 @@ +''' +Created on Aug 3, 2016 + +@author: YLin2 +''' + +import sys +import os +from xml.dom import minidom + +def fix_class(class_node): + valid_lines = 0 + covered_lines = 0 + for lines_node in class_node.getElementsByTagName('lines'): + for line in lines_node.getElementsByTagName('line'): + if not line.hasAttribute('hits'): + continue + valid_lines += 1 + hit = line.getAttribute('hits') + if hit == '1': + covered_lines += 1 + if valid_lines > 0: + class_node.setAttribute('line-rate', repr(float(covered_lines)/float(valid_lines))) + return valid_lines, covered_lines + + +def fix_package(package_node): + valid_lines = 0 + covered_lines = 0 + for classes_node in package_node.getElementsByTagName('classes'): + for class_node in classes_node.getElementsByTagName('class'): + current_valid_lines, current_covered_lines = fix_class(class_node) + valid_lines += current_valid_lines + covered_lines += current_covered_lines + if valid_lines > 0: + package_node.setAttribute('line-rate', repr(float(covered_lines)/float(valid_lines))) + return valid_lines, covered_lines + + +def fix(*args, **kargs): + default_file_path = '' + default_file_name = 'cobertura.xml' + if len(args[0]) > 1: + arg = args[0][1] + else: + arg = default_file_path + + if os.path.isdir(arg): + file_name = os.path.join(arg, default_file_name) + else: + file_name = os.path.join(default_file_path, default_file_name) + + print 'processing: '+file_name + xml_file = open(file_name, 'r') + xml_doc = minidom.parse(xml_file) + xml_file.close() + xml_root = xml_doc.documentElement + original_copy = open('coverage.original.xml', 'w') + xml_root.writexml(original_copy) + valid_lines = 0 + covered_lines = 0 + tag_valid_lines = 'lines-valid' + tag_covered_lines = 'lines-covered' + + for package_node in xml_doc.getElementsByTagName('package'): + current_valid_lines, current_covered_lines = fix_package(package_node) + valid_lines += current_valid_lines + covered_lines += current_covered_lines + + xml_root.setAttribute(tag_valid_lines, repr(valid_lines)) + xml_root.setAttribute(tag_covered_lines, repr(covered_lines)) + fixed_copy = open(os.path.basename(file_name), 'w') + xml_root.writexml(fixed_copy) + +if __name__ == '__main__': + fix(sys.argv) + From 5d9b342e6da9c7f46cea3f303360ed3ad8ac3a94 Mon Sep 17 00:00:00 2001 From: Daniel Griffen Date: Tue, 7 May 2019 09:55:36 -0700 Subject: [PATCH 5/5] cleanup autogenerated Cargo.toml --- dotenv/Cargo.toml | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/dotenv/Cargo.toml b/dotenv/Cargo.toml index c00595a..9727cf7 100644 --- a/dotenv/Cargo.toml +++ b/dotenv/Cargo.toml @@ -1,15 +1,3 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g. crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - [package] name = "dotenv" version = "0.14.0" @@ -24,22 +12,19 @@ repository = "https://github.com/dotenv-rs/dotenv" [[bin]] name = "dotenv" required-features = ["cli"] -[dependencies.clap] -version = "2" -optional = true + +[dependencies] +lazy_static = "1.0.0" +regex = "1.0" +clap = { version = "2", optional = true } [dependencies.failure] version = "0.1.1" features = ["derive"] default-features = false -[dependencies.lazy_static] -version = "1.0.0" - -[dependencies.regex] -version = "1.0" -[dev-dependencies.tempfile] -version = "3.0.0" +[dev-dependencies] +tempfile = "3.0.0" [features] backtrace = ["failure/backtrace"]