Skip to content

Commit

Permalink
CI refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Rybakov committed Aug 15, 2023
1 parent 0638320 commit 770b679
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 312 deletions.
138 changes: 5 additions & 133 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,137 +5,9 @@ on:
branches-ignore:
- 'refs/tags/v'

env:
PYTHON_IMAGE: 3.9
PYTHON_PACKAGE_NAME: deker

jobs:
setup:
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_IMAGE }}

- name: Install poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies
run: poetry install

- name: Cache virtual environment
uses: actions/cache@v2
with:
path: .venv
key: ${{ runner.os }}-venv-${{ env.PYTHON_IMAGE }}-${{ hashFiles('pyproject.toml', 'poetry.lock') }}

linters:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_IMAGE }}

- name: Load virtual environment
uses: actions/cache@v2
with:
path: .venv
key: ${{ runner.os }}-venv-${{ env.PYTHON_IMAGE }}-${{ hashFiles('pyproject.toml', 'poetry.lock') }}

- name: Run linters and checks
run: |
source .venv/bin/activate
isort ./${{ env.PYTHON_PACKAGE_NAME }}
black ./${{ env.PYTHON_PACKAGE_NAME }}
flake8 ./${{ env.PYTHON_PACKAGE_NAME }}
mypy ./${{ env.PYTHON_PACKAGE_NAME }} --install-types --non-interactive --config-file pyproject.toml
doc8 --config pyproject.toml ./docs/deker
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

- name: Save linter reports
if: always()
uses: actions/upload-artifact@v2
with:
name: linter-reports
path: report.xml

tests:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_IMAGE }}

- name: Load virtual environment
uses: actions/cache@v2
with:
path: .venv
key: ${{ runner.os }}-venv-${{ env.PYTHON_IMAGE }}-${{ hashFiles('pyproject.toml', 'poetry.lock') }}

- name: Run shuffled tests
run: |
source .venv/bin/activate
pytest --random-order --junitxml=tests.xml
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

- name: Save test reports
if: always()
uses: actions/upload-artifact@v2
with:
name: test-reports
path: tests.xml

coverage:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_IMAGE }}

- name: Load virtual environment
uses: actions/cache@v2
with:
path: .venv
key: ${{ runner.os }}-venv-${{ env.PYTHON_IMAGE }}-${{ hashFiles('pyproject.toml', 'poetry.lock') }}

- name: Run coverage
run: |
source .venv/bin/activate
coverage run -m pytest --junitxml=report.xml
coverage report --fail-under=96
coverage xml
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

- name: Save coverage reports
if: always()
uses: actions/upload-artifact@v2
with:
name: coverage-reports
path: coverage.xml
checks:
uses: openweathermap/deker-actions/.github/workflows/checks.yml@master
with:
package-name: deker
python-version: '3.9'
111 changes: 11 additions & 100 deletions .github/workflows/on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,125 +6,36 @@ on:
- 'v[1-9]+.[0-9]+.[0-9]+'

env:
PYTHON_IMAGE: 3.9
PACKAGE_NAME: deker

jobs:
tox_tests:
runs-on: ubuntu-latest
container:
image: ghcr.io/openweathermap/deker/deker-embedded/tox:latest
env:
PACKAGE_VERSION: ${{ github.REF_NAME }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Set python versions
run: pyenv global 3.9 3.10 3.11

- name: Checkout code
uses: actions/checkout@v3

- name: Install tools
run: |
env
pip install tox poetry
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

- name: Make requirements file
run: poetry export --without-hashes > requirements.txt

- name: Run tox tests
run: |
export PIP_EXTRA_INDEX_URL=https://test.pypi.org/simple
env
tox
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
PACKAGE_VERSION: ${{ github.REF_NAME }}
uses: openweathermap/deker-actions/.github/workflows/tox.yml@master
with:
package-name: $PACKAGE_NAME

build_docs:
needs: tox_tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_IMAGE }}

- name: Install poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies
run: |
poetry install
source .venv/bin/activate
doc8 --config pyproject.toml docs/deker
cd ./docs
make html
awk 'NR >= 35 && NR <= 40' _build/html/index.html
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: docs/_build/html
uses: openweathermap/deker-actions/.github/workflows/docs_build.yml@master

publish_docs:
needs: build_docs
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
force: true
directory: docs/_build/html
uses: openweathermap/deker-actions/.github/workflows/docs_publish.yml@master

build_sdist:
needs: build_docs
needs: [tox_tests, build_docs]
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build sdist
run: |
pip install poetry-dynamic-versioning
pip install poetry
poetry dynamic-versioning enable
poetry build -f sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
uses: openweathermap/deker-actions/.github/workflows/build.yml@master

upload_pypi:
needs: [build_sdist, publish_docs]
name: Publish source distribution
needs: build_sdist
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/p/deker
url: https://pypi.org/p/$PACKAGE_NAME

steps:
- uses: actions/download-artifact@v3
Expand Down
27 changes: 8 additions & 19 deletions .github/workflows/on_test_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,23 @@ on:
tags-ignore:
- 'v[1-9]+.[0-9]+.[0-9]+'

env:
PACKAGE_NAME: deker

jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build sdist
run: |
pip install poetry-dynamic-versioning
pip install poetry
poetry dynamic-versioning enable
poetry build -f sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
name: Build test source distribution
uses: openweathermap/deker-actions/.github/workflows/build.yml@master

upload_test_pypi:
name: Upload test source distribution
needs: build_sdist
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: testpypi
url: https://test.pypi.org/p/deker
url: https://test.pypi.org/p/$PACKAGE_NAME

steps:
- uses: actions/download-artifact@v3
Expand All @@ -42,7 +31,7 @@ jobs:
name: artifact
path: dist

- name: Publish package distributions to PyPI
- name: Publish test source distributions to Test-PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = "Dekerdoc"
htmlhelp_basename = "deker-doc"

# -- Custom Settings -------------------------------------------------------

Expand Down
Loading

0 comments on commit 770b679

Please sign in to comment.