forked from mindsdb/minds
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (127 loc) · 4.72 KB
/
Copy pathtests_unit.yml
File metadata and controls
140 lines (127 loc) · 4.72 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
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
name: Unit Tests
permissions:
contents: read
on:
workflow_call:
defaults:
run:
shell: bash
jobs:
# Run all of our static code checks here
code_checking:
name: Run static code checks
runs-on: mdb-dev
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # required to grab the history of the PR so pre-commit can work out what's changed
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
cache-local-path: "/home/runner/_work/_tool/uv-local-cache" # Place cache in the tool dir because we mount this in our runnners
prune-cache: false # We want to save all cache because it's in the mount^
python-version: ${{ vars.CI_PYTHON_VERSION || '3.11' }} # Default to 3.11 where vars aren't available (PRs from forks)
# Checks the codebase for print() statements and fails if any are found
# We should be using loggers instead
- name: Check for print statements
run: |
# The pyproject file confuses uv: https://github.com/astral-sh/uv/issues/6838
rm pyproject.toml
uv run tests/scripts/check_print_statements.py
- name: Install MDB dev requirements
run: |
uv pip install -r requirements/requirements-dev.txt
# Run pre-commit on all changed files
# See .pre-commit-config.yaml for the list of checks
- name: Run pre-commit
run: |
pre-commit run --show-diff-on-failure --color=always --from-ref ${{ github.event.pull_request.base.sha || 'HEAD~1' }} --to-ref ${{ github.event.pull_request.head.sha || 'HEAD' }}
# Runs a few different checks against our many requirements files
# to make sure they're in order
- name: Check requirements files
run: |
uv run tests/scripts/check_requirements.py
# Creates a matrix of environments to test against using matrix_includes.json
matrix_prep:
name: Prepare matrix
runs-on: mdb-dev
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- id: set-matrix
uses: JoshuaTheMiller/conditional-build-matrix@v2.0.1
with:
filter: "[?runOnBranch==`${{ github.ref }}` || runOnBranch==`always`]"
# Check that our pip package is able to be installed in all of our supported environments
check_install:
name: Check pip installation
needs: [matrix_prep, code_checking]
strategy:
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
runs-on: ${{ matrix.runs_on }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Check pip package builds and installs
run: |
# Install dev requirements and build our pip package
uv pip install -r requirements/requirements-dev.txt
python setup.py sdist
# Install from the pip package
# If we install from source, we don't know if the pip package is installable.
cd dist
uv pip install *.tar.gz
unit_tests:
name: Run Unit Tests
needs: [matrix_prep, code_checking]
strategy:
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
runs-on: ${{ matrix.runs_on }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
# TODO: for now some tests rely on lightwood
uv pip install . \
-r requirements/requirements-test.txt \
.[lightwood] \
.[clickhouse] \
.[snowflake] \
.[web] \
.[redshift] \
.[bigquery] \
.[databricks] \
.[oracle] \
.[slack] \
.[github] \
.[ms_teams] \
.[salesforce] \
.[statsforecast] \
.[mysql] \
.[chromadb] \
.[mssql]
uv pip freeze
git clone --branch v$(uv pip show mindsdb_sql_parser | grep Version | cut -d ' ' -f 2) https://github.com/mindsdb/mindsdb_sql_parser.git parser_tests
- name: Run unit tests
run: |
make unit_tests_slow