Skip to content

Commit 98ec649

Browse files
Enhance Python package workflow for new Python version
Updated Python CI workflow to support Python 3.12, added build step, and improved dependency installation.
1 parent d65a0e7 commit 98ec649

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Python package
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
release:
9+
types: [published]
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
python-version: ["3.10", "3.11", "3.12"]
22+
23+
steps:
24+
- name: Check out repository
25+
uses: actions/checkout@v5
26+
27+
- name: Set up Python ${{ matrix.python-version }}
28+
uses: actions/setup-python@v6
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
cache: pip
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
python -m pip install build flake8 pytest
37+
python -m pip install .
38+
39+
- name: Lint with flake8
40+
run: |
41+
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
42+
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
43+
44+
- name: Test with pytest
45+
run: |
46+
if [ -d tests ]; then
47+
pytest -q
48+
else
49+
echo "No tests directory found, skipping pytest."
50+
fi
51+
52+
- name: Build package
53+
run: python -m build
54+
55+
publish:
56+
if: github.event_name == 'release'
57+
needs: test
58+
runs-on: ubuntu-latest
59+
environment:
60+
name: pypi
61+
url: https://pypi.org/p/rlearner
62+
permissions:
63+
contents: read
64+
id-token: write
65+
66+
steps:
67+
- name: Check out repository
68+
uses: actions/checkout@v5
69+
70+
- name: Set up Python 3.12
71+
uses: actions/setup-python@v6
72+
with:
73+
python-version: "3.12"
74+
cache: pip
75+
76+
- name: Install build tools
77+
run: |
78+
python -m pip install --upgrade pip
79+
python -m pip install build twine
80+
81+
- name: Build distribution
82+
run: python -m build
83+
84+
- name: Check distribution
85+
run: twine check dist/*
86+
87+
- name: Publish to PyPI
88+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)