Skip to content

Commit 66f93e0

Browse files
feat: DEV-2546: Add tests for ML backend (#123)
* feat: DEV-2546: Add tests for ML backend * rename + cache Co-authored-by: Sergey Zhuk <[email protected]>
1 parent 7a4e315 commit 66f93e0

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

.github/workflows/tests.yml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: "Tests"
2+
3+
on:
4+
push:
5+
paths:
6+
- 'label_studio_ml/**'
7+
- '.github/workflows/tests.yml'
8+
- 'requirements**'
9+
tags-ignore:
10+
- '**'
11+
pull_request_target:
12+
types: [ opened, synchronize, reopened, ready_for_review ]
13+
branches: ['*', '*/*', master]
14+
15+
env:
16+
CACHE_NAME_PREFIX: v1
17+
18+
jobs:
19+
run_pytest:
20+
name: Run pytest for Label Studio ML backend
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 30
23+
env:
24+
LOG_DIR: pytest_logs
25+
collect_analytics: false
26+
27+
28+
steps:
29+
- uses: hmarr/[email protected]
30+
31+
- name: Extract branch name on direct push to a branch
32+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/')
33+
run: |
34+
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
35+
36+
- name: Extract branch name on 'pull_request_target'
37+
if: github.event_name == 'pull_request_target'
38+
run: |
39+
echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_ENV
40+
41+
- name: Checkout
42+
uses: actions/checkout@v3
43+
with:
44+
ref: "${{ env.BRANCH_NAME }}"
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v3
48+
with:
49+
python-version: '3.7'
50+
51+
- uses: actions/cache@v3
52+
name: Configure pip cache
53+
id: pip-cache
54+
with:
55+
path: ~/.cache/pip
56+
key: ${{ env.CACHE_NAME_PREFIX }}-${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-test.txt') }}
57+
restore-keys: |
58+
${{ env.CACHE_NAME_PREFIX }}-${{ runner.os }}-pip-
59+
60+
- name: Install dependencies
61+
run: |
62+
sudo apt-get clean
63+
sudo apt-get update
64+
sudo apt-get install virtualenv libsasl2-dev python-dev libldap2-dev libssl-dev
65+
pip install -U pip==20.2
66+
pip install -r deploy/requirements-test.txt
67+
pip install -r deploy/requirements.txt
68+
pip install -e .
69+
70+
- name: Check pytest version
71+
run: pytest --version
72+
73+
- name: Run general functional tests
74+
run: |
75+
cd label_studio_ml/
76+
pytest --cov=. --cov-report=xml --ignore lse_tests/cloud -n auto
77+
78+
- name: "Upload cloud coverage to Codecov"
79+
uses: codecov/[email protected]
80+
with:
81+
name: codecov
82+
files: ./label_studio_ml/coverage.xml
83+
token: ${{ secrets.CODECOV_TOKEN }}
84+
fail_ci_if_error: true

label_studio_ml/tests/__init__.py

Whitespace-only changes.

requirements-test.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest==6.2.2
2+
pytest-cov==2.9.0

0 commit comments

Comments
 (0)