-
Notifications
You must be signed in to change notification settings - Fork 749
150 lines (125 loc) Β· 3.94 KB
/
ci.yaml
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: CI
on:
pull_request:
permissions:
contents: read
env:
LINES: 120
COLUMNS: 120
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun
defaults:
run:
shell: bash --noprofile --norc -exo pipefail {0}
jobs:
diff:
runs-on: ubuntu-latest
outputs:
related: ${{ steps.filter.outputs.related }}
ragas: ${{ steps.filter.outputs.ragas }}
docs: ${{ steps.filter.outputs.docs }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
base: "main"
token: ${{ github.token }}
filters: |
related: &related
- .github/workflows/ci.yml
- codecov.yml
- pyproject.toml
- requirements/test.txt
ragas:
- *related
- "src/ragas/**"
- "tests/**"
ragas_experimental:
- "src/experimental/**"
docs:
- *related
- requirements/docs-requirements.txt
- "docs/**"
unit_tests:
needs:
- diff
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.ragas == 'true') || github.event_name == 'push' }}
name: python${{ matrix.python-version }}_unit_tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all tags and branches
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.os == 'macos-latest' && 'arm64' || 'x64' }}
- name: Get pip cache dir
id: cache-dir
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache pip dependencies
uses: actions/cache@v3
id: cache-pip
with:
path: ${{ steps.cache-dir.outputs.dir }}
key: ${{ runner.os }}-tests-${{ hashFiles('requirements/test.txt') }}
- name: Install dependencies
run: |
pip install "."
pip install -r requirements/test.txt
- name: Run unit tests
run: |
# OPTS=(--cov-config pyproject.toml --cov=src/bentoml --cov-append)
if [ "${{ matrix.os }}" != 'windows-latest' ]; then
# we will use pytest-xdist to improve tests run-time.
OPTS=(--dist loadfile -n auto)
fi
# Now run the unit tests
pytest --nbmake tests/unit "${OPTS[@]}"
env:
__RAGAS_DEBUG_TRACKING: true
RAGAS_DO_NOT_TRACK: true
codestyle_check:
runs-on: ubuntu-latest
needs:
- diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.ragas == 'true') || github.event_name == 'push' }}
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.10.6"
architecture: x64
- name: Get pip cache dir
id: cache-dir
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Fetch origin
run: git fetch origin "$GITHUB_BASE_REF"
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "17"
- name: Cache pip dependencies
uses: actions/cache@v3
id: cache-pip
with:
path: ${{ steps.cache-dir.outputs.dir }}
key: codestyle-${{ hashFiles('requirements/dev.txt') }}
- name: Install dependencies
run: |
pip install .
pip install -r requirements/dev.txt
- name: Lint check
run: make lint
- name: Type check
if: ${{ github.event_name == 'pull_request' }}
run: make type