Skip to content

Commit b21f967

Browse files
committed
Initial commit
0 parents  commit b21f967

20 files changed

Lines changed: 471 additions & 0 deletions

.coveragerc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[report]
2+
omit =
3+
*/mibs/*
4+
*__init__*

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Quali-Shells-Open-Source.rtf linguist-documentation
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
pull_request:
8+
branches:
9+
- "*"
10+
release:
11+
types: [published]
12+
13+
jobs:
14+
tests:
15+
name: Run unit tests
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: [2.7, 3.7]
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v2
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install pip -U
30+
pip install tox codecov
31+
- name: Set TOXENV
32+
run: |
33+
python_version="${{ matrix.python-version }}"
34+
py_version="${python_version/./}"
35+
target_branch=${{ github.base_ref || github.ref }}
36+
target_branch=(`[[ ${target_branch::10} == 'refs/heads' ]] && echo ${target_branch:11} || echo $target_branch`)
37+
echo "target_branch =" $target_branch
38+
is_master=(`[[ $target_branch == 'master' ]] && echo 'true' || echo 'false'`)
39+
is_tag=${{ startsWith(github.ref, 'refs/tags') }}
40+
echo "is_master =" $is_master
41+
echo "is_tag =" $is_tag
42+
branch=(`[[ $is_master == 'true' || $is_tag == 'true' ]] && echo 'master' || echo 'dev'`)
43+
TOXENV="py$py_version-$branch"
44+
echo $TOXENV
45+
echo "TOXENV=$TOXENV" >> $GITHUB_ENV
46+
- name: Run tox
47+
run: tox
48+
- name: Upload coverage report
49+
uses: codecov/codecov-action@v1
50+
with:
51+
file: .coverage
52+
fail_ci_if_error: true
53+
verbose: true
54+
pre-commit:
55+
name: Run pre-commit
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v2
60+
- name: Set up Python 3.7
61+
uses: actions/setup-python@v2
62+
with:
63+
python-version: 3.7
64+
- name: Install dependencies
65+
run: |
66+
python -m pip install pip -U
67+
pip install tox
68+
- name: Run pre-commit
69+
env:
70+
TOXENV: pre-commit
71+
run: tox
72+
build:
73+
name: Build package
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v2
78+
- name: Set up Python 3.7
79+
uses: actions/setup-python@v2
80+
with:
81+
python-version: 3.7
82+
- name: Install dependencies
83+
run: |
84+
python -m pip install pip -U
85+
pip install tox
86+
- name: Build
87+
env:
88+
TOXENV: build
89+
run: tox
90+
check-version:
91+
name: Check version
92+
# only for PRs in master
93+
if: ${{ github.base_ref == 'master' }}
94+
runs-on: ubuntu-latest
95+
steps:
96+
- name: Checkout code
97+
uses: actions/checkout@v2
98+
- name: Check version
99+
run: |
100+
git clone https://github.com/${{ github.repository }}.git ${{ github.repository }}
101+
cd ${{ github.repository }}
102+
git checkout -qf ${{ github.head_ref }}
103+
! git diff --exit-code --quiet origin/master version.txt
104+
deploy-to-test-pypi:
105+
needs: [tests, pre-commit, build]
106+
if: ${{ github.ref == 'refs/heads/dev' && github.event_name == 'push' }}
107+
runs-on: ubuntu-latest
108+
steps:
109+
- name: Checkout code
110+
uses: actions/checkout@v2
111+
- name: Set up Python 3.7
112+
uses: actions/setup-python@v2
113+
with:
114+
python-version: 3.7
115+
- name: Install dependencies
116+
run: |
117+
python -m pip install pip -U
118+
pip install tox
119+
- name: Add id to a package version
120+
run: sed -i -E "s/^([0-9]+\.[0-9]+\.[0-9]+)$/\1.${{ github.run_number }}/" version.txt
121+
- name: Build
122+
env:
123+
TOXENV: build
124+
run: tox
125+
- name: Publish
126+
uses: pypa/gh-action-pypi-publish@v1.4.1
127+
with:
128+
user: __token__
129+
password: ${{ secrets.TEST_PYPI_TOKEN }}
130+
repository_url: https://test.pypi.org/legacy/
131+
create-gh-release:
132+
needs: [tests, pre-commit, build]
133+
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
134+
runs-on: ubuntu-latest
135+
steps:
136+
- name: Checkout code
137+
uses: actions/checkout@v2
138+
- name: Set up Python 3.7
139+
uses: actions/setup-python@v2
140+
with:
141+
python-version: 3.7
142+
- name: Install dependencies
143+
run: |
144+
python -m pip install pip -U
145+
pip install tox
146+
- name: Build
147+
env:
148+
TOXENV: build
149+
run: tox
150+
- name: Set envs
151+
run: |
152+
version="$(cat version.txt | tr -d ' \t\n\r')"
153+
repo_owner=${{ github.repository }}
154+
index=`expr index "$repo_owner" /`
155+
repo=${repo_owner:index}
156+
echo "TAG=$version" >> $GITHUB_ENV
157+
echo "REPO=$repo" >> $GITHUB_ENV
158+
- name: Create GitHub release
159+
uses: ncipollo/release-action@v1
160+
with:
161+
token: ${{ secrets.GITHUB_TOKEN }}
162+
artifacts: "dist/*"
163+
draft: true
164+
name: ${{ env.REPO }} ${{ env.TAG }}
165+
tag: ${{ env.TAG }}
166+
commit: master
167+
deploy-to-pypi:
168+
needs: [tests, pre-commit, build]
169+
if: startsWith(github.ref, 'refs/tags/')
170+
runs-on: ubuntu-latest
171+
steps:
172+
- name: Checkout code
173+
uses: actions/checkout@v2
174+
- name: Set up Python 3.7
175+
uses: actions/setup-python@v2
176+
with:
177+
python-version: 3.7
178+
- name: Install dependencies
179+
run: |
180+
python -m pip install pip -U
181+
pip install tox
182+
- name: Build
183+
env:
184+
TOXENV: build
185+
run: tox
186+
- name: Publish
187+
uses: pypa/gh-action-pypi-publish@v1.4.1
188+
with:
189+
user: __token__
190+
password: ${{ secrets.PYPI_TOKEN }}

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
48+
# Translations
49+
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
55+
# Sphinx documentation
56+
docs/_build/
57+
58+
# PyBuilder
59+
target/
60+
61+
#Ipython Notebook
62+
.ipynb_checkpoints
63+
.pypirc
64+
65+
.idea/

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
repos:
2+
- repo: https://github.com/timothycrosley/isort
3+
rev: 5.6.4
4+
hooks:
5+
- id: isort
6+
language_version: python3.7
7+
exclude: '/mibs'
8+
- repo: https://github.com/python/black
9+
rev: 20.8b1
10+
hooks:
11+
- id: black
12+
language_version: python3.7
13+
exclude: '/mibs'
14+
- repo: https://gitlab.com/pycqa/flake8
15+
rev: 3.8.4
16+
hooks:
17+
- id: flake8
18+
additional_dependencies: [
19+
flake8-docstrings,
20+
flake8-builtins,
21+
flake8-comprehensions,
22+
flake8-print,
23+
flake8-eradicate,
24+
]
25+
language_version: python3.7
26+
exclude: '/mibs'

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include *.txt
2+
global-include *.ini
3+
prune .tox

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# CloudShell package repo template
2+
3+
[![Build status](https://github.com/QualiSystems/cloudshell-package-repo-template/workflows/CI/badge.svg?branch=master)](https://github.com/QualiSystems/cloudshell-package-repo-template/actions?query=branch%3Amaster)
4+
[![codecov](https://codecov.io/gh/QualiSystems/cloudshell-package-repo-template/branch/dev/graph/badge.svg)](https://codecov.io/gh/QualiSystems/cloudshell-package-repo-template)
5+
[![PyPI version](https://badge.fury.io/py/cloudshell-template.svg)](https://badge.fury.io/py/cloudshell-template)
6+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
7+
8+
Use this template to create new shell packages.
9+
10+
## Description of services
11+
### tox
12+
[tox](https://pypi.org/project/tox/) is an open source tool we use to run tests in multiple virtual environments.
13+
* To run all tests described in tox.ini, just run `tox`.
14+
* To run a particular env use `tox -e env_name`.
15+
16+
### pre-commit
17+
[pre-commit](https://pypi.org/project/pre-commit/) is an open source library we use to manage pre-commit hooks.
18+
* Run all code linters with a command `pre-commit run --all-files`.
19+
* Add git hook with command `pre-commit install`.
20+
* To update versions of pre-commit hooks in config file run `pre-commit autoupdate`
21+
22+
We use these hooks:
23+
* **isort** sorts imports (config in tox.ini)
24+
* **black** reformats code to one style (config in pyproject.toml)
25+
* **flake8** checks code style (config in tox.ini). We use these plugins:
26+
* `flake8-docstring` to check docstrings
27+
* `flake8-builtins` to avoid using builtins as variable names
28+
* `flake8-comprehensions` to check list/dict comprehensions
29+
* `flake8-print` to ensure we don't leave prints in the code
30+
* `flake8-eradicate` to ensure we don't leave commented lines in the code
31+
32+
## Installation
33+
34+
### tox.ini
35+
* Set the `package-name` var regarding your package.
36+
* Set the python version in envlist.
37+
38+
### .travis.yml
39+
* Set the python version regarding tox.ini.
40+
41+
### pyproject.toml
42+
* Set the python version for black.
43+
44+
### setup.py
45+
* Set a name and description for the package.
46+
* Set the python version of the shell.
47+
48+
### README.md
49+
* Update links for build, coverage etc.
50+
* Add the line to README
51+
We use tox and pre-commit for testing. [Services description](https://github.com/QualiSystems/cloudshell-package-repo-template#description-of-services)

cloudshell/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from pkgutil import extend_path
2+
3+
__path__ = extend_path(__path__, __name__)

cloudshell/template/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from pkgutil import extend_path
2+
3+
__path__ = extend_path(__path__, __name__)

cloudshell/template/package.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
info = "info"

0 commit comments

Comments
 (0)