-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (48 loc) · 1.47 KB
/
python-app-test.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
# This workflow will install Python dependencies, run tests and
# lint with a single version of Python
# For more information see:
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
pull_request:
permissions:
contents: read
jobs:
check-tests:
runs-on: ubuntu-latest
outputs:
tests_exist: ${{ steps.check.outputs.tests_exist }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check for test files
id: check
run: |
if find . -type f -name "*.test.py" | grep -q .; then
echo "::set-output name=tests_exist::true"
else
echo "::set-output name=tests_exist::false"
fi
run-tests:
runs-on: ubuntu-latest
needs: check-tests
if: needs.check-tests.outputs.tests_exist == 'true'
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}