-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (118 loc) · 3.74 KB
/
coverage.yml
File metadata and controls
137 lines (118 loc) · 3.74 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
name: coverage
on:
workflow_dispatch:
push:
tags:
- 'v*.*.*'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
fail-fast: false
steps:
- uses: actions/checkout@v5
- name: Set up Python
id: setup-python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
id: cache
with:
path: .venv
key: ${{ runner.os }}-python-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }}-ci
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv pip install -U pip
uv pip install -e .[all]
uv pip install -U "coverage[toml]" pytest freezegun pytest-asyncio
- name: Use Python virtual environment
run: |
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV
# NOTE: I set OS level for timezone because I have schedule object
# testcase.
# TODO: I should seeing this is necessary task on GitHub action, right?
# Because it does not depend on OS level when you pass tz to schedule
# object or not, and it will use UTC for default.
- uses: MathRobin/timezone-action@v1.1
with:
timezoneLinux: "Asia/Bangkok"
- name: Run coverage and produce a .coverage file
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
run: |
mkdir coverage
echo $COVERAGE_FILE
coverage run -m pytest --disable-pytest-warnings
ls -al ./coverage
- name: Store coverage file
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: coverage
include-hidden-files: true
coverage:
name: coverage
needs: [build]
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.9'
- name: Get coverage files
uses: actions/download-artifact@v5
id: download
with:
pattern: coverage-*
path: coverage
merge-multiple: true
- name: Install Python Dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv pip install -U pip
uv pip install -U "coverage[toml]" pytest
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV
- name: Run coverage
run: |
ls -al coverage
coverage combine coverage
coverage report --show-missing
coverage html --show-contexts --title "Coverage for ${{ github.sha }}"
ls -al
- run: |
coverage xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Store coverage HTML
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov
check:
if: always()
needs:
- build
- coverage
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}