-
Notifications
You must be signed in to change notification settings - Fork 7
79 lines (63 loc) · 2.08 KB
/
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
name: Coverage
on:
push:
branches:
- main
pull_request: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true
jobs:
coverage:
runs-on: ubuntu-latest
# Not intended for forks.
if: github.repository == 'optuna/optunahub'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Setup cache
uses: actions/cache@v3
env:
cache-name: coverage
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pyproject.toml') }}-v1
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pyproject.toml') }}
- name: Install
run: |
python -m pip install --upgrade pip
# Install minimal dependencies and confirm that `import optunahub` is successful.
pip install --progress-bar off .
python -c 'import optunahub'
pip install --progress-bar off .[test]
echo 'import coverage; coverage.process_startup()' > sitecustomize.py
- name: Output installed packages
run: |
pip freeze --all
- name: Output dependency tree
run: |
pip install pipdeptree
pipdeptree
- name: Tests
env:
OMP_NUM_THREADS: 1
PYTHONPATH: . # To invoke sitecutomize.py
COVERAGE_PROCESS_START: .coveragerc # https://coverage.readthedocs.io/en/6.4.1/subprocess.html
COVERAGE_COVERAGE: yes # https://github.com/nedbat/coveragepy/blob/65bf33fc03209ffb01bbbc0d900017614645ee7a/coverage/control.py#L255-L261
OPTUNAHUB_NO_ANALYTICS: 1
run: |
coverage run --source=optunahub -m pytest tests
coverage combine
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./coverage.xml
fail_ci_if_error: true