-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (123 loc) · 4.39 KB
/
python-publish.yml
File metadata and controls
145 lines (123 loc) · 4.39 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
142
143
144
145
# This workflow will upload a Python Package to PyPI when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
#
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
# Trigger on workflow dispatch (manual trigger), pushes to main, PRs, or when a release is published
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
release:
types: [published]
permissions:
contents: read
jobs:
release-build:
runs-on: ubuntu-latest
# Only run on releases, not on regular pushes/PRs
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Sync version to sonar-project.properties
run: |
# Ensure version is synced before building
python scripts/update_version.py
- name: Build release distributions
run: |
# Build the hyperway package
python -m pip install build
python -m build
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
pypi-publish:
runs-on: ubuntu-latest
# Only run on releases, not on regular pushes/PRs
if: github.event_name == 'release'
needs:
- release-build
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
# Dedicated environments with protections for publishing are strongly recommended.
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
environment:
name: pypi
# PyPI project URL for hyperway
url: https://pypi.org/p/hyperway
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
sonarcloud:
name: SonarCloud Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for better analysis
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Sync version to sonar-project.properties
run: |
# Ensure version is synced before SonarCloud analysis
python scripts/update_version.py
- name: Install Graphviz
run: |
wget https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/14.0.1/ubuntu_25.04_graphviz-14.0.1-cmake.deb -O /tmp/graphviz-14.0.1.deb
sudo dpkg -i /tmp/graphviz-14.0.1.deb
dot -V
- name: Install tox and dependencies
run: |
python -m pip install --upgrade pip
pip install tox graphviz
- name: Run tests and generate coverage
run: tox -e py312
- name: Debug - Check coverage file paths
run: |
echo "=== Checking coverage.xml paths ==="
if [ -f coverage.xml ]; then
echo "Coverage file exists"
echo "Source path in coverage.xml:"
grep -A 1 "<sources>" coverage.xml
echo ""
echo "Sample file paths (first 5):"
grep -o 'filename="[^"]*"' coverage.xml | head -5
echo ""
echo "Actual source files in src/:"
ls -la src/hyperway/*.py | head -3
else
echo "ERROR: coverage.xml not found!"
exit 1
fi
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectKey=Strangemother_python-hyperway
-Dsonar.organization=strangemother