-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathgithub-actions-python-package.yml
More file actions
52 lines (46 loc) · 2.21 KB
/
Copy pathgithub-actions-python-package.yml
File metadata and controls
52 lines (46 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Python package
on: [push,pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .["dev"] --extra-index-url https://download.pytorch.org/whl/cpu
pip install mypy
- name: Lint with ruff
run: |
ruff check dicee/ --line-length=200
- name: Type check with mypy (ratchet: error count must not increase)
run: |
# See docs/TYPING_ROADMAP.md for the type hints enforcement strategy.
# The codebase isn't fully typed yet, so mypy isn't blocking on every
# pre-existing error. Instead, this step fails only if the total
# error count grows past the recorded baseline, so new code can't
# add fresh type errors while existing debt is paid down gradually.
# If you fix errors, lower .github/mypy-baseline.txt to lock in the
# improvement; only raise it if a change unavoidably adds errors.
mypy dicee/ --config-file=pyproject.toml > mypy_output.txt 2>&1 || true
cat mypy_output.txt
CURRENT_ERRORS=$(grep -oP 'Found \K[0-9]+(?= errors?)' mypy_output.txt || echo 0)
BASELINE_ERRORS=$(cat .github/mypy-baseline.txt)
echo "mypy errors: $CURRENT_ERRORS (baseline: $BASELINE_ERRORS)"
if [ "$CURRENT_ERRORS" -gt "$BASELINE_ERRORS" ]; then
echo "::error::mypy error count increased from $BASELINE_ERRORS to $CURRENT_ERRORS. Fix the newly introduced errors, or update .github/mypy-baseline.txt only if the increase is intentional and reviewed."
exit 1
fi
- name: Testing and coverage report
run: |
wget https://files.dice-research.org/datasets/dice-embeddings/KGs.zip --no-check-certificate && unzip KGs.zip
pip install coverage
coverage run -m pytest -p no:warnings -x
coverage report -m