Skip to content

Commit

Permalink
ci: add format & lint & test
Browse files Browse the repository at this point in the history
Signed-off-by: LingKa <[email protected]>
  • Loading branch information
LingKa28 committed Sep 30, 2023
1 parent 2fdc0a4 commit aa7836f
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 7 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,57 @@ on:
branches: [main]

jobs:
lint:
name: Check Lint & Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Pip
run: sudo apt install pip

- name: Install Hatch
run: pip install hatch

- name: Run lint & fmt
run: hatch run lint:all

test:
name: Test Validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Pip
run: sudo apt install pip

- name: Generate API
uses: ./.github/workflows/protobuf

- name: Install Hatch
run: pip install hatch

- name: Start the cluster
run: ./scripts/quick_start.sh

- name: Run test
run: hatch run cov

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true
verbose: true

commit:
name: Commit Message Validation
runs-on: ubuntu-latest
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/protobuf/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Generate API

runs:
using: "composite"
steps:
- name: Install gRPC
run: python3 -m pip install grpcio
shell: bash
- name: Install gRPC tools
run: python3 -m pip install grpcio-tools
shell: bash

- name: Initialize Git Submodules
run: git submodule init
shell: bash
- name: Update Git Submodules
run: git submodule update
shell: bash

- name: Generate api
run: make
shell: bash
5 changes: 5 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Global options:

[mypy]
ignore_missing_imports = True
disable_error_code = var-annotated
19 changes: 12 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dynamic = ["version"]
description = 'py-xline is an official xline client sdk, written in Python.'
readme = "README.md"
requires-python = ">=3.7"
license = "Apache 2.0"
license = "Apache-2.0"
keywords = []
authors = [
{ name = "LingKa", email = "[email protected]" },
Expand All @@ -24,15 +24,18 @@ classifiers = [
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = []
dependencies = [
"grpcio",
"grpcio-tools",
]

[project.urls]
Documentation = "https://github.com/xline-kv/py-xline#readme"
Issues = "https://github.com/xline-kv/py-xline/issues"
Source = "https://github.com/xline-kv/py-xline"

[tool.hatch.version]
path = "src/py_xline/__about__.py"
path = "client/__about__.py"

[tool.hatch.envs.default]
dependencies = [
Expand Down Expand Up @@ -63,7 +66,7 @@ dependencies = [
"ruff>=0.0.243",
]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/py_xline tests}"
typing = "mypy --install-types --non-interactive {args:client tests}"
style = [
"ruff {args:.}",
"black --check --diff {args:.}",
Expand Down Expand Up @@ -117,11 +120,13 @@ ignore = [
# Allow non-abstract empty methods in abstract base classes
"B027",
# Allow boolean positional values in function calls, like `dict.get(... True)`
"FBT003",
"FBT001", "FBT002", "FBT003",
# Ignore checks for possible passwords
"S105", "S106", "S107",
# Ignore complexity
"C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915",
# Ignore import sort
"I001"
]
unfixable = [
# Don't touch unused imports
Expand All @@ -139,11 +144,11 @@ ban-relative-imports = "all"
"tests/**/*" = ["PLR2004", "S101", "TID252"]

[tool.coverage.run]
source_pkgs = ["py_xline", "tests"]
source_pkgs = ["client", "tests"]
branch = true
parallel = true
omit = [
"src/py_xline/__about__.py",
"client/__about__.py",
]

[tool.coverage.paths]
Expand Down

0 comments on commit aa7836f

Please sign in to comment.