-
Notifications
You must be signed in to change notification settings - Fork 1.2k
141 lines (134 loc) · 4.91 KB
/
Copy pathgithub-actions.yml
File metadata and controls
141 lines (134 loc) · 4.91 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
name: MongoengineCI
on:
# All PRs
pull_request:
# All branch pushes (runs linting, tests, doc build on every push)
push:
# Manual trigger from Action page
workflow_dispatch:
# release tags
create:
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+*'
# Cancel in-progress runs when a new workflow run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
MAIN_PYTHON_VERSION: "3.14"
jobs:
linting:
# Run pre-commit (https://pre-commit.com/)
# which runs pre-configured linter & autoformatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v8.1.0
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Install Dependencies for lint
run: uv sync --only-group dev
- name: Run pre-commit
run: uv run pre-commit run -a
test:
# Test suite runs against recent python versions
# and against a few combinations of MongoDB and pymongo
name: "test (Python ${{ matrix.python-version }}, MongoDB ${{ matrix.mongodb-version }}, PyMongo ${{ matrix.pymongo-version }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
mongodb-version: [ "4.4", "5.0", "6.0", "7.0", "8.0", "8.3" ]
pymongo-version: [ "4.14", "4.15", "4.16", "4.17" ]
steps:
- uses: actions/checkout@v6
- name: Install uv and set the Python version ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v8.1.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.12.1
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: mongoengine
- name: Cache tox environments
uses: actions/cache@v4
with:
path: .tox
key: tox-${{ matrix.python-version }}-mg${{ matrix.pymongo-version }}-${{ hashFiles('pyproject.toml', 'tox.ini') }}
restore-keys: |
tox-${{ matrix.python-version }}-mg${{ matrix.pymongo-version }}-
- name: Install Dependencies
run: uv sync --only-group test
- name: Run test suite
run: |
env="py$(echo "${{ matrix.python-version }}" | tr -d . )-mg$(echo "${{ matrix.pymongo-version }}" | tr -d . )"
echo "Running tox environment: $env"
uv run tox run -e "$env" -- "--cov=mongoengine --cov-report="
uv run coverage combine
uv run coverage report
# - name: Send coverage to Coveralls
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# COVERALLS_SERVICE_NAME: GitHub
# run: uv run coveralls
build_doc_dryrun:
# ensures that readthedocs can be built continuously
# to avoid that it breaks when new releases are being created
# The way RTD works is that it builds the doc on its side
# builds are visible at https://readthedocs.org/projects/mongoengine-odm/builds/
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv and set the Python version ${{ env.MAIN_PYTHON_VERSION }}
uses: astral-sh/setup-uv@v8.1.0
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Install python dependencies
run: uv sync --only-group docs
- name: Build documentation
run: |
cd docs
make html-readthedocs
build-release:
runs-on: ubuntu-latest
needs: [ linting, test, build_doc_dryrun ]
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v6
- name: Install uv and set the Python version ${{ env.MAIN_PYTHON_VERSION }}
uses: astral-sh/setup-uv@v8.1.0
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Build wheel and sdist for release
run: uv build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
runs-on: ubuntu-latest
needs: [ build-release ]
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write # Required for trusted publishing
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.pypi_token }}