Repository navigation
151 lines (132 loc) · 4.53 KB
/
Copy pathtests.yml
File metadata and controls
151 lines (132 loc) · 4.53 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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: continuous-integration
on:
push:
branches: [master]
tags:
- 'v*'
pull_request:
permissions:
contents: read
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: pre-commit/action@v3.0.1
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['pypy-3.10', '3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[testing]
- name: Run pytest
run: |
pytest --cov=mdit_py_plugins --cov-report=xml --cov-report=term-missing
- name: Upload to Codecov
uses: codecov/codecov-action@v5
if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: mdit-py-plugins-pytests
flags: pytests
files: ./coverage.xml
# coverage is informational: an upload failure must not fail CI
fail_ci_if_error: false
tests-floor:
# the oldest markdown-it-py the package declares (`markdown-it-py>=3.0.0`):
# the plugins that need 4.1 skip their tests and check their version guard
name: tests (3.10, markdown-it-py 3.0.0)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[testing] markdown-it-py==3.0.0
- name: Check the installed markdown-it-py
run: python -c "import markdown_it; assert markdown_it.__version__ == '3.0.0', markdown_it.__version__"
- name: Run pytest
run: pytest
build:
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-python@v7
with:
python-version: "3.13"
# `python -m build` builds with the project's own [build-system] pin,
# so the release build cannot drift from it
# (`pip install flit~=3.4` resolves flit 3.12 + flit_core 4.2, and `flit build` crashes)
- run: python -m pip install build twine
- run: python -m build
- run: python -m twine check --strict dist/*
- name: Check the tag matches the built version
if: startsWith(github.ref, 'refs/tags/v')
run: |
python - <<'EOF'
import os, pathlib, sys
tag = os.environ["GITHUB_REF_NAME"].removeprefix("v")
wheels = list(pathlib.Path("dist").glob("*.whl"))
sdists = list(pathlib.Path("dist").glob("*.tar.gz"))
if len(wheels) != 1 or len(sdists) != 1:
sys.exit(f"expected one wheel and one sdist, got {len(wheels)} and {len(sdists)}")
versions = {p.name.removesuffix(".tar.gz").split("-")[1] for p in wheels + sdists}
if versions != {tag}:
sys.exit(f"tag v{tag} != built version(s) {sorted(versions)}")
print(f"tag v{tag} matches the built version")
EOF
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
retention-days: 7
allgood:
runs-on: ubuntu-latest
needs:
- pre-commit
- tests
- tests-floor
- build
steps:
- run: echo "Great success!"
publish:
name: Publish to PyPI
needs: [pre-commit, tests, tests-floor, build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
id-token: write # the only permission this job has (trusted publishing)
environment:
name: pypi
url: https://pypi.org/p/mdit-py-plugins
steps:
# publish exactly the distributions the `build` job built and checked
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
# attestations are generated and uploaded by default
- uses: pypa/gh-action-pypi-publish@release/v1