Repository navigation
155 lines (146 loc) · 5.72 KB
/
Copy pathci.yml
File metadata and controls
155 lines (146 loc) · 5.72 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
146
147
148
149
150
151
152
153
154
155
name: ci
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
checks:
name: checks (pre-commit)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
python-version: "3.12"
- run: uv sync --locked
# The same hooks a commit runs locally; pytest runs in its own job.
- run: uv run pre-commit run --all-files --show-diff-on-failure
env:
SKIP: pytest
tests:
name: tests (py${{ matrix.python }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Every supported Python on Linux, plus macOS once: this repo is
# private, and macOS minutes count ten times against the free quota.
os: [ubuntu-latest]
python: ["3.11", "3.12", "3.13"]
include:
- os: macos-latest
python: "3.12"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
python-version: ${{ matrix.python }}
- run: uv sync --locked
- name: Run tests
if: matrix.os != 'ubuntu-latest' || matrix.python != '3.12'
run: uv run pytest
- name: Run tests with coverage
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
run: uv run pytest --cov=kdev --cov-report=term-missing --cov-report=markdown:coverage.md
- name: Add coverage summary
if: ${{ always() && matrix.os == 'ubuntu-latest' && matrix.python == '3.12' }}
shell: bash
run: |
if [ -f coverage.md ]; then
{
echo "## Test coverage"
echo
cat coverage.md
} >> "$GITHUB_STEP_SUMMARY"
fi
lowest:
name: tests (lowest direct dependencies, py3.11)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
python-version: "3.11"
# Resolves every dependency kdev names to the lowest version pyproject.toml
# allows, on the oldest supported Python, without touching uv.lock. If this
# fails, a floor in pyproject.toml is lower than kdev really works with.
- run: uv run --isolated --resolution lowest-direct pytest
package:
name: package builds and installs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
python-version: "3.12"
- run: uv build
- run: uvx twine check --strict dist/*
- name: Installs cleanly and runs
run: |
uv tool install dist/*.whl
# The version comes from the installed distribution's metadata; a
# wrong distribution name silently falls back to 0.0.0+source.
want="kdev $(uv run --no-project python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")"
test "$(kdev --version)" = "$want" || { echo "::error::kdev --version says '$(kdev --version)', want '$want'"; exit 1; }
kdev --help > /dev/null
python - <<'PY'
import zipfile, glob
names = zipfile.ZipFile(glob.glob("dist/*.whl")[0]).namelist()
# Shipped into every Kaggle session: the package is useless without it.
assert "kdev/kdev_box.py" in names, names
PY
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist/
secrets:
name: no secrets in history
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
# The gitleaks CLI, not gitleaks-action, which needs a licence key in a
# repository owned by an organization. Bump the version and checksum
# together; the checksum is in the release's checksums file.
- name: gitleaks over every commit
env:
GITLEAKS_VERSION: 8.30.1
GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb # pragma: allowlist secret
run: |
tarball="$RUNNER_TEMP/gitleaks.tar.gz"
curl -fsSL -o "$tarball" "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
echo "${GITLEAKS_SHA256} ${tarball}" | sha256sum -c -
tar -xzf "$tarball" -C "$RUNNER_TEMP" gitleaks
"$RUNNER_TEMP/gitleaks" git --redact --no-banner --verbose .
# One check for branch protection to require: the job names above change with
# the test matrix, this one does not.
ci-passed:
name: CI passed
if: ${{ always() }}
needs: [checks, tests, lowest, package, secrets]
runs-on: ubuntu-latest
steps:
- name: Require every job to succeed
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
run: |
echo "Job results: $RESULTS"
for result in $RESULTS; do
if [ "$result" != "success" ]; then exit 1; fi
done