FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-codext/.github/workflows/python-package.yml at main · dhondta/python-codext · GitHub
dhondta
/
python-codext
Public
Notifications
You must be signed in to change notification settings
Fork
28
Star
300
Code
Issues
2
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-codext
/
.github
/
workflows
/
python-package.yml
Copy path
View runs
More file actions
More file actions
Latest commit
History
History
History
128 lines (124 loc) · 4.3 KB
Breadcrumbs
python-codext
/
.github
/
workflows
/
python-package.yml
Copy path
File metadata and controls
128 lines (124 loc) · 4.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
This workflow will install Python dependencies, run tests and lint with a variety of Python versions
#
For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name
:
build
on
:
push
:
branches
:
[ "main" ]
pull_request
:
branches
:
[ "main" ]
permissions
:
id-token
:
write
contents
:
read
jobs
:
prepare
:
runs-on
:
ubuntu-latest
outputs
:
package
:
${{ steps.pkg.outputs.package }}
pypi_url
:
${{ steps.pkg.outputs.pypi_url }}
steps
:
-
name
:
Compute package name from the repository's
id
:
pkg
run
:
|
name="${GITHUB_REPOSITORY##*/}"
echo "package=${name#python-}" >> $GITHUB_OUTPUT
echo "pypi_url=https://pypi.org/p/${name#python-}" >> $GITHUB_OUTPUT
build
:
needs
:
prepare
runs-on
:
${{ matrix.os }}
strategy
:
fail-fast
:
false
matrix
:
os
:
[ubuntu-latest]
python-version
:
["3.9", "3.10", "3.11", "3.12", "3.13"]
env
:
package
:
${{ needs.prepare.outputs.package }}
steps
:
-
uses
:
actions/checkout@v5
-
name
:
Set up Python ${{ matrix.python-version }}
uses
:
actions/setup-python@v6
with
:
python-version
:
${{ matrix.python-version }}
-
name
:
Install ${{ env.package }}
run
:
|
python -m pip install --upgrade pip
python -m pip install pytest pytest-cov coverage
pip install -r requirements.txt
pip install tinyscript>=1.31
pip install .
-
name
:
Test ${{ env.package }} with pytest
run
:
|
pytest --cov=$package
coverage
:
needs
:
[prepare, build]
permissions
:
contents
:
write
runs-on
:
ubuntu-latest
env
:
cov_badge_path
:
docs/coverage.svg
package
:
${{ needs.prepare.outputs.package }}
python_version
:
"
3.13
"
steps
:
-
uses
:
actions/checkout@v5
with
:
fetch-depth
:
0
ref
:
${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.head.sha || github.sha }}
-
name
:
Set up Python ${{ env.python_version }}
uses
:
actions/setup-python@v6
with
:
python-version
:
${{ env.python_version }}
-
name
:
Install ${{ env.package }}
run
:
|
python -m pip install --upgrade pip
python -m pip install pytest pytest-cov
pip install -r requirements.txt
pip install .
-
name
:
Make coverage badge for ${{ env.package }}
run
:
|
pip install genbadge[coverage]
pytest --cov=$package --cov-report=xml
genbadge coverage -i coverage.xml -o $cov_badge_path
-
name
:
Verify Changed files
uses
:
tj-actions/verify-changed-files@v20
id
:
changed_files
with
:
files
:
${{ env.cov_badge_path }}
-
name
:
Push coverage badge
if
:
steps.changed_files.outputs.files_changed == 'true'
run
:
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git fetch origin
git checkout coverage-badge || git checkout -b coverage-badge
git add $cov_badge_path
git diff --cached --quiet && exit 0
git commit -m "Update coverage badge"
git push origin coverage-badge --force
deploy
:
environment
:
name
:
pypi
url
:
${{ needs.prepare.outputs.pypi_url }}
runs-on
:
ubuntu-latest
needs
:
[prepare, coverage]
steps
:
-
uses
:
actions/checkout@v5
with
:
fetch-depth
:
0
-
name
:
Check for version change
uses
:
dorny/paths-filter@v4
id
:
filter
with
:
filters
:
|
version:
- '**/VERSION.txt'
-
if
:
steps.filter.outputs.version == 'true'
name
:
Cleanup README
run
:
|
sed -ri 's/^(##*)\s*:.*:\s*/\1 /g' README.md
awk '{if (match($0,"## Supporters")) exit; print}' README.md > README
mv -f README README.md
-
if
:
steps.filter.outputs.version == 'true'
name
:
Build ${{ needs.prepare.outputs.package }} package
run
:
python3 -m pip install --upgrade build && python3 -m build
-
if
:
steps.filter.outputs.version == 'true'
name
:
Publish to PyPI
uses
:
pypa/gh-action-pypi-publish@release/v1
Back
|
FazBrowse Home
|
New Git URL