Skip to content

Commit

Permalink
refactor(ci-cd): run CI on both supported versions
Browse files Browse the repository at this point in the history
  • Loading branch information
HormCodes committed Feb 3, 2024
1 parent ff5f28c commit 6571b86
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 25 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/release.yml → .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish to PyPI and GitHub
on:
workflow_dispatch:
inputs:
tag:
tag:
description: New version tag
required: true

Expand All @@ -26,10 +26,12 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.x"

- name: Update pyproject.toml Version
run: |
pip install tomlkit
Expand All @@ -42,8 +44,9 @@ jobs:
with open('pyproject.toml', 'w') as file:
file.write(tomlkit.dumps(content))
"
- name: Update __init__.py version
run: |
run: |
version="${{ github.event.inputs.tag }}"
file="airthings_ble/__init__.py"
sed -i "s/__version__\\s*=\\s*[\"'].*[\"']/__version__ = \"$version\"/" $file
Expand All @@ -57,13 +60,16 @@ jobs:
git push
git tag ${{ github.event.inputs.tag }}
git push --tags
- name: Build source and wheel distributions
run: |
python -m pip install --upgrade build twine
python -m build
twine check --strict dist/*
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Release
uses: softprops/action-gh-release@v1
with:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
pull_request:

env:
# Reference: https://github.com/home-assistant/architecture/blob/master/adr/0002-minimum-supported-python-version.md
SUPPORTED_PYTHON_VERSIONS: "['3.11', '3.12']"

jobs:
test:
strategy:
matrix:
python-version: ${{ fromJson(env.SUPPORTED_PYTHON_VERSIONS) }}
name: Run tests on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- uses: snok/install-poetry@v1

- name: Install Dependencies
run: poetry install

- name: Run tests
run: poetry run pytest

lint:
strategy:
matrix:
python-version: ${{ fromJson(env.SUPPORTED_PYTHON_VERSIONS) }}
name: Lint code on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- uses: snok/install-poetry@v1

- name: Install Dependencies
run: poetry install
- name: Run linters
run: poetry run make lint
22 changes: 0 additions & 22 deletions .github/workflows/lint.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ the [Home Assistant integration](https://www.home-assistant.io/integrations/airt

Prerequisites:

- [Python](https://www.python.org/downloads/) with version 3.11 that is required by Home Assistant ([docs](https://developers.home-assistant.io/docs/development_environment?_highlight=python&_highlight=versi#manual-environment))
- [Python](https://www.python.org/downloads/) with version 3.11 that is required by Home Assistant ([docs](https://developers.home-assistant.io/docs/development_environment?_highlight=python&_highlight=versi#manual-environment) or [reference](https://github.com/home-assistant/architecture/blob/master/adr/0002-minimum-supported-python-version.md))
- [Poetry](https://python-poetry.org/docs/#installation)

Install dependencies:
Expand Down

0 comments on commit 6571b86

Please sign in to comment.