From b004f50558b5e54b7967484658b9d1a5abf30936 Mon Sep 17 00:00:00 2001 From: Javed Habib Date: Tue, 14 May 2024 11:48:41 +0530 Subject: [PATCH] github actions cache, and create dep groups in pyproject for CI --- .github/workflows/code_lint_format.yaml | 58 +++++++++++++++++++ .github/workflows/code_test.yaml | 45 ++++++++++++++ ...r.yaml => docker_build_publish_filer.yaml} | 0 ...l => docker_build_publish_taskmaster.yaml} | 0 .../{helm-test.yaml => helm_test.yaml} | 0 .github/workflows/lint-format.yaml | 53 ----------------- ...r-evaulations.yaml => pr_evaulations.yaml} | 0 .github/workflows/test.yaml | 39 ------------- .github/workflows/type-check.yaml | 43 -------------- .github/workflows/type_check.yaml | 37 ++++++++++++ poetry.lock | 2 +- pyproject.toml | 24 ++++++-- 12 files changed, 161 insertions(+), 140 deletions(-) create mode 100644 .github/workflows/code_lint_format.yaml create mode 100644 .github/workflows/code_test.yaml rename .github/workflows/{docker-build-publish-filer.yaml => docker_build_publish_filer.yaml} (100%) rename .github/workflows/{docker-build-publish-taskmaster.yaml => docker_build_publish_taskmaster.yaml} (100%) rename .github/workflows/{helm-test.yaml => helm_test.yaml} (100%) delete mode 100644 .github/workflows/lint-format.yaml rename .github/workflows/{pr-evaulations.yaml => pr_evaulations.yaml} (100%) delete mode 100644 .github/workflows/test.yaml delete mode 100644 .github/workflows/type-check.yaml create mode 100644 .github/workflows/type_check.yaml diff --git a/.github/workflows/code_lint_format.yaml b/.github/workflows/code_lint_format.yaml new file mode 100644 index 00000000..ffa03921 --- /dev/null +++ b/.github/workflows/code_lint_format.yaml @@ -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 \ No newline at end of file diff --git a/.github/workflows/code_test.yaml b/.github/workflows/code_test.yaml new file mode 100644 index 00000000..5d846fee --- /dev/null +++ b/.github/workflows/code_test.yaml @@ -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 }} diff --git a/.github/workflows/docker-build-publish-filer.yaml b/.github/workflows/docker_build_publish_filer.yaml similarity index 100% rename from .github/workflows/docker-build-publish-filer.yaml rename to .github/workflows/docker_build_publish_filer.yaml diff --git a/.github/workflows/docker-build-publish-taskmaster.yaml b/.github/workflows/docker_build_publish_taskmaster.yaml similarity index 100% rename from .github/workflows/docker-build-publish-taskmaster.yaml rename to .github/workflows/docker_build_publish_taskmaster.yaml diff --git a/.github/workflows/helm-test.yaml b/.github/workflows/helm_test.yaml similarity index 100% rename from .github/workflows/helm-test.yaml rename to .github/workflows/helm_test.yaml diff --git a/.github/workflows/lint-format.yaml b/.github/workflows/lint-format.yaml deleted file mode 100644 index 44dfb19f..00000000 --- a/.github/workflows/lint-format.yaml +++ /dev/null @@ -1,53 +0,0 @@ -name: Lint and Format - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - lint-and-format: - runs-on: ubuntu-latest - steps: - # Check out repository - - name: Check out repository - uses: actions/checkout@v3 - - # Set up python - - name: Set up python - id: setup-python - uses: actions/setup-python@v3 - with: - python-version: '3.11' - - # Install Poetry - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true - - # Load cached if it exists - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v2 - with: - path: .venv - key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - - # Install dependencies if cache does not exist - - name: Install dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root - - # Run lint suite - - name: Check code quality - run: poetry run ruff check . - - # Run format suite - - name: Check code style - run: poetry run ruff format --check \ No newline at end of file diff --git a/.github/workflows/pr-evaulations.yaml b/.github/workflows/pr_evaulations.yaml similarity index 100% rename from .github/workflows/pr-evaulations.yaml rename to .github/workflows/pr_evaulations.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 411e6932..00000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Test - -on: - - push - - pull_request - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.11', '3.12'] - - 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 - with: - python-version: ${{ matrix.python-version }} - - # Install dependencies if cache does not exist - - name: Install dependencies - run: poetry install - - # Run tests - - name: Run tests - run: poetry run pytest tests/ - - # # 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 }} \ No newline at end of file diff --git a/.github/workflows/type-check.yaml b/.github/workflows/type-check.yaml deleted file mode 100644 index 63d2e051..00000000 --- a/.github/workflows/type-check.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# 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 -# - pull_request - -# jobs: -# check-type: -# runs-on: ubuntu-latest -# steps: -# # Check out repository -# - name: Check out repository -# uses: actions/checkout@v3 -# # Set up python -# - name: Set up python -# id: setup-python -# uses: actions/setup-python@v3 -# with: -# python-version: '3.11' -# # Install Poetry -# - name: Install Poetry -# uses: snok/install-poetry@v1 -# with: -# virtualenvs-create: true -# virtualenvs-in-project: true -# installer-parallel: true -# # Load cached if it exists -# - name: Load cached venv -# id: cached-poetry-dependencies -# uses: actions/cache@v2 -# with: -# path: .venv -# key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} -# # Install dependencies if cache does not exist -# - name: Install dependencies -# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' -# run: poetry install --no-interaction --no-root -# # Run type checking suite -# - name: Check types -# run: poetry run mypy tesk/ \ No newline at end of file diff --git a/.github/workflows/type_check.yaml b/.github/workflows/type_check.yaml new file mode 100644 index 00000000..be0c8115 --- /dev/null +++ b/.github/workflows/type_check.yaml @@ -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/ diff --git a/poetry.lock b/poetry.lock index ba6222ec..a024680e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1050,4 +1050,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "7fcccae3a9b635514f350bbc57eff14699809d7733859c1c84df047fe2d0ebdb" +content-hash = "0f4988c136e2346ca35f185bdc5627103edab923ea65ea560037df88bafe6a21" diff --git a/pyproject.toml b/pyproject.toml index ac53c9a9..fc32a284 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] @@ -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