-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (92 loc) · 2.95 KB
/
python-publish.yml
File metadata and controls
114 lines (92 loc) · 2.95 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
name: Publish Python Package to TestPyPI
env:
# Define a constant for the Python version
PYTHON_VERSION: "3.13"
on:
# Trigger the workflow only for tags pushed to the 'master' branch
push:
tags:
- "v*"
jobs:
Format-validator:
# Use the latest Ubuntu runner for the job
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
# Step 3: Install dependencies (flake8)
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8==7.1.1
# Step 4: Check PEP8 compliance on all Python files in the repository
- name: Check PEP8 compliance
run: |
find . -name "*.py" | xargs flake8 --ignore=E203,W503
Test:
# Use the latest Ubuntu runner for the job
runs-on: ubuntu-latest
# Ensure this job runs after Format-validator passes
needs: Format-validator
steps:
# Step 1: Checkout the repository code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
# Step 3: Install dependencies for testing
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r project_settings/python/requirements-test.txt -r project_settings/python/requirements.txt
# Step 4: Run tests in parallel
- name: Run tests in parallel
run: |
pip install pytest-xdist
pytest -n auto
Publish:
# Use the latest Ubuntu runner for the job
runs-on: ubuntu-latest
# Ensure this job runs after Test passes
needs: Test
environment:
# Set the environment to 'testpypi'
name: testpypi
steps:
# Step 1: Checkout the repository code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
# Step 3: Install dependencies (pip, build, twine)
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
# Step 4: Build the Python package
- name: Build the package
run: |
python -m build
# Step 5: List the contents of the build directory (dist/)
- name: List build directory contents
run: |
ls -lh dist/
# Step 6: Upload the package to TestPyPI
- name: Publish to TestPyPI
env:
TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }}
run: |
twine upload --repository-url https://test.pypi.org/legacy/ dist/* --verbose