-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (78 loc) · 2.6 KB
/
Copy pathci.yml
File metadata and controls
82 lines (78 loc) · 2.6 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
code-quality: write # for actions/upload-code-coverage (GitHub-native coverage API)
pull-requests: read # lets the action associate coverage with the PR on push events
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
with:
version: "0.11.15"
enable-cache: true
- name: Set up Python
run: uv python install
- name: Install dependencies
run: uv sync --locked --all-extras --dev
- name: Lint
id: lint
run: uv run ruff check --output-format=github .
- name: Format check
id: format
run: uv run ruff format --diff .
- name: Type check
id: typecheck
run: uv run pyrefly check --output-format=github
- name: Test
id: test
run: uv run pytest --cov --cov-report=xml --cov-report=term-missing
- name: Upload coverage to GitHub
uses: actions/upload-code-coverage@abb5995db9e0199b0e2bb9dbd136fce4cb1ec4d3 # v1.3.0
with:
file: coverage.xml
language: Python
label: code-coverage/pytest
fail-on-error: false # coverage upload is best-effort; don't gate the build on it
- name: Job summary
if: always()
continue-on-error: true
run: |
gate() { # $1 = label, $2 = step outcome
case "$2" in
success) echo "| $1 | ✅ pass |" ;;
failure) echo "| $1 | ❌ fail |" ;;
skipped) echo "| $1 | ⏭️ skipped |" ;;
*) echo "| $1 | ➖ $2 |" ;;
esac
}
{
echo "## CI summary"
echo ""
echo "| Gate | Result |"
echo "| --- | --- |"
gate "Lint (ruff check)" "${{ steps.lint.outcome }}"
gate "Format (ruff format)" "${{ steps.format.outcome }}"
gate "Type check (pyrefly)" "${{ steps.typecheck.outcome }}"
gate "Tests (pytest)" "${{ steps.test.outcome }}"
echo ""
if [ -f .coverage ]; then
echo "<details><summary>📊 Coverage: $(uv run coverage report --format=total)% total</summary>"
echo ""
uv run coverage report --format=markdown
echo ""
echo "</details>"
fi
} >> "$GITHUB_STEP_SUMMARY"