diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 00000000..f5b4211c --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,50 @@ +name: CI + +on: + push: + branches: + master + pull_request: + branches: + master + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + rust: [stable, beta, nightly] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + check: + runs-on: ubuntu-latest + name: Check + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: -- --check + + - uses: actions-rs/tarpaulin@v0.1 + with: + args: --ignore-tests -- --test-threads 1 + - uses: codecov/codecov-action@v1 + - name: Archive code coverage results + uses: actions/upload-artifact@v1 + with: + name: code-coverage-report + path: cobertura.xml diff --git a/README.md b/README.md index 4e05c2ab..1f91ab39 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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) +![CI](https://github.com/dotenv-rs/dotenv/workflows/CI/badge.svg) [![codecov](https://codecov.io/gh/dotenv-rs/dotenv/branch/master/graph/badge.svg)](https://codecov.io/gh/dotenv-rs/dotenv) [![Crates.io](https://img.shields.io/crates/v/dotenv.svg)](https://crates.io/crates/dotenv) diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index f3b99df6..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index db059cb3..00000000 --- a/azure-pipelines/build-template.yml +++ /dev/null @@ -1,68 +0,0 @@ -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 cargo2junit - displayName: Install cargo junit formatter - - script: cargo build - displayName: Build - - script: cargo test -- -Z unstable-options --format json | cargo2junit > 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 deleted file mode 100644 index 6b3e174b..00000000 --- a/azure-pipelines/fix_coverage_for_cobertura.py +++ /dev/null @@ -1,77 +0,0 @@ -''' -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) -