Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #1

Merged
merged 5 commits into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

52 changes: 6 additions & 46 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <noemi.lapresta@gmail.com>", "Craig Hills <chills@gmail.com>", "Mike Piccolo <mfpiccolo@gmail.com>", "Alice Maz <alice@alicemaz.com>", "Sean Griffin <sean@seantheprogrammer.com>", "Adam Sharp <adam@sharplet.me>"]
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",
]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
22 changes: 22 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -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
68 changes: 68 additions & 0 deletions azure-pipelines/build-template.yml
Original file line number Diff line number Diff line change
@@ -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'))
77 changes: 77 additions & 0 deletions azure-pipelines/fix_coverage_for_cobertura.py
Original file line number Diff line number Diff line change
@@ -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)

32 changes: 32 additions & 0 deletions dotenv/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "dotenv"
version = "0.14.0"
authors = ["Noemi Lapresta <noemi.lapresta@gmail.com>", "Craig Hills <chills@gmail.com>", "Mike Piccolo <mfpiccolo@gmail.com>", "Alice Maz <alice@alicemaz.com>", "Sean Griffin <sean@seantheprogrammer.com>", "Adam Sharp <adam@sharplet.me>"]
description = "A `dotenv` implementation for Rust"
homepage = "https://github.com/dotenv-rs/dotenv"
readme = "README.md"
keywords = ["environment", "env", "dotenv", "settings", "config"]
license = "MIT"
repository = "https://github.com/dotenv-rs/dotenv"

[[bin]]
name = "dotenv"
required-features = ["cli"]

[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

[dev-dependencies]
tempfile = "3.0.0"

[features]
backtrace = ["failure/backtrace"]
cli = ["clap"]
default = ["backtrace"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/common/mod.rs → dotenv/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -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<TempDir> {
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)?;
Expand Down
3 changes: 2 additions & 1 deletion tests/test-child-dir.rs → dotenv/tests/test-child-dir.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate dotenv;
extern crate tempdir;
extern crate tempfile;

mod common;

Expand All @@ -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();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate dotenv;
extern crate tempdir;
extern crate tempfile;

mod common;

Expand All @@ -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();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate dotenv;
extern crate tempdir;
extern crate tempfile;

mod common;

Expand All @@ -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();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate dotenv;
extern crate tempdir;
extern crate tempfile;

mod common;

Expand All @@ -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();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate dotenv;
extern crate tempdir;
extern crate tempfile;

mod common;

Expand All @@ -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();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate dotenv;
extern crate tempdir;
extern crate tempfile;

mod common;

Expand All @@ -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();
}
3 changes: 2 additions & 1 deletion tests/test-from-path.rs → dotenv/tests/test-from-path.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate dotenv;
extern crate tempdir;
extern crate tempfile;

mod common;

Expand All @@ -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();
}
Loading