-
Notifications
You must be signed in to change notification settings - Fork 1
126 lines (108 loc) · 3.49 KB
/
ci.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: CI
on:
workflow_call:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
env:
PYTHON_VERSION: 3.11
# Disable tokenizers parallelism because this doesn't help, and can cause issues in distributed tests.
TOKENIZERS_PARALLELISM: "false"
# Disable multithreading with OMP because this can lead to dead-locks in distributed tests.
OMP_NUM_THREADS: "1"
# See https://github.com/pytorch/pytorch/issues/37377#issuecomment-677851112.
MKL_THREADING_LAYER: "GNU"
CI: "1"
jobs:
changes:
name: Check for Python file changes
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
outputs:
python: ${{steps.filter.outputs.python}}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
python:
- '**/*.py'
- 'storage/fixtures/**/*'
- 'configs/**/*'
- 'pyproject.toml'
- 'pdm.lock'
- '.github/workflows/ci.yml'
pre_commit_config:
- '.pre-commit-config.yaml'
test:
runs-on: ubuntu-latest
needs: [changes]
if: ${{needs.changes.outputs.python == 'true' && !github.event.pull_request.draft }}
steps:
- name: Checkpout repository
uses: actions/checkout@v4
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: true
- name: Install dependencies
run: pdm install --without notebooks,monitoring,lint
- name: Run tests
run: pdm run pytest --deselect tests/test_online_evaluation.py -n 2
check_pre_commit:
runs-on: ubuntu-latest
needs: [changes]
if: ${{ (needs.changes.outputs.python == 'true' || needs.changes.outputs.pre_commit_config == 'true') && !github.event.pull_request.draft }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
- name: Install pre-commit
run: |
pip install pre-commit
- name: Load cached pre-commit environment
uses: actions/cache@v4
id: pre-commit-cache
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}
restore-keys: |
${{ runner.os }}-pre-commit-
- name: Run pre-commit hook
id: run-pre-commit-hooks
run: |
git add .pre-commit-config.yaml
pre-commit run --color=always --all-files
- name: Annotate any changes using reviewdog
if: ${{ failure() }}
id: reviewdog-suggester
uses: reviewdog/action-suggester@v1
with:
tool_name: pre-commit
based_pyright:
runs-on: ubuntu-latest
needs: [changes]
if: ${{needs.changes.outputs.python == 'true' && !github.event.pull_request.draft }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: true
- name: Install dependencies
run: pdm install --without notebooks,monitoring,test
- name: Run basedpyright
run: pdm run basedpyright