Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI #229

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/install-poetry@v1.3.4

- name: Create venv cache
id: cache-venv
uses: actions/cache@v4.0.0
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/install-poetry@v1.3.4
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/install-poetry@v1.3.4

- name: Create venv cache
id: cache-venv
uses: actions/cache@v4.0.0
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/install-poetry@v1.3.4
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