Metadata-Version: 2.1
Name: atosdevopstools
Version: 1.0.0
Summary: DevOps utils
Home-page: https://scm.atosresearch.eu/ari/smartnet/pylib/atos-devops-tools
Author: 2020, ATOS Research and Innovation
Author-email: smartnet@atosresearh.eu
Maintainer: Guillermo Gomez
License: OSI Approved :: Apache Software License
Platform: UNKNOWN
Requires-Python: ~=3.8
Description-Content-Type: text/markdown
Requires-Dist: click (~=7.1.2)
Requires-Dist: requests (~=2.25.0)
Requires-Dist: pytest (~=6.2.1)
Requires-Dist: pytest-bdd (~=4.0.2)
Requires-Dist: pytest-cov (~=2.8.1)
Requires-Dist: pylint (~=2.6.0)
Requires-Dist: sphinx (==3.3.1)
Requires-Dist: sphinx-rtd-theme (==0.4.3)

# DevOps Tools 
This project consists on a collection of utility classes and modules in the context of DevOps and CICD


## Gitlab Wrapper

This class provides a wrapper for the Gitlab API and initially aims to help send outputs to project badges

## Pylint Wrapper

This class provides a wrapper for the Pylint quality report and initially aims to help send outputs to project badges

## Usage via CLI
```
pylint_wrapper --help
Usage: pylint_wrapper [OPTIONS] COMMAND [ARGS]...

Options:
  --pylint-report-path TEXT  QA report txt file based on Pylint
  --help                     Show this message and exit.

Commands:
  get-qa-value    Returns the code's quality as a score
  raise-for-code  Validate a pylint report looking for Failures or Errors
```
```
gitlab_wrapper --help
Usage: gitlab_wrapper [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  setup-badges  Utility CLI to initialize a gitlab repository with default badges; Version, Coverage and Code Quality
  update-badge  Utility CLI to modify Gitlab badges based on https://shields.io. Currently supporting version,
                coverage and code quality.
                Coverage value will have a different color based on its value;
                [0, 30] = red; (30, 50] = yellow; (50, 70] =  light-green; (70, 100] = green \n
                Code Quality value will have a different color based on its value;
                [0, 5] = red; (5, 6] = yellow; (6, 7] = light-green; (7, 10] = green

```
Gitlab CI Pipeline example in a project "TOOL" making use of atosdevopstools 
```yaml
variables:
  PACKAGE: TOOLS
  JOB_WITH_COVERAGE: test_functional  # Job name which includes the "coverage" keyword in the main gitlab-ci.yaml

before_script:
  - pip install atosdevopstools

qa:
  stage: tests
  dependencies:
    - <BUILD WHEEL JOB>
  only:
    - develop
    - master
    - merge_requests
  script:
    - pip install dist/*  # Install from distribution
    # pylint will fail return non-zero even if only warnings are found
    - pylint $PACKAGE tests --exit-zero --reports y >> qa_report.txt
    - cat qa_report.txt
    - pylint_wrapper --pylint-report-path qa_report.txt raise-for-code
    - mkdir reports/
    - cp qa_report.txt reports/
  artifacts:
    paths:
      - reports/qa_report.txt

make_badges: # Only update when merged to main branches
  stage: badges
  dependencies:
    - <BUILD WHEEL JOB>
    - qa
  only:
    - develop
    - master
  script:
    - pip install dist/*  # Install TOOL from distribution
    - QA=$(pylint_wrapper --pylint-report-path reports/qa_report.txt get-qa-value | tail -1)
    - echo ${QA}
    - VERSION=$(python -c "import pkg_resources; print(pkg_resources.get_distribution('$PACKAGE').version)")
    - echo ${VERSION}
    - gitlab_wrapper update-badge --url https://scm.atosresearch.eu --api-token ${API_TOKEN}
      --project-id ${CI_PROJECT_ID} --pipeline-id ${CI_PIPELINE_ID} --version ${VERSION} --test-job-name $JOB_WITH_COVERAGE --qa-value ${QA}

```


## Release Notes:

Since atosdevopstools is intended to be publicly available under pypi to facilitate its usage on any other project and
regarless of the consortium setup, the source code here is obfuscated into a Cython package and distributed (**Will be distributed**)
for Windows and Ubuntu and which are named automatically using the format {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform tag}.whl

E.g Local dev environment shows the following package being created: **atosdevopstools-0.1.0-cp38-cp38-win_amd64.whl**

This approach has some limitations and implies coding in a module-based way instead of a fully OOP approach. This is the reason
why **atosdevopstools does not contain a __init__.py file**. When installed from a different project, imports should point 
at the individual modules rather than at the atosdevopstools package:
```
pip install atosdevopstools~=1.0.0 # The latest 1.0 release for your Host will be downloaded and installed
```
```python
from gitlab_wrapper import GitlabWrapper
from pylint_wrapper import PylintWrapper
```


### Changelog

1. v1.0.0:  

