Skip to content

Commit

Permalink
github actions cache, and create dep groups in pyproject for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeAeich committed May 14, 2024
1 parent 91a9dc0 commit b004f50
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 140 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/code_lint_format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Code Quality

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v5
id: cql
with:
python-version: '3.11'
cache: 'poetry'

# Install lint deps only
- name: Install dependencies
if: steps.cql.outputs.cache-hit != 'true'
run: poetry install --only=lint --no-interaction --no-root

- name: Check code quality
run: poetry run ruff check .

format:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v5
id: cqf
with:
python-version: '3.11'
cache: 'poetry'

# Install lint deps only
- name: Install dependencies
if: steps.cqf.outputs.cache-hit != 'true'
run: poetry install --only=lint --no-interaction --no-root

- name: Check code style
run: poetry run ruff format --check
45 changes: 45 additions & 0 deletions .github/workflows/code_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Code Test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
unit-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12', '3.13']

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

# Set up python versions with matrix to test on multiple versions
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
id: ctut-${{ matrix.python-version}}
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'

# Install all test dependencies
- name: Install dependencies
if: steps.ctut-${{ matrix.python-version }}.outputs.cache-hit != 'true'
run: poetry install --only=test --no-interaction --no-root

- name: Run tests
run: poetry run pytest tests/test_unit

# # Upload coverage reports to Codecov once the tests start running 😭
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v3
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
File renamed without changes.
53 changes: 0 additions & 53 deletions .github/workflows/lint-format.yaml

This file was deleted.

File renamed without changes.
39 changes: 0 additions & 39 deletions .github/workflows/test.yaml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/type-check.yaml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/type_check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow should work but will fail
# as the code has no types, will add types to the
# code and then uncomment it 👍
name: Type Check

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
check-type:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up python
id: tcct
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'poetry'

# Install only type check dependency
- name: Install dependencies
if: steps.tcct.outputs.cache-hit != 'true'
run: poetry install --only=type --no-root

- name: Check types
run: poetry run mypy tesk/
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ classifiers = [
"Intended Audience :: System Administrators",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]

[tool.poetry.scripts]
Expand All @@ -41,6 +39,24 @@ pytest-localftpserver = "*"
ruff = "^0.4.4"
mypy = "^1.10.0"

# dependency groups for CI, helps isolate
# dependencies that are only needed for specifc
# CI jobs
[tool.poetry.group.lint.dependencies]
ruff = "^0.4.4"

[tool.poetry.group.type.dependencies]
mypy = "^1.10.0"

[tool.poetry.group.test.dependencies]
pytest = "*"
pyfakefs = "*"
pytest-mock = "*"
fs = "*"
moto = "*"
pytest-localftpserver = "*"
kubernetes = "9.0.0"

[tool.ruff.lint]
select = [
"E", # pycodestyle
Expand Down

0 comments on commit b004f50

Please sign in to comment.