forked from jamielinux/pyright-polite
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (125 loc) · 4.11 KB
/
ci.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: CI
on:
push:
branches:
- 'main'
paths-ignore:
- '.changelog.d/**'
- '.github/workflows/*'
- '*.md'
- 'LICENSE'
- 'hatch.toml'
- 'pyproject.toml'
- 'src/*/__about__.py'
workflow_dispatch:
defaults:
run:
shell: bash
concurrency:
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1
permissions:
contents: read
jobs:
test:
name: 'Test with python ${{ matrix.python-version }} on ${{ matrix.os }}'
timeout-minutes: 20
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy3.7', 'pypy3.8', 'pypy3.9']
include:
- os: macos-latest
python-version: '3.7'
- os: macos-latest
python-version: '3.11'
- os: windows-latest
python-version: '3.7'
- os: windows-latest
python-version: '3.11'
steps:
- name: 'Checkout'
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: 'Install python'
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
with:
python-version: ${{ matrix.python-version }}
- name: 'Install hatch'
run: |
python -m pip install --upgrade hatch
- name: 'Install node'
if: matrix.os == 'ubuntu-latest'
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: '18.15.0'
cache: 'npm'
- name: 'Install pyright'
if: matrix.os == 'ubuntu-latest'
run: |
npm ci
echo "node_modules/.bin" >> $GITHUB_PATH
- name: 'Run tests'
run: >
hatch run +py=${{ matrix.python-version }} ci:cov
--data-file '.coverage.${{ matrix.os }}.${{ matrix.python-version }}'
- name: 'Upload coverage'
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: coverage
path: '.coverage.*'
if-no-files-found: error
retention-days: 30
covbadge:
if: github.repository == 'jamielinux/pyright-polite' && github.ref == 'refs/heads/main'
name: 'Code coverage badge'
timeout-minutes: 20
runs-on: ubuntu-latest
needs: [test]
steps:
- name: 'Harden Runner'
uses: step-security/harden-runner@03bee3930647ebbf994244c21ddbc0d4933aab4f # v2.3.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
files.pythonhosted.org:443
github.com:443
pypi.org:443
- name: 'Checkout'
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: 'Install python'
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
with:
python-version: '3.11'
- name: 'Install hatch'
run: |
python -m pip install --upgrade hatch
- name: 'Download coverage'
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: coverage
- name: 'Combine coverage'
run: |
hatch run +py=3.11 ci:cov-combine
export TOTAL=$(python -c \
"import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: 'Coverage badge'
uses: schneegans/dynamic-badges-action@5d424ad4060f866e4d1dab8f8da0456e6b1c4f56 # v1.6.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: ed2d4df7c2b137ac89778db60ef8894f
filename: pyright-polite.covbadge.json
label: coverage
message: ${{ env.total }}%
minColorRange: 70
maxColorRange: 90
valColorRange: ${{ env.total }}