diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ca2e92..0743eb2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/protobuf/action.yaml b/.github/workflows/protobuf/action.yaml new file mode 100644 index 0000000..3a6caf0 --- /dev/null +++ b/.github/workflows/protobuf/action.yaml @@ -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 diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..6425201 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,5 @@ +# Global options: + +[mypy] +ignore_missing_imports = True +disable_error_code = var-annotated diff --git a/pyproject.toml b/pyproject.toml index 7119a2a..305cec8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = "cnfty786@gmail.com" }, @@ -24,7 +24,10 @@ 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" @@ -32,7 +35,7 @@ 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 = [ @@ -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:.}", @@ -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 @@ -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]