-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (106 loc) · 4.34 KB
/
Copy pathci.yml
File metadata and controls
126 lines (106 loc) · 4.34 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
name: CI
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
# Lets the release workflow run this exact gate (lint + test matrix +
# package) before publishing, instead of duplicating it. workflow_call adds
# no automatic runs of its own.
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Least privilege: nothing here needs to write to the repo. Declaring this at
# the workflow level also overrides a permissive repo/org default.
permissions:
contents: read
env:
# Assert uv.lock is up to date with pyproject.toml and install exactly what
# it pins, rather than silently resolving something different from what
# developers run locally. (UV_LOCKED, not UV_FROZEN: --frozen skips
# re-locking without checking, --locked fails when the lock is stale.)
UV_LOCKED: "1"
jobs:
lint:
name: Lint and type-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Don't leave GITHUB_TOKEN in .git/config for later steps to reach.
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras --dev
- name: ruff check
run: uv run ruff check .
- name: ruff format --check
run: uv run ruff format --check .
- name: mypy
run: uv run mypy src/myinvois
# Pyright is what Pylance runs in the editor, and it catches things mypy
# does not: it found a module-level `del` that would have raised
# NameError at import time if a constant tuple were ever emptied, while
# mypy was green. Scope comes from pyrightconfig.json (src, tests,
# scripts) so CI and the IDE cannot drift apart.
#
# The version is pinned through uv.lock, deliberately: Pyright ships new
# checks frequently, and an unpinned upgrade would fail unrelated PRs
# with findings nobody introduced.
- name: pyright
run: uv run pyright
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Don't leave GITHUB_TOKEN in .git/config for later steps to reach.
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --all-extras --dev
# Live tests need real MyInvois sandbox credentials, so they are
# deselected here. They skip on their own if MYINVOIS_CLIENT_ID is
# unset, but deselecting keeps the CI summary honest about what ran.
- name: pytest
run: uv run pytest -m "not live"
package:
name: Build and verify distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Don't leave GITHUB_TOKEN in .git/config for later steps to reach.
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
- name: Build sdist and wheel
run: uv build
# Guards two things that are easy to break and painful to un-publish:
# 1. The PEP 561 marker and the JSON code tables must ship, or
# `from myinvois.codes import ...` fails at runtime in a wheel
# install and type-checkers ignore the package.
# 2. The test signing key/cert must NEVER ship. They are force-tracked
# in git for the byte-parity tests (see tests/fixtures/cert/README.md)
# which makes an accidental include plausible.
- name: Verify distribution contents
run: uv run --no-project python scripts/check_dist.py
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: distributions
path: dist/