-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (72 loc) · 2 KB
/
python-package.yml
File metadata and controls
88 lines (72 loc) · 2 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
name: Python package
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build flake8 pytest
python -m pip install .
- name: Lint with flake8
run: |
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
if [ -d tests ]; then
pytest -q
else
echo "No tests directory found, skipping pytest."
fi
- name: Build package
run: python -m build
publish:
if: github.event_name == 'release'
needs: test
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/rlearner
permissions:
contents: read
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- name: Install build tools
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build distribution
run: python -m build
- name: Check distribution
run: twine check dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1