Skip to content

Commit 4e3aeb8

Browse files
committed
Add .github for PyPI releases
1 parent ee088f8 commit 4e3aeb8

File tree

4 files changed

+254
-0
lines changed

4 files changed

+254
-0
lines changed

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
# GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
groups:
9+
actions:
10+
patterns:
11+
- "*"
12+
# Python
13+
- package-ecosystem: "pip"
14+
directory: "/"
15+
schedule:
16+
interval: "weekly"
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Python Wheels
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
tags:
7+
- "**"
8+
pull_request:
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: wheels-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
defaults:
16+
run:
17+
shell: bash -eux {0}
18+
19+
jobs:
20+
21+
build_dist:
22+
name: Build Distribution Files
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
persist-credentials: false
29+
30+
- uses: actions/setup-python@v5
31+
with:
32+
# Build sdist on lowest supported Python
33+
python-version: '3.9'
34+
35+
- name: Install build
36+
run: |
37+
python -m pip install build
38+
39+
- name: build the dist files
40+
run: |
41+
python -m build .
42+
43+
- name: Upload the dist files
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: dist-${{ github.run_id }}
47+
path: ./dist/*.*
48+
49+
test_dist:
50+
needs: [build_dist]
51+
name: Test Distribution Files
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
with:
56+
fetch-depth: 0
57+
persist-credentials: false
58+
59+
- uses: actions/setup-python@v5
60+
with:
61+
# Build sdist on lowest supported Python
62+
python-version: '3.9'
63+
64+
- name: Download the dists
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: dist-${{ github.run_id }}
68+
path: dist/
69+
70+
- name: Test the sdist
71+
run: |
72+
cd dist
73+
pip install *.tar.gz
74+
python -c "import django_mongodb_extensions"
75+
pip uninstall -y django-mongodb-extensions
76+
77+
- name: Test the wheel
78+
run: |
79+
cd dist
80+
pip install *.whl
81+
python -c "import django_mongodb_extensions"
82+
pip uninstall -y django-mongodb-extensions
83+
84+
publish:
85+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#publishing-the-distribution-to-pypi
86+
needs: [test_dist]
87+
if: startsWith(github.ref, 'refs/tags/')
88+
runs-on: ubuntu-latest
89+
environment: release
90+
permissions:
91+
id-token: write
92+
steps:
93+
- name: Download the dists
94+
uses: actions/download-artifact@v4
95+
with:
96+
name: dist-${{ github.run_id }}
97+
path: dist/
98+
- name: Publish distribution 📦 to PyPI
99+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test-python.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Python Tests
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
8+
concurrency:
9+
group: tests-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
defaults:
13+
run:
14+
shell: bash -eux {0}
15+
16+
env:
17+
MIN_PYTHON: "3.9"
18+
MIN_MONGODB: "4.0"
19+
MAX_MONGODB: "8.0"
20+
21+
jobs:
22+
static:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
persist-credentials: false
28+
fetch-depth: 0
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v5
31+
with:
32+
enable-cache: true
33+
python-version: ${{ matrix.python-version }}
34+
- uses: extractions/setup-just@v3
35+
- run: just install
36+
- run: just lint
37+
- run: just docs
38+
- run: just doctest
39+
build:
40+
runs-on: ${{ matrix.os }}
41+
strategy:
42+
matrix:
43+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
44+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
45+
fail-fast: false
46+
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
persist-credentials: false
51+
fetch-depth: 0
52+
- name: Install uv
53+
uses: astral-sh/setup-uv@v5
54+
with:
55+
enable-cache: true
56+
python-version: ${{ matrix.python-version }}
57+
- uses: extractions/setup-just@v3
58+
- name: Start MongoDB on Linux
59+
if: ${{ startsWith(runner.os, 'Linux') }}
60+
uses: supercharge/[email protected]
61+
with:
62+
mongodb-version: ${{ env.MAX_MONGODB }}
63+
mongodb-replica-set: test-rs
64+
- name: Start MongoDB on MacOS
65+
if: ${{ startsWith(runner.os, 'macOS') }}
66+
run: |
67+
brew tap mongodb/brew
68+
brew install mongodb/brew/mongodb-community@${MAX_MONGODB}
69+
brew services start mongodb-community@${MAX_MONGODB}
70+
- name: Start MongoDB on Windows
71+
if: ${{ startsWith(runner.os, 'Windows') }}
72+
shell: powershell
73+
run: |
74+
mkdir data
75+
mongod --remove
76+
mongod --install --dbpath=$(pwd)/data --logpath=$PWD/mongo.log
77+
net start MongoDB
78+
- run: just install
79+
- run: just test
80+
81+
build-min:
82+
runs-on: ubuntu-latest
83+
steps:
84+
- uses: actions/checkout@v4
85+
with:
86+
persist-credentials: false
87+
fetch-depth: 0
88+
- name: Install uv
89+
uses: astral-sh/setup-uv@v5
90+
with:
91+
enable-cache: true
92+
python-version: ${{ env.MIN_PYTHON }}
93+
- uses: extractions/setup-just@v3
94+
- name: Install uv
95+
uses: astral-sh/setup-uv@v5
96+
with:
97+
enable-cache: true
98+
python-version: ${{ env.MIN_PYTHON }}
99+
- uses: extractions/setup-just@v3
100+
- uses: supercharge/[email protected]
101+
with:
102+
mongodb-version: ${{ env.MIN_MONGODB }}
103+
mongodb-replica-set: test-rs
104+
- name: Run unit tests with minimum dependency versions
105+
run: |
106+
uv sync --python=${MIN_PYTHON} --resolution=lowest-direct
107+
just test

.github/workflows/zizmor.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: GitHub Actions Security Analysis with zizmor
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
zizmor:
11+
name: zizmor latest via Cargo
12+
runs-on: ubuntu-latest
13+
permissions:
14+
security-events: write
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
persist-credentials: false
20+
- name: Setup Rust
21+
uses: actions-rust-lang/setup-rust-toolchain@v1
22+
- name: Get zizmor
23+
run: cargo install zizmor
24+
- name: Run zizmor
25+
run: zizmor --format sarif . > results.sarif
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
- name: Upload SARIF file
29+
uses: github/codeql-action/upload-sarif@v3
30+
with:
31+
sarif_file: results.sarif
32+
category: zizmor

0 commit comments

Comments
 (0)