Skip to content

Commit

Permalink
Fix CI (#229)
Browse files Browse the repository at this point in the history
* Run linters and formatters on latest python

* Consolidate linters in single run

* Update cache action to v4

* Run mosquitto for proper integration tests

* Drop unstable amqtt broker
  • Loading branch information
Orhideous authored Feb 15, 2024
1 parent 0f2cd7a commit 6cdf5a8
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 352 deletions.
5 changes: 5 additions & 0 deletions .ci/mosquitto.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
allow_anonymous false
listener 8883
password_file /mosquitto/config/mosquitto.passwd
certfile /mosquitto-certs/test.crt
keyfile /mosquitto-certs/test.key
1 change: 1 addition & 0 deletions .ci/mosquitto.passwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test:$7$101$QwCQMINr0PmhId3d$K8g2qV5gw0Q3Dk9gXNB6TOsjGKD2tfptmdG5Ib5wEfuE4emzZjBP9L7z7y9jZFKVZQFVHMzYajnqTZk18KkGdw==
File renamed without changes.
File renamed without changes.
128 changes: 45 additions & 83 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
workflow_dispatch:

jobs:
black:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -22,88 +22,34 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"

- name: Install Poetry
uses: snok/[email protected]

- name: Create venv cache
id: cache-venv
uses: actions/[email protected]
with:
path: ${{env.venv-path}}
key: ${{ runner.os }}-venv-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-venv-
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
poetry install
- name: Black
run: |
poetry run black --config pyproject.toml --check --diff --verbose .
isort:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Poetry
uses: snok/[email protected]
virtualenvs-create: true
virtualenvs-in-project: true

- name: Create venv cache
id: cache-venv
uses: actions/cache@v4.0.0
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: ${{env.venv-path}}
key: ${{ runner.os }}-venv-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-venv-
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
poetry install
- name: isort
run: |
poetry run isort --check --diff --verbose .
flake8:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Poetry
uses: snok/[email protected]

- name: Create venv cache
id: cache-venv
uses: actions/[email protected]
with:
path: ${{env.venv-path}}
key: ${{ runner.os }}-venv-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-venv-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
poetry install
- name: Install library
run: poetry install --no-interaction

- name: flake8
- name: Run linters
run: |
poetry run flake8 --config .flake8 --verbose --count .
source .venv/bin/activate
black --config pyproject.toml --check --diff --verbose .
isort --check --diff --verbose .
flake8 --config .flake8 --verbose --count .
pytest:
runs-on: ubuntu-latest
Expand All @@ -115,27 +61,43 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

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

- name: Create venv cache
id: cache-venv
uses: actions/cache@v4.0.0
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: ${{env.venv-path}}
key: ${{ runner.os }}-${{ matrix.python-version }}-venv-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-venv-
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install library
run: poetry install --no-interaction

- name: Start Mosquitto
uses: namoshek/mosquitto-github-action@v1
with:
version: '2.0.18'
ports: '8883:8883'
certificates: ${{ github.workspace }}/.ci/tls-certificates
config: ${{ github.workspace }}/.ci/mosquitto.conf
password-file: ${{ github.workspace}}/.ci/mosquitto.passwd
container-name: 'mqtt'

- name: Run Pytest
run: |
poetry run pytest --verbose
source .venv/bin/activate
pytest --verbose
Loading

0 comments on commit 6cdf5a8

Please sign in to comment.