Skip to content

Commit 5ff337e

Browse files
Alexey BogoslovskyiCostya-Y
authored andcommitted
Fixed unittest.
Configured tox, pre-commit and github-actions
1 parent 699e51b commit 5ff337e

File tree

71 files changed

+1292
-1483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1292
-1483
lines changed

.coveragerc

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

.editorconfig

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
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: [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+
fail_ci_if_error: true
52+
verbose: true
53+
pre-commit:
54+
name: Run pre-commit
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v2
59+
- name: Set up Python 3.7
60+
uses: actions/setup-python@v2
61+
with:
62+
python-version: 3.7
63+
- name: Install dependencies
64+
run: |
65+
python -m pip install pip -U
66+
pip install tox
67+
- name: Run pre-commit
68+
env:
69+
TOXENV: pre-commit
70+
run: tox
71+
build:
72+
name: Build package
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v2
77+
- name: Set up Python 3.7
78+
uses: actions/setup-python@v2
79+
with:
80+
python-version: 3.7
81+
- name: Install dependencies
82+
run: |
83+
python -m pip install pip -U
84+
pip install tox
85+
- name: Build
86+
env:
87+
TOXENV: build
88+
run: tox
89+
check-version:
90+
name: Check version
91+
# only for PRs in master
92+
if: ${{ github.base_ref == 'master' }}
93+
runs-on: ubuntu-latest
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v2
97+
- name: Check version
98+
run: |
99+
git clone https://github.com/${{ github.repository }}.git ${{ github.repository }}
100+
cd ${{ github.repository }}
101+
git checkout -qf ${{ github.head_ref }}
102+
! git diff --exit-code --quiet origin/master version.txt
103+
deploy-to-test-pypi:
104+
needs: [tests, pre-commit, build]
105+
if: ${{ github.ref == 'refs/heads/dev' && github.event_name == 'push' }}
106+
runs-on: ubuntu-latest
107+
steps:
108+
- name: Checkout code
109+
uses: actions/checkout@v2
110+
- name: Set up Python 3.7
111+
uses: actions/setup-python@v2
112+
with:
113+
python-version: 3.7
114+
- name: Install dependencies
115+
run: |
116+
python -m pip install pip -U
117+
pip install tox
118+
- name: Add id to a package version
119+
run: sed -i -E "s/^([0-9]+\.[0-9]+\.[0-9]+)$/\1.${{ github.run_number }}/" version.txt
120+
- name: Build
121+
env:
122+
TOXENV: build
123+
run: tox
124+
- name: Publish
125+
uses: pypa/gh-action-pypi-publish@v1.4.1
126+
with:
127+
user: __token__
128+
password: ${{ secrets.TEST_PYPI_TOKEN }}
129+
repository_url: https://test.pypi.org/legacy/
130+
create-gh-release:
131+
needs: [tests, pre-commit, build]
132+
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
133+
runs-on: ubuntu-latest
134+
steps:
135+
- name: Checkout code
136+
uses: actions/checkout@v2
137+
- name: Set up Python 3.7
138+
uses: actions/setup-python@v2
139+
with:
140+
python-version: 3.7
141+
- name: Install dependencies
142+
run: |
143+
python -m pip install pip -U
144+
pip install tox
145+
- name: Build
146+
env:
147+
TOXENV: build
148+
run: tox
149+
- name: Set envs
150+
run: |
151+
version="$(cat version.txt | tr -d ' \t\n\r')"
152+
repo_owner=${{ github.repository }}
153+
index=`expr index "$repo_owner" /`
154+
repo=${repo_owner:index}
155+
echo "TAG=$version" >> $GITHUB_ENV
156+
echo "REPO=$repo" >> $GITHUB_ENV
157+
- name: Create GitHub release
158+
uses: ncipollo/release-action@v1
159+
with:
160+
token: ${{ secrets.GITHUB_TOKEN }}
161+
artifacts: "dist/*"
162+
draft: true
163+
name: ${{ env.REPO }} ${{ env.TAG }}
164+
tag: ${{ env.TAG }}
165+
commit: master
166+
deploy-to-pypi:
167+
needs: [tests, pre-commit, build]
168+
if: startsWith(github.ref, 'refs/tags/')
169+
runs-on: ubuntu-latest
170+
steps:
171+
- name: Checkout code
172+
uses: actions/checkout@v2
173+
- name: Set up Python 3.7
174+
uses: actions/setup-python@v2
175+
with:
176+
python-version: 3.7
177+
- name: Install dependencies
178+
run: |
179+
python -m pip install pip -U
180+
pip install tox
181+
- name: Build
182+
env:
183+
TOXENV: build
184+
run: tox
185+
- name: Publish
186+
uses: pypa/gh-action-pypi-publish@v1.4.1
187+
with:
188+
user: __token__
189+
password: ${{ secrets.PYPI_TOKEN }}

.pre-commit-config.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ repos:
44
hooks:
55
- id: isort
66
language_version: python3.7
7-
exclude: '/mibs'
87
- repo: https://github.com/python/black
98
rev: 20.8b1
109
hooks:
1110
- id: black
1211
language_version: python3.7
13-
exclude: '/mibs'
1412
- repo: https://gitlab.com/pycqa/flake8
1513
rev: 3.8.4
1614
hooks:
@@ -22,5 +20,4 @@ repos:
2220
flake8-print,
2321
flake8-eradicate,
2422
]
25-
language_version: python3.7
26-
exclude: '/mibs'
23+
language_version: python3.7

AUTHORS.rst

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

MANIFEST.in

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
include AUTHORS.rst
2-
include CONTRIBUTING.rst
31
include HISTORY.rst
42
include LICENSE
53
include README.rst
6-
include requirements.txt
7-
include test_requirements.txt
4+
include *.txt
85

9-
recursive-include tests *
106
recursive-include shellfoundry/data *
117
recursive-exclude * __pycache__
128
recursive-exclude * *.py[co]
13-
14-
recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif

Makefile

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

dev_requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
Sphinx==1.3.1
21
pre-commit
32
tox
43
-r test_requirements.txt

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
requests
2-
cookiecutter==1.6.0
3-
click==6.7
2+
cookiecutter~=1.7.2
3+
click~=7.1.2
44
pyyaml
55
terminaltables
66
cloudshell-rest-api>=8.2.3.1
77
colorama
88
giturlparse.py
99
ruamel.yaml
10-
cryptography
10+
cryptography

shellfoundry/commands/extend_command.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
DefinitionModification,
1919
)
2020
from shellfoundry.utilities.repository_downloader import RepositoryDownloader
21-
from shellfoundry.utilities.shell_package import ShellPackage
2221
from shellfoundry.utilities.temp_dir_context import TempDirContext
2322
from shellfoundry.utilities.validations import (
2423
ShellGenerationValidations,
@@ -37,7 +36,7 @@ def __init__(
3736
shell_name_validations=None,
3837
shell_gen_validations=None,
3938
):
40-
"""
39+
"""Creates a new shell based on an already existing shell.
4140
4241
:param RepositoryDownloader repository_downloader:
4342
:param ShellNameValidations shell_name_validations:

0 commit comments

Comments
 (0)