forked from acl-org/acl-anthology
-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (69 loc) · 2.32 KB
/
code-quality.yml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Checks
on:
push:
branches:
- master
paths:
- '.pre-commit-config.yaml'
- '.codecov.yml'
- 'python/**'
pull_request:
paths:
- '.pre-commit-config.yaml'
- '.codecov.yml'
- 'python/**'
jobs:
build:
defaults:
run:
working-directory: ./python
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
poetry-version: ["1.7.1"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
# Setup all dependencies
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Cache virtual environment based on Poetry lockfile
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: poetry install --with dev --verbose
- name: Cache pre-commit hooks based on pre-commit config
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ matrix.os }}|${{ matrix.python-version }}|${{ hashFiles('~/.pre-commit-config.yaml') }}
# Run all checks and tests
- name: Run pre-commit hooks
run: poetry run pre-commit run --all-files
env:
SKIP: no-commit-to-branch
- name: Run type checker
run: poetry run mypy acl_anthology
- name: Run tests
run: poetry run pytest -m "not integration" --cov=acl_anthology --cov-report=xml
# Run integration tests, but only run on latest Python version to save time
- name: Run integration tests
if: ${{ matrix.python-version == '3.12' }}
run: poetry run pytest -m "integration" --cov=acl_anthology --cov-report=xml --cov-append
# Coverage report
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3