-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (79 loc) · 3.32 KB
/
test_coverage.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
name: test_coverage
permissions:
pull-requests: write
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build_test_linux:
name: ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.11" ]
permissions:
issues: write
pull-requests: write
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup py-${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Caching improves build time, we use pythonLocation to cache everything including wheels to avoid building
# wheels at each build (pandas/Pypy is extremely time consuming)
# sed replacement is performed to rectify PyPy path which ends with /bin
# cache key takes into account the Python version of the runner to avoid version mismatch on updates.
- name: Get pip cache path
id: get-pip-path
run: |
id=$(echo ${{ env.pythonLocation }} | sed 's/\/bin//g')
echo "name=id::$id" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v3
id: pip-cache
with:
path: ${{ steps.get-pip-path.outputs.id }}
key: ${{ steps.get-pip-path.outputs.id }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements/requirements.dev.txt') }}-${{ hashFiles('requirements/requirements.logcollector.txt') }}-${{ hashFiles('requirements/requirements.detector.txt') }}-${{ hashFiles('requirements/requirements.prefilter.txt') }}-${{ hashFiles('requirements/requirements.inspector.txt') }}-${{ hashFiles('requirements/requirements.logserver.txt') }}
- name: Install requirements
if: steps.pip-cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements/requirements.dev.txt -r requirements/requirements.detector.txt -r requirements/requirements.logcollector.txt -r requirements/requirements.prefilter.txt -r requirements/requirements.inspector.txt -r requirements/requirements.logserver.txt
- name: Test
run: |
python -m coverage run -m unittest
python -m coverage xml
- name: Get Coverage
uses: orgoro/coverage@v3.2
with:
coverageFile: ./coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
- name: Coverage Badge
uses: tj-actions/coverage-badge-py@v2.0.3
with:
output: 'assets/coverage_${{ env.BRANCH_NAME }}.svg'
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v20.0.1
id: verify-changed-files
with:
files: 'assets/coverage_${{ env.BRANCH_NAME }}.svg'
- name: Upload file
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
pip install requests beautifulsoup4
python assets/upload_seafile.py -l ${{ secrets.SEAFILE_UPLOAD }} -f assets/coverage_${{ env.BRANCH_NAME }}.svg
- name: Upload results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}