Skip to content

Commit

Permalink
Update code climate and coverage setup
Browse files Browse the repository at this point in the history
  • Loading branch information
JrGoodle committed Sep 20, 2020
1 parent 1e280e4 commit 8393eab
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 119 deletions.
27 changes: 19 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ jobs:
command: script/docker start

- run:
name: Code climate setup
command: script/ci_before
name: Initialize Code Climate test reporter
command: |
script/install_cc_test_reporter
./cc-test-reporter before-build
- run:
name: Pytest functional tests - not write and not offline - parallel
Expand All @@ -51,17 +53,26 @@ jobs:
command: docker-compose exec clowder script/test "-m 'offline'"

- run:
name: Code climate reporting
command: script/ci_after
name: Update build files ownership
command: sudo chown --recursive ${USER} build

- run:
name: Upload coverage to Code climate
command: |
./cc-test-reporter format-coverage --input-type coverage.py --output - build/coverage/coverage.xml \
| ./cc-test-reporter upload-coverage --id ${CC_TEST_REPORTER_ID} --input -
- store_test_results:
path: build/reports
path: build/cucumber
- store_test_results:
path: build/junit

- codecov/upload:
file: build/coverage/.coverage
file: build/coverage/coverage.xml

- store_artifacts:
path: build/coverage

- store_artifacts:
path: build/reports
path: build/cucumber
- store_artifacts:
path: build/junit
5 changes: 3 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
[run]
branch = True
concurrency = multiprocessing
relative_files=True
parallel = True
dynamic_context = test_function
data_file = build/coverage/.coverage
omit =
tests/*
clowder/sitecustomize.py
source = clowder/*
# debug = config

[paths]
source =
clowder/
/clowder/clowder/
/Users/runner/work/clowder/clowder/clowder/
/home/circleci/project/clowder/
/Users/runner/work/clowder/clowder/
/Users/jrgoodle/projects/clowder-projects/clowder/clowder/

[report]
Expand Down
23 changes: 17 additions & 6 deletions .github/workflows/ci-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,26 @@ defaults:

jobs:
pytest:

env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest] # TODO: windows-latest
python-version: ['3.6', '3.7', '3.8']

steps:
- uses: actions/checkout@v2

- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Setup git config
run: |
git config --global user.email "joe@polka.cat";
Expand All @@ -41,25 +46,31 @@ jobs:
sudo git config --system --unset-all filter.lfs.smudge
sudo git config --system --unset-all filter.lfs.process
sudo git config --system --unset-all filter.lfs.required
- name: Install clowder
run: script/cibuild

- name: Run pytest functional tests
run: script/test "-n auto -m 'not ssh and not offline'"
- uses: codecov/codecov-action@v1
with:
file: build/coverage/.coverage

- name: Update build files ownership
run: sudo chown --recursive ${USER} build

- uses: actions/upload-artifact@v2
with:
name: coverage-ghworkflow-${{ matrix.os }}-${{ matrix.python-version }}
path: |
build/reports
build/cucumber
build/junit
build/coverage
- uses: deblockt/cucumber-report-annotations-action@v1.6
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
path: build/reports/cucumber/results*.json
path: build/cucumber/results*.json

- uses: ashley-taylor/junit-report-annotations-action@1.3
if: always()
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
path: build/reports/junit/results*.xml
path: build/junit/results*.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Example files

temp
coverage

README-processed.md
Expand Down
37 changes: 3 additions & 34 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@ environment:

# For Python versions available on Appveyor, see
# http://www.appveyor.com/docs/installed-software#python
# The list here is complete (excluding Python 2.6, which
# isn't covered by this document) at the time of writing.

- PYTHON: "C:\\Python33"
- PYTHON: "C:\\Python34"
- PYTHON: "C:\\Python35"
# - PYTHON: "C:\\Python33-x64"
# DISTUTILS_USE_SDK: "1"
- PYTHON: "C:\\Python34-x64"
DISTUTILS_USE_SDK: "1"
- PYTHON: "C:\\Python35-x64"
- PYTHON: "C:\\Python36-x64"
- PYTHON: "C:\\Python37-x64"
- PYTHON: "C:\\Python38-x64"

install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
Expand All @@ -25,32 +17,9 @@ install:
build: off

test_script:
# Put your test command here.
# If you don't need to build C extensions on 64-bit Python 3.3 or 3.4,
# you can remove "build.cmd" from the front of the command, as it's
# only needed to support those cases.
# Note that you must use the environment variable %PYTHON% to refer to
# the interpreter you're using - Appveyor does not do anything special
# to put the Python version you want to use on PATH.
# - "build.cmd %PYTHON%\\python.exe setup.py"
# - "%PYTHON%\\python.exe setup.py"
- cd examples\cats
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app init https://github.com/JrGoodle/cats.git
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app herd
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app herd --parallel
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app status
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app branch
# - coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app forall -c 'copy NUL empty-file.txt'
# - coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app forall --parallel -c 'copy NUL empty-file.txt'
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app diff
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app clean -g black-cats
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app stash -g cats
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app start new_branch
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app checkout master -g black-cats
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app reset
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app reset --parallel
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app prune new_branch
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app save vWin
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app yaml

after_test:
# Combine and submit test coverage results
Expand Down
3 changes: 1 addition & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ coverage:
# target: '50'

fixes:
- "/home/circleci/project/::"
- "/home/runner/work/clowder/clowder/::"
- "/clowder/::"

parsers:
gcov:
Expand Down
47 changes: 0 additions & 47 deletions script/ci_after

This file was deleted.

6 changes: 3 additions & 3 deletions script/docs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.." || exit 1

BUILD_DIR='build/docs'
HTML_DIR="$BUILD_DIR/html"
DOCS_BUILD_DIR='build/docs'
HTML_DIR="$DOCS_BUILD_DIR/html"

rm -rf "$BUILD_DIR"
rm -rf "$DOCS_BUILD_DIR"
sphinx-apidoc --force --no-toc -d 1 -o docs/rst clowder setup
sphinx-build docs "$HTML_DIR"

Expand Down
2 changes: 0 additions & 2 deletions script/ci_before → script/install_cc_test_reporter
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ esac
echo 'Download Code Climate test reporter'
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-$PLATFORM-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
echo 'Initialize Code Climate test reporter'
./cc-test-reporter before-build
28 changes: 13 additions & 15 deletions script/test
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import random
import shutil
import string
import subprocess
import sys
Expand All @@ -20,7 +19,7 @@ def run_command(cwd: Path, cmd: str) -> CompletedProcess:
def get_random_alphanumeric_string(length: int) -> str:
letters_and_digits = string.ascii_letters + string.digits
result_str = ''.join((random.choice(letters_and_digits) for _ in range(length)))
print("Random alphanumeric String is:", result_str)
print(f"Random alphanumeric String is: {result_str}")
return result_str


Expand All @@ -36,39 +35,38 @@ else:
# Repo path
path = Path(__file__).resolve().parent.parent.resolve()

# Create temp dir
temp_dir = path / "temp"
temp_dir.mkdir(parents=True, exist_ok=True)

# Create build dir
build_dir = path / "build"
build_dir.mkdir(parents=True, exist_ok=True)

# Base command
temp_dir = build_dir / "temp"
temp_dir.mkdir(parents=True, exist_ok=True)
command = f"pytest --basetemp={temp_dir} -vv"

# Coverage
# Coverage command
command += " --cov-config=.coveragerc --cov-append --cov=clowder"

# Create reports dir
reports_dir = build_dir / "reports"
reports_dir.mkdir(parents=True, exist_ok=True)

# Coverage reports
coverage_dir = reports_dir / f"coverage"
coverage_dir = build_dir / "coverage"
coverage_dir.mkdir(parents=True, exist_ok=True)
xml_file = coverage_dir / "results.xml"
xml_file = coverage_dir / f"coverage.xml"
command += f" --cov-report xml:{xml_file}"
html_dir = coverage_dir / "html"
command += f" --cov-report html:{html_dir}"
annotate_dir = coverage_dir / "annotate"
command += f" --cov-report annotate:{annotate_dir}"

# JUnit reports
junit_dir = reports_dir / f"junit"
junit_dir = build_dir / f"junit"
junit_dir.mkdir(parents=True, exist_ok=True)
junit_file = junit_dir / f"results{name}.xml"
command += f" --junitxml={junit_file}"

# BDD reports
cucumber_dir = reports_dir / f"cucumber"
cucumber_dir = build_dir / f"cucumber"
cucumber_dir.mkdir(parents=True, exist_ok=True)
cucumber_file = cucumber_dir / f"results{name}.json"
bdd_reporting_options = f" --cucumberjson={cucumber_file} --cucumberjson-expanded"
Expand All @@ -85,9 +83,9 @@ test_cmd = f'{command} -n auto -m "not offline and not write"'
run_command(path, test_cmd)

# Run offline tests
test_cmd = f'{base_command} -m "offline and not config"'
test_cmd = f'{command} -m "offline and not config"'
run_command(path, test_cmd)

# Run write tests
test_cmd = f'{base_command} -m "write and not offline"'
test_cmd = f'{command} -m "write and not offline"'
run_command(path, test_cmd)

0 comments on commit 8393eab

Please sign in to comment.