Skip to content

Commit d62b206

Browse files
authored
Code cleanup (#1)
* switch to workspaces * fix tests on windows * correct repo links * add azure pipelines support * cleanup autogenerated Cargo.toml
1 parent 6289ff1 commit d62b206

30 files changed

+308
-158
lines changed
File renamed without changes.

.travis.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

Cargo.toml

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,7 @@
1-
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
2-
#
3-
# When uploading crates to the registry Cargo will automatically
4-
# "normalize" Cargo.toml files for maximal compatibility
5-
# with all versions of Cargo and also rewrite `path` dependencies
6-
# to registry (e.g. crates.io) dependencies
7-
#
8-
# If you believe there's an error in this file please file an
9-
# issue against the rust-lang/cargo repository. If you're
10-
# editing this file be aware that the upstream Cargo.toml
11-
# will likely look very different (and much more reasonable)
1+
[workspace]
122

13-
[package]
14-
name = "dotenv"
15-
version = "0.13.0"
16-
authors = ["Noemi Lapresta <[email protected]>", "Craig Hills <[email protected]>", "Mike Piccolo <[email protected]>", "Alice Maz <[email protected]>", "Sean Griffin <[email protected]>", "Adam Sharp <[email protected]>"]
17-
description = "A `dotenv` implementation for Rust"
18-
homepage = "https://github.com/purpliminal/rust-dotenv"
19-
readme = "README.md"
20-
keywords = ["environment", "env", "dotenv", "settings", "config"]
21-
license = "MIT"
22-
repository = "https://github.com/purpliminal/rust-dotenv"
23-
24-
[[bin]]
25-
name = "dotenv"
26-
required-features = ["cli"]
27-
[dependencies.clap]
28-
version = "2"
29-
optional = true
30-
31-
[dependencies.failure]
32-
version = "0.1.1"
33-
features = ["derive"]
34-
default-features = false
35-
36-
[dependencies.lazy_static]
37-
version = "1.0.0"
38-
39-
[dependencies.regex]
40-
version = "1.0"
41-
[dev-dependencies.tempdir]
42-
version = "0.3.0"
43-
44-
[features]
45-
backtrace = ["failure/backtrace"]
46-
cli = ["clap"]
47-
default = ["backtrace"]
3+
members = [
4+
"dotenv",
5+
"dotenv_codegen",
6+
"dotenv_codegen_impl",
7+
]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
rust-dotenv [![Build Status](https://travis-ci.org/purpliminal/rust-dotenv.svg?branch=master)](https://travis-ci.org/purpliminal/rust-dotenv)
1+
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)
22
====
33

44
**Achtung!** This is a v0.\* version! Expect bugs and issues all around.

azure-pipelines.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
trigger:
2+
branches:
3+
include: ["master", "v*"]
4+
paths:
5+
exclude: ["*.md"]
6+
7+
jobs:
8+
- template: azure-pipelines/build-template.yml
9+
parameters:
10+
name: Windows
11+
poolName: Hosted VS2017
12+
13+
- template: azure-pipelines/build-template.yml
14+
parameters:
15+
name: MacOs
16+
poolName: Hosted macOS
17+
18+
19+
- template: azure-pipelines/build-template.yml
20+
parameters:
21+
name: Linux
22+
poolName: Hosted Ubuntu 1604

azure-pipelines/build-template.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
jobs:
2+
- job: ${{ parameters.name }}
3+
pool: ${{ parameters.poolName }}
4+
strategy:
5+
matrix:
6+
nightly:
7+
RUSTUP_TOOLCHAIN: nightly
8+
beta:
9+
RUSTUP_TOOLCHAIN: beta
10+
stable:
11+
RUSTUP_TOOLCHAIN: stable
12+
steps:
13+
- ${{ if ne(parameters.name, 'Windows') }}:
14+
# Linux and macOS.
15+
- script: |
16+
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
17+
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
18+
displayName: Install rust
19+
- ${{ if eq(parameters.name, 'Windows') }}:
20+
# Windows.
21+
- script: |
22+
curl -sSf -o rustup-init.exe https://win.rustup.rs
23+
rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN%
24+
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
25+
echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
26+
displayName: Install rust (windows)
27+
# All platforms.
28+
- script: |
29+
rustc -Vv
30+
cargo -V
31+
echo $RUSTUP_TOOLCHAIN
32+
displayName: Query rust and cargo versions
33+
- script: |
34+
sudo apt-get update
35+
sudo apt-get install cmake g++ pkg-config jq
36+
sudo apt-get install libcurl4-openssl-dev libelf-dev libdw-dev binutils-dev libiberty-dev
37+
cargo install cargo-kcov
38+
cargo kcov --print-install-kcov-sh | sh
39+
displayName: Install kcov
40+
condition: and(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.JobName'], 'Linux stable'))
41+
- script: cargo install --git https://github.com/dgriffen/cargo-junit --branch temp-patch
42+
displayName: Install cargo junit formatter
43+
- script: cargo build
44+
displayName: Build
45+
- script: cargo junit --name testResults.xml
46+
displayName: Build and run tests
47+
- task: PublishTestResults@2
48+
inputs:
49+
testResultsFormat: 'JUnit'
50+
testResultsFiles: '**/testResults.xml'
51+
testRunTitle: $(Agent.JobName) tests
52+
- script: |
53+
mkdir coverageReport
54+
cargo kcov -o coverageReport --all
55+
cd coverageReport/kcov-merged
56+
python ../../azure-pipelines/fix_coverage_for_cobertura.py
57+
displayName: Run code coverage
58+
condition: and(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.JobName'], 'Linux stable'))
59+
- script: bash <(curl -s https://codecov.io/bash)
60+
env:
61+
CODECOV_TOKEN: $(CODECOV_TOKEN_SECRET)
62+
displayName: Publish to codecov.io
63+
condition: and(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.JobName'], 'Linux stable'))
64+
- task: PublishCodeCoverageResults@1
65+
inputs:
66+
codeCoverageTool: 'cobertura'
67+
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverageReport/kcov-merged/cobertura.xml
68+
condition: and(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.JobName'], 'Linux stable'))
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
'''
2+
Created on Aug 3, 2016
3+
4+
@author: YLin2
5+
'''
6+
7+
import sys
8+
import os
9+
from xml.dom import minidom
10+
11+
def fix_class(class_node):
12+
valid_lines = 0
13+
covered_lines = 0
14+
for lines_node in class_node.getElementsByTagName('lines'):
15+
for line in lines_node.getElementsByTagName('line'):
16+
if not line.hasAttribute('hits'):
17+
continue
18+
valid_lines += 1
19+
hit = line.getAttribute('hits')
20+
if hit == '1':
21+
covered_lines += 1
22+
if valid_lines > 0:
23+
class_node.setAttribute('line-rate', repr(float(covered_lines)/float(valid_lines)))
24+
return valid_lines, covered_lines
25+
26+
27+
def fix_package(package_node):
28+
valid_lines = 0
29+
covered_lines = 0
30+
for classes_node in package_node.getElementsByTagName('classes'):
31+
for class_node in classes_node.getElementsByTagName('class'):
32+
current_valid_lines, current_covered_lines = fix_class(class_node)
33+
valid_lines += current_valid_lines
34+
covered_lines += current_covered_lines
35+
if valid_lines > 0:
36+
package_node.setAttribute('line-rate', repr(float(covered_lines)/float(valid_lines)))
37+
return valid_lines, covered_lines
38+
39+
40+
def fix(*args, **kargs):
41+
default_file_path = ''
42+
default_file_name = 'cobertura.xml'
43+
if len(args[0]) > 1:
44+
arg = args[0][1]
45+
else:
46+
arg = default_file_path
47+
48+
if os.path.isdir(arg):
49+
file_name = os.path.join(arg, default_file_name)
50+
else:
51+
file_name = os.path.join(default_file_path, default_file_name)
52+
53+
print 'processing: '+file_name
54+
xml_file = open(file_name, 'r')
55+
xml_doc = minidom.parse(xml_file)
56+
xml_file.close()
57+
xml_root = xml_doc.documentElement
58+
original_copy = open('coverage.original.xml', 'w')
59+
xml_root.writexml(original_copy)
60+
valid_lines = 0
61+
covered_lines = 0
62+
tag_valid_lines = 'lines-valid'
63+
tag_covered_lines = 'lines-covered'
64+
65+
for package_node in xml_doc.getElementsByTagName('package'):
66+
current_valid_lines, current_covered_lines = fix_package(package_node)
67+
valid_lines += current_valid_lines
68+
covered_lines += current_covered_lines
69+
70+
xml_root.setAttribute(tag_valid_lines, repr(valid_lines))
71+
xml_root.setAttribute(tag_covered_lines, repr(covered_lines))
72+
fixed_copy = open(os.path.basename(file_name), 'w')
73+
xml_root.writexml(fixed_copy)
74+
75+
if __name__ == '__main__':
76+
fix(sys.argv)
77+

dotenv/Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[package]
2+
name = "dotenv"
3+
version = "0.14.0"
4+
authors = ["Noemi Lapresta <[email protected]>", "Craig Hills <[email protected]>", "Mike Piccolo <[email protected]>", "Alice Maz <[email protected]>", "Sean Griffin <[email protected]>", "Adam Sharp <[email protected]>"]
5+
description = "A `dotenv` implementation for Rust"
6+
homepage = "https://github.com/dotenv-rs/dotenv"
7+
readme = "README.md"
8+
keywords = ["environment", "env", "dotenv", "settings", "config"]
9+
license = "MIT"
10+
repository = "https://github.com/dotenv-rs/dotenv"
11+
12+
[[bin]]
13+
name = "dotenv"
14+
required-features = ["cli"]
15+
16+
[dependencies]
17+
lazy_static = "1.0.0"
18+
regex = "1.0"
19+
clap = { version = "2", optional = true }
20+
21+
[dependencies.failure]
22+
version = "0.1.1"
23+
features = ["derive"]
24+
default-features = false
25+
26+
[dev-dependencies]
27+
tempfile = "3.0.0"
28+
29+
[features]
30+
backtrace = ["failure/backtrace"]
31+
cli = ["clap"]
32+
default = ["backtrace"]
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)