Skip to content

Commit

Permalink
updated pre-commit hooks and CI config (#2197)
Browse files Browse the repository at this point in the history
* updated pre-commit hooks and CI config

* updated pre-commit hooks and CI config

* updated pre-commit hooks and CI config

---------

Co-authored-by: oleksandr-sandbx <[email protected]>
  • Loading branch information
sasha-apolo and oleksandr-sandbx authored Jan 8, 2025
1 parent aa36a70 commit 33343b5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 62 deletions.
44 changes: 22 additions & 22 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout commit
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version-file: .python-version
- name: Cache packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: py-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
Expand All @@ -30,13 +30,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout commit
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version-file: .python-version
- name: Cache packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: py-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
Expand All @@ -45,10 +45,10 @@ jobs:
- name: Run unit tests
run: make test_unit
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: .coverage-unit.xml
files: .coverage-unit.xml
flags: unit
name: unit

Expand All @@ -59,20 +59,20 @@ jobs:
MINIKUBE_DRIVER: none
steps:
- name: Checkout commit
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version-file: .python-version
- name: Cache packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: py-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
- name: Install dependencies
run: make setup
- name: Login to ghcr.io
uses: docker/login-action@v2.0.0
uses: docker/login-action@v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -94,10 +94,10 @@ jobs:
- name: Run integration tests
run: make test_integration
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: .coverage-integration.xml
files: .coverage-integration.xml
flags: integration
name: integration

Expand All @@ -106,20 +106,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout commit
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version-file: .python-version
- name: Cache packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: py-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
- name: Install dependencies
run: make setup
- name: Login to ghcr.io
uses: docker/login-action@v2.0.0
uses: docker/login-action@v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand Down
50 changes: 17 additions & 33 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v5.0.0'
hooks:
- id: check-added-large-files
- id: check-merge-conflict
exclude: "rst$"
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
- id: check-case-conflict
- id: check-json
- id: check-toml
- id: check-xml
- id: debug-statements
- id: check-added-large-files
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: check-symlinks
exclude: ^charts/
- repo: https://github.com/sondrelg/pep585-upgrade
rev: v1.0
hooks:
Expand All @@ -25,44 +33,20 @@ repos:
- python
- markdown
- rst
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v5.0.0'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
hooks:
- id: check-case-conflict
- id: check-json
- id: check-xml
- id: debug-statements
- id: check-added-large-files
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: check-symlinks
- id: debug-statements
# Another entry is required to apply file-contents-sorter to another file
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v5.0.0'
hooks:
- id: file-contents-sorter
files: |
docs/spelling_wordlist.txt|
.gitignore
# - repo: https://github.com/rhysd/actionlint
# rev: v1.6.8
# hooks:
# - id: actionlint-docker
# args:
# - -ignore
# - 'SC2155:'
# - -ignore
# - 'SC2086:'
# - -ignore
# - 'SC1004:'
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.29.4
rev: 0.30.0
hooks:
- id: check-github-actions
- id: check-github-workflows
Expand Down
10 changes: 5 additions & 5 deletions platform_api/handlers/jobs_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ def _check_scheduler_enabled_for_energy_schedule_name(
)

def multiname_key(
name: str, keys: Sequence[str], default: Any, trafaret: t.Trafaret
name: str, keys: Sequence[str], default: Any, trafaret_func: t.Trafaret
) -> t.Key:
_empty = object()

def _take_first(data: dict[str, Any]) -> dict[str, Any]:
for key in keys:
if data[key] is not _empty:
return trafaret(data[key])
return trafaret(default)
return trafaret_func(data[key])
return trafaret_func(default)

return t.keys.subdict(
name,
Expand Down Expand Up @@ -152,13 +152,13 @@ def _take_first(data: dict[str, Any]) -> dict[str, Any]:
"scheduler_enabled",
["scheduler_enabled", "is_preemptible"],
default=False,
trafaret=t.Bool(),
trafaret_func=t.Bool(),
),
multiname_key(
"preemptible_node",
["preemptible_node", "is_preemptible_node_required"],
default=False,
trafaret=t.Bool(),
trafaret_func=t.Bool(),
),
)
# Either flat structure or payload with container field are allowed
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def _admin_server_setup_db(
f"NP_ADMIN_CONFIG_TOKEN={admin_token}",
"NP_ADMIN_CONFIG_URL=http://host.docker.internal:8089",
f"NP_ADMIN_POSTGRES_DSN={admin_postgres_dsn}",
f"NP_ADMIN_NOTIFICATIONS_URL=http://host.docker.internal:8083",
"NP_ADMIN_NOTIFICATIONS_URL=http://host.docker.internal:8083",
"NP_ADMIN_NOTIFICATIONS_TOKEN=token",
],
}
Expand Down Expand Up @@ -182,7 +182,7 @@ async def admin_server(
f"NP_ADMIN_CONFIG_TOKEN={admin_token}",
"NP_ADMIN_CONFIG_URL=http://host.docker.internal:8089",
f"NP_ADMIN_POSTGRES_DSN={admin_postgres_dsn}",
f"NP_ADMIN_NOTIFICATIONS_URL=http://host.docker.internal:8083",
"NP_ADMIN_NOTIFICATIONS_URL=http://host.docker.internal:8083",
"NP_ADMIN_NOTIFICATIONS_TOKEN=token",
"NP_LOG_LEVEL=DEBUG",
],
Expand Down

0 comments on commit 33343b5

Please sign in to comment.