ci: add dead code detection #5388
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push] | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
cache: "pip" | |
- uses: pre-commit/[email protected] | |
pylint: | |
runs-on: ubuntu-latest | |
name: Pylint test | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e ".[dev]" | |
- name: Analysing the code with pylint | |
run: | | |
pylint --rcfile=.pylintrc src/kili | |
pyright: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
version: ["3.8", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.version }} | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e ".[dev]" | |
- name: Run pyright | |
run: pyright . | |
unit-integration-test: | |
timeout-minutes: 15 | |
name: Unit and integration tests | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
python-version: 3.8 | |
- os: windows-latest | |
python-version: 3.8 | |
- os: ubuntu-latest | |
python-version: 3.12 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e ".[dev]" | |
- name: Unit and integration tests | |
run: pytest -n auto -ra -sv --color yes --code-highlight yes --durations=15 -vv --ignore tests/e2e/ --cov=src/kili --cov-report=term-missing --cov-config=.coveragerc --cov-fail-under=82 | |
markdown-link-check: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: lycheeverse/[email protected] | |
with: | |
fail: true | |
debug: false | |
args: "-qq --no-progress --insecure './**/*.md' './src/kili/**/*.py'" | |
build-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build twine | |
- name: Build | |
run: | | |
python -m build | |
- name: Test the Build | |
run: | | |
python -m pip install . # to install dependencies | |
python -m pip uninstall -y kili | |
python -m pip install --find-links=dist --no-index kili | |
python -c 'from kili.client import Kili; k=Kili(); print("Everything OK!")' | |
env: | |
KILI_API_ENDPOINT: https://cloud.kili-technology.com/api/label/v2/graphql | |
KILI_API_KEY: ${{ secrets.KILI_USER_API_KEY_PROD }} | |
doc-build-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e ".[dev]" | |
- name: Build | |
run: | | |
mkdocs build | |
- name: Look for Warnings | |
run: | | |
mkdocs build 2>&1 | tee doc-build.log | |
if grep -q "WARNING" doc-build.log; then | |
echo $(grep "WARNING" doc-build.log) | |
echo "::error::Documentation build completed with warnings" | |
exit 1 | |
else | |
echo "Documentation build completed successfully" | |
fi | |
find-dead-code: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e ".[dev]" | |
- name: Find dead code with vulture | |
run: vulture src/kili tests > dead_code.log || true | |
- name: Find dead code with dead | |
run: dead >> dead_code.log || true | |
- name: Log dead code | |
run: >- | |
cat dead_code.log | | |
grep -e "src/kili" | | |
grep -v | |
-e "is only referenced in tests" | |
-e "_ is never read" | |
-e "internal.py" | |
-e "unused attribute 'internal'" | |
-e "affected_rows" | |
-e "src/kili/orm" | |
-e "src/kili/types.py" | |
-e "src/kili/services" | |
-e "src/kili/entrypoints" | |
-e "src/kili/core/graphql/ws_graphql_client" | |
> dead_code_filtered.log | |
- name: Crash if dead code found | |
run: | | |
if [ $(cat dead_code_filtered.log | wc -l) -gt 0 ]; then | |
cat dead_code.log | |
echo "\nDead code found" | |
exit 1 | |
else | |
echo "No dead code found" | |
fi |