-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (122 loc) · 3.9 KB
/
ci.yml
File metadata and controls
145 lines (122 loc) · 3.9 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
138
139
140
141
142
143
144
145
name: CI
on:
push:
branches:
- "**"
pull_request:
branches: [main, dev]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Ruff check
run: ruff check .
- name: Ruff format
run: ruff format --check .
- name: Vulture
run: vulture
- name: Xenon
run: xenon --max-absolute=A --max-modules=A --max-average=A yt_framework ytjobs
- name: Pre-commit policy (max file lines)
run: python scripts/precommit/run.py
- name: Tach
run: tach check
- name: Tach external
run: tach check-external
typecheck:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: BasedPyright
run: |
basedpyright --pythonpath "$(python -c 'import sys; print(sys.executable)')"
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run tests
run: |
pytest \
-m "not yt_cluster" \
--cov=yt_framework \
--cov=ytjobs \
--cov-report=term-missing \
--cov-report=json:coverage.json
- name: Require 100% statement coverage (yt_framework + ytjobs)
run: python scripts/coverage/check_line_coverage.py coverage.json
- name: Publish coverage badge to gist
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && vars.COVERAGE_GIST_ID != ''
env:
COVERAGE_GIST_ID: ${{ vars.COVERAGE_GIST_ID }}
COVERAGE_GIST_TOKEN: ${{ secrets.COVERAGE_GIST_TOKEN }}
run: |
python <<'PY'
import json
import os
import urllib.error
import urllib.request
with open("coverage.json", encoding="utf-8") as f:
cov = json.load(f)
pct = round(float(cov["totals"]["percent_covered"]), 1)
if pct >= 80.0:
color = "brightgreen"
elif pct >= 60.0:
color = "yellow"
else:
color = "red"
payload = {
"schemaVersion": 1,
"label": "coverage",
"message": f"{pct}%",
"color": color,
}
body = json.dumps(
{"files": {"yt-framework-coverage.json": {"content": json.dumps(payload)}}}
)
req = urllib.request.Request(
f"https://api.github.com/gists/{os.environ['COVERAGE_GIST_ID']}",
data=body.encode(),
method="PATCH",
headers={
"Authorization": f"Bearer {os.environ['COVERAGE_GIST_TOKEN']}",
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
)
try:
with urllib.request.urlopen(req) as resp:
assert 200 <= resp.status < 300, resp.status
except urllib.error.HTTPError as e:
raise SystemExit(f"gist PATCH failed: HTTP {e.code}") from e
PY