Skip to content

Commit

Permalink
Fixed unittest.
Browse files Browse the repository at this point in the history
Configured tox, pre-commit and github-actions
  • Loading branch information
Alexey Bogoslovskyi authored and Costya-Y committed Jul 6, 2021
1 parent 699e51b commit 5ff337e
Show file tree
Hide file tree
Showing 71 changed files with 1,292 additions and 1,483 deletions.
4 changes: 0 additions & 4 deletions .coveragerc

This file was deleted.

21 changes: 0 additions & 21 deletions .editorconfig

This file was deleted.

189 changes: 189 additions & 0 deletions .github/workflows/py2-py3-packages-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
name: CI

on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
release:
types: [published]

jobs:
tests:
name: Run unit tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install pip -U
pip install tox codecov
- name: Set TOXENV
run: |
python_version="${{ matrix.python-version }}"
py_version="${python_version/./}"
target_branch=${{ github.base_ref || github.ref }}
target_branch=(`[[ ${target_branch::10} == 'refs/heads' ]] && echo ${target_branch:11} || echo $target_branch`)
echo "target_branch =" $target_branch
is_master=(`[[ $target_branch == 'master' ]] && echo 'true' || echo 'false'`)
is_tag=${{ startsWith(github.ref, 'refs/tags') }}
echo "is_master =" $is_master
echo "is_tag =" $is_tag
branch=(`[[ $is_master == 'true' || $is_tag == 'true' ]] && echo 'master' || echo 'dev'`)
TOXENV="py$py_version-$branch"
echo $TOXENV
echo "TOXENV=$TOXENV" >> $GITHUB_ENV
- name: Run tox
run: tox
- name: Upload coverage report
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
verbose: true
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install pip -U
pip install tox
- name: Run pre-commit
env:
TOXENV: pre-commit
run: tox
build:
name: Build package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install pip -U
pip install tox
- name: Build
env:
TOXENV: build
run: tox
check-version:
name: Check version
# only for PRs in master
if: ${{ github.base_ref == 'master' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check version
run: |
git clone https://github.com/${{ github.repository }}.git ${{ github.repository }}
cd ${{ github.repository }}
git checkout -qf ${{ github.head_ref }}
! git diff --exit-code --quiet origin/master version.txt
deploy-to-test-pypi:
needs: [tests, pre-commit, build]
if: ${{ github.ref == 'refs/heads/dev' && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install pip -U
pip install tox
- name: Add id to a package version
run: sed -i -E "s/^([0-9]+\.[0-9]+\.[0-9]+)$/\1.${{ github.run_number }}/" version.txt
- name: Build
env:
TOXENV: build
run: tox
- name: Publish
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
create-gh-release:
needs: [tests, pre-commit, build]
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install pip -U
pip install tox
- name: Build
env:
TOXENV: build
run: tox
- name: Set envs
run: |
version="$(cat version.txt | tr -d ' \t\n\r')"
repo_owner=${{ github.repository }}
index=`expr index "$repo_owner" /`
repo=${repo_owner:index}
echo "TAG=$version" >> $GITHUB_ENV
echo "REPO=$repo" >> $GITHUB_ENV
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "dist/*"
draft: true
name: ${{ env.REPO }} ${{ env.TAG }}
tag: ${{ env.TAG }}
commit: master
deploy-to-pypi:
needs: [tests, pre-commit, build]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install pip -U
pip install tox
- name: Build
env:
TOXENV: build
run: tox
- name: Publish
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
5 changes: 1 addition & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ repos:
hooks:
- id: isort
language_version: python3.7
exclude: '/mibs'
- repo: https://github.com/python/black
rev: 20.8b1
hooks:
- id: black
language_version: python3.7
exclude: '/mibs'
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
Expand All @@ -22,5 +20,4 @@ repos:
flake8-print,
flake8-eradicate,
]
language_version: python3.7
exclude: '/mibs'
language_version: python3.7
10 changes: 0 additions & 10 deletions AUTHORS.rst

This file was deleted.

8 changes: 1 addition & 7 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
include AUTHORS.rst
include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst
include requirements.txt
include test_requirements.txt
include *.txt

recursive-include tests *
recursive-include shellfoundry/data *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
84 changes: 0 additions & 84 deletions Makefile

This file was deleted.

1 change: 0 additions & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Sphinx==1.3.1
pre-commit
tox
-r test_requirements.txt
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
requests
cookiecutter==1.6.0
click==6.7
cookiecutter~=1.7.2
click~=7.1.2
pyyaml
terminaltables
cloudshell-rest-api>=8.2.3.1
colorama
giturlparse.py
ruamel.yaml
cryptography
cryptography
3 changes: 1 addition & 2 deletions shellfoundry/commands/extend_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
DefinitionModification,
)
from shellfoundry.utilities.repository_downloader import RepositoryDownloader
from shellfoundry.utilities.shell_package import ShellPackage
from shellfoundry.utilities.temp_dir_context import TempDirContext
from shellfoundry.utilities.validations import (
ShellGenerationValidations,
Expand All @@ -37,7 +36,7 @@ def __init__(
shell_name_validations=None,
shell_gen_validations=None,
):
"""
"""Creates a new shell based on an already existing shell.
:param RepositoryDownloader repository_downloader:
:param ShellNameValidations shell_name_validations:
Expand Down
2 changes: 1 addition & 1 deletion shellfoundry/commands/get_templates_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class GetTemplatesCommandExecutor(object):
def __init__(self, repository_downloader=None, template_retriever=None):
"""
"""Download all templates relevant to provided CloudShell Version.
:param TemplateRetriever template_retriever:
:param RepositoryDownloader repository_downloader:
Expand Down
Loading

0 comments on commit 5ff337e

Please sign in to comment.