From 537fac743d2b2baa7ab8b77e0c7206b59338b04a Mon Sep 17 00:00:00 2001 From: Kyrylo Maksymenko Date: Mon, 8 May 2023 15:19:30 +0200 Subject: [PATCH] update pre-commit hooks and CI/CD --- .github/workflows/check-version.yml | 10 + .github/workflows/deploy-package.yml | 11 ++ .github/workflows/github-release.yml | 13 ++ .github/workflows/package.yml | 10 + .github/workflows/py2-py3-packages-ci.yml | 189 ------------------- .pre-commit-config.yaml | 8 +- shellfoundry/utilities/template_retriever.py | 1 - tox.ini | 2 +- 8 files changed, 49 insertions(+), 195 deletions(-) create mode 100644 .github/workflows/check-version.yml create mode 100644 .github/workflows/deploy-package.yml create mode 100644 .github/workflows/github-release.yml create mode 100644 .github/workflows/package.yml delete mode 100644 .github/workflows/py2-py3-packages-ci.yml diff --git a/.github/workflows/check-version.yml b/.github/workflows/check-version.yml new file mode 100644 index 0000000..137d86a --- /dev/null +++ b/.github/workflows/check-version.yml @@ -0,0 +1,10 @@ +name: check version +on: + pull_request: + paths-ignore: + - README.md + branches: + - master +jobs: + check-version: + uses: QualiSystems/.github/.github/workflows/package-check-version.yml@master diff --git a/.github/workflows/deploy-package.yml b/.github/workflows/deploy-package.yml new file mode 100644 index 0000000..0a5e215 --- /dev/null +++ b/.github/workflows/deploy-package.yml @@ -0,0 +1,11 @@ +name: deploy package +on: + release: + types: [ published ] +jobs: + tox-ci: + uses: QualiSystems/.github/.github/workflows/package-tox-py-37-39.yml@master + pypi-deploy: + needs: tox-ci + uses: QualiSystems/.github/.github/workflows/package-deploy-pypi.yml@master + secrets: inherit diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml new file mode 100644 index 0000000..bf380e2 --- /dev/null +++ b/.github/workflows/github-release.yml @@ -0,0 +1,13 @@ +name: github release +on: + push: + paths-ignore: + - README.md + branches: + - master +jobs: + tox-ci: + uses: QualiSystems/.github/.github/workflows/package-tox-py-37-39.yml@master + pypi-deploy: + needs: tox-ci + uses: QualiSystems/.github/.github/workflows/package-github-release.yml@master diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 0000000..34e31cc --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,10 @@ +name: package CI +on: + push: + paths-ignore: + - README.md + branches-ignore: + - master +jobs: + tox-ci: + uses: QualiSystems/.github/.github/workflows/package-tox-py-37-39.yml@master diff --git a/.github/workflows/py2-py3-packages-ci.yml b/.github/workflows/py2-py3-packages-ci.yml deleted file mode 100644 index 22d0af6..0000000 --- a/.github/workflows/py2-py3-packages-ci.yml +++ /dev/null @@ -1,189 +0,0 @@ -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/gh-action-pypi-publish@v1.4.1 - 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/gh-action-pypi-publish@v1.4.1 - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f9a0e5d..6eedc4f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ repos: - repo: https://github.com/timothycrosley/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/python/black - rev: 22.3.0 + rev: 22.12.0 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 5.0.4 hooks: - id: flake8 additional_dependencies: [ @@ -17,4 +17,4 @@ repos: flake8-comprehensions, flake8-print, flake8-eradicate, - ] \ No newline at end of file + ] diff --git a/shellfoundry/utilities/template_retriever.py b/shellfoundry/utilities/template_retriever.py index 499447d..b99f6cd 100644 --- a/shellfoundry/utilities/template_retriever.py +++ b/shellfoundry/utilities/template_retriever.py @@ -23,7 +23,6 @@ TEMPLATES_YML, ) - REQUEST_TIMEOUT = 15 diff --git a/tox.ini b/tox.ini index 6b04d99..bb9727d 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] envlist = - py{37}-{master} + py{37,39}-{master} pre-commit build distshare = dist