Skip to content

Commit

Permalink
Merge pull request #50 from scs/feature/upgrade
Browse files Browse the repository at this point in the history
* update dependencies
* add Python 3.10 code checks
* update and fix Github workflows & scripts
* update documentation
  • Loading branch information
raymar9 authored May 19, 2023
2 parents d65062b + e89ffb6 commit 3ac817d
Show file tree
Hide file tree
Showing 11 changed files with 709 additions and 588 deletions.
43 changes: 17 additions & 26 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,48 @@ name: Build a Debian package
on:
push:
branches:
- '**'
- "**"
tags:
- 'v*'
- "v*"
workflow_dispatch:

permissions:
contents: write

jobs:
build-deb:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
os: [ 'debian', 'raspios' ]
os: ["debian", "raspios"]
include:
- os: debian
dist: buster
dist: bullseye
arch: amd64
keyring_cmd: sudo apt-get install -y debian-archive-keyring
- os: raspios
dist: buster
dist: bullseye
arch: armhf
keyring_cmd: wget http://archive.raspbian.org/raspbian/pool/main/r/raspbian-archive-keyring/raspbian-archive-keyring_20120528.2_all.deb && sudo dpkg -i raspbian-archive-keyring_20120528.2_all.deb

name: Build a Debian package for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v3
- name: Update apt cache
run: |
sudo apt-get update
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8

python-version: 3.9
cache: "pipenv"
- name: Install pipenv
run: |
python -m pip install --upgrade pip pipenv
python --version; python -m pip --version; pipenv --version
- name: Cache pipenv environment
id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-3.8-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Setup project with pipenv
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --dev
pipenv --python 3.9 install --dev
- name: Prepare to build a Debian source package
run: |
sudo apt-get -y install python3-all debhelper dh-python rename
Expand All @@ -65,10 +55,11 @@ jobs:
- name: Cache pbuilder chroot
id: cache-pbuilder-chroot
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-base.tgz
key: ${{ runner.os }}-pbuilder-${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-${{ hashFiles('**/Pipfile.lock') }}

- name: Prepare the pbuilder chroot for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}
if: steps.cache-pbuilder-${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-chroot.outputs.cache-hit != 'true'
run: |
Expand All @@ -86,13 +77,13 @@ jobs:
sudo rename "s/_all\./_${{ matrix.arch }}\./" /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/result/*.deb
- name: Archive the built Debian package for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-deb
path: /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/result/*.deb

- name: Archive the additional Debian package files for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-packagefiles
path: |
Expand All @@ -102,11 +93,11 @@ jobs:
- name: Get the tag name
id: tag-name
if: startsWith(github.ref, 'refs/tags')
uses: olegtarasov/[email protected].1
uses: olegtarasov/[email protected].2

- name: Create a new release
if: startsWith(github.ref, 'refs/tags')
uses: ncipollo/release-action@v1.8.8
uses: ncipollo/release-action@v1.12.0
with:
allowUpdates: true
artifacts: /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/result/*.deb
Expand Down
32 changes: 13 additions & 19 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,66 @@ name: Publish Python package to PyPI / Test PyPI
on:
push:
branches:
- '**'
- "**"
tags:
- 'v*'
- "v*"
workflow_dispatch:

permissions:
contents: write

jobs:
build-and-publish:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

name: Build a Python package and upload it to PyPI / Test PyPI
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8

python-version: 3.9
cache: "pipenv"
- name: Install pipenv
run: |
python -m pip install --upgrade pip pipenv
python --version; python -m pip --version; pipenv --version
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-3.8-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Setup project with pipenv
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --dev
pipenv --python 3.9 install --dev
- name: Build a Python package
run: |
pipenv run build
- name: Archive the built Python package
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: smartmeter-datacollector-py
path: dist/*

- name: Publish the Python package to Test PyPI
if: github.ref == 'refs/heads/master'
uses: pypa/gh-action-pypi-publish@v1.4.2
uses: pypa/gh-action-pypi-publish@v1.8.6
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

- name: Publish the Python package to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.4.2
uses: pypa/gh-action-pypi-publish@v1.8.6
with:
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Get the tag name
id: tag-name
if: startsWith(github.ref, 'refs/tags')
uses: olegtarasov/[email protected].1
uses: olegtarasov/[email protected].2

- name: Create a new release
if: startsWith(github.ref, 'refs/tags')
uses: ncipollo/release-action@v1.8.8
uses: ncipollo/release-action@v1.12.0
with:
allowUpdates: true
artifacts: dist/*.tar.gz,dist/*.whl
Expand Down
26 changes: 8 additions & 18 deletions .github/workflows/python-code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,42 @@ name: Python code checks
on:
push:
branches:
- '**'
- "**"
pull_request:
branches:
- master
workflow_dispatch:

jobs:
check_python_code:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9' ]
python-version: ["3.8", "3.9", "3.10"]

name: Running Python code checks with Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

cache: "pipenv"
- name: Install pipenv
run: |
python -m pip install --upgrade pip pipenv
python --version; python -m pip --version; pipenv --version
- name: Adjust Python version in Pipfile
run: |
sed -i 's/^python_version = .*/python_version = "${{ matrix.python-version }}"/' Pipfile
cat Pipfile
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-${{ matrix.python-version }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Setup project with pipenv
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --dev
pipenv --python ${{ matrix.python-version }} install --dev
- name: Check code style
run: |
pipenv run format_check
- name: Check import order
run: |
pipenv run isort_check
- name: Lint with pylint
- name: Lint with pylint
run: |
pipenv run lint_check
- name: Run unit tests
Expand Down
22 changes: 10 additions & 12 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ verify_ssl = true
name = "pypi"

[packages]
aioserial = "~=1.3.0"
asyncio-mqtt = "~=0.10.0"
gurux-dlms = "==1.0.107"
aioserial = "~=1.3.1"
asyncio-mqtt = "~=0.16.1"
gurux-dlms = "==1.0.143"

[dev-packages]
autopep8 = "*"
Expand All @@ -15,31 +15,29 @@ isort = "*"
licenseheaders = "*"
pipenv-setup = "*"
pylint = "*"
pytest = "*"
pytest-asyncio = "*"
pytest-mock = "*"
setuptools = "*"
stdeb = {version="*", markers="sys_platform == 'linux'"}
twine = "*"
vistir = "~=0.6.1"
wheel = "*"
pytest = "*"
pytest-mock = "*"
pytest-asyncio = "*"

[requires]
python_version = "3.8"

[scripts]
build = "bash ./scripts/build.sh"
build_check = "twine check dist/*"
build_srcdeb = "bash ./scripts/build_srcdeb.sh"
build_deb = "bash ./scripts/build_deb.sh"
build_srcdeb = "bash ./scripts/build_srcdeb.sh"
clean = "rm -rf .eggs build dist deb_dist smartmeter_datacollector.egg-info"
debianize = "bash ./scripts/debianize.sh"
format_check = "autopep8 --diff -r --aggressive smartmeter_datacollector/"
format = "autopep8 --in-place -r --aggressive smartmeter_datacollector/"
format_check = "autopep8 --diff -r --aggressive smartmeter_datacollector/"
isort = "isort ."
isort_check = "isort --check ."
license = "licenseheaders -t .copyright.tmpl --ext py --current-year --owner 'Supercomputing Systems AG' --projname 'smartmeter-datacollector'"
lint = "pylint smartmeter_datacollector/"
lint_check = "pylint smartmeter_datacollector/ --exit-zero"
license = "licenseheaders -t .copyright.tmpl --ext py --current-year --owner 'Supercomputing Systems AG' --projname 'smartmeter-datacollector'"
setup = "pipenv-setup sync"
setup_check = "pipenv-setup check"
test = "pytest"
Loading

0 comments on commit 3ac817d

Please sign in to comment.