Skip to content

Commit 6da3de2

Browse files
authored
Update python-app.yml
1 parent b652c27 commit 6da3de2

1 file changed

Lines changed: 24 additions & 92 deletions

File tree

.github/workflows/python-app.yml

Lines changed: 24 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,36 @@
1-
name: CLI Tool CI/CD
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python application
25

36
on:
47
push:
5-
branches: [main, master]
8+
branches: [ "main" ]
69
pull_request:
7-
branches: [main, master]
10+
branches: [ "main" ]
11+
12+
permissions:
13+
contents: read
814

915
jobs:
10-
build-and-test:
16+
build:
17+
1118
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
python-version: ["3.8", "3.10", "3.11"]
15-
19+
1620
steps:
17-
- name: Checkout repository
18-
uses: actions/checkout@v4
19-
20-
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v5
21+
- uses: actions/checkout@v4
22+
- name: Set up Python 3.13
23+
uses: actions/setup-python@v3
2224
with:
23-
python-version: ${{ matrix.python-version }}
24-
cache: 'pip'
25-
cache-dependency-path: 'requirements.txt'
26-
25+
python-version: "3.10"
2726
- name: Install dependencies
2827
run: |
2928
python -m pip install --upgrade pip
30-
pip install -r requirements.txt
31-
32-
- name: Run CLI help command (smoke test)
33-
run: |
34-
python wintool.py --help
35-
36-
- name: Lint code
37-
run: |
38-
pip install flake8
39-
flake8 wintool.py --max-line-length=120 --ignore=E501,W503
40-
41-
- name: Run unit tests
42-
run: |
43-
if [ -f test_wintool.py ]; then
44-
pip install pytest
45-
pytest -v test_wintool.py
46-
else
47-
echo "No tests found, skipping test step"
48-
fi
49-
50-
package-and-release:
51-
needs: build-and-test
52-
runs-on: ubuntu-latest
53-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
54-
55-
steps:
56-
- name: Checkout repository
57-
uses: actions/checkout@v4
58-
59-
- name: Set up Python 3.10
60-
uses: actions/setup-python@v5
61-
with:
62-
python-version: "3.10"
63-
64-
- name: Install packaging tools
65-
run: |
66-
pip install setuptools wheel twine pyinstaller
67-
68-
- name: Build Python package
69-
run: |
70-
python setup.py sdist bdist_wheel
71-
72-
- name: Create standalone executable
73-
run: |
74-
pyinstaller --onefile --name wintool wintool.py
75-
76-
- name: Test executable
77-
run: |
78-
./dist/wintool --version || ./dist/wintool.exe --version
79-
80-
- name: Create release archive
81-
run: |
82-
mkdir release
83-
cp dist/wintool* release/
84-
cp wintool.py release/
85-
cp README.md release/
86-
tar -czvf wintool-cli-${{ github.run_number }}.tar.gz release/
87-
88-
- name: Upload to GitHub Releases
89-
uses: softprops/action-gh-release@v1
90-
with:
91-
files: |
92-
wintool-cli-${{ github.run_number }}.tar.gz
93-
dist/wintool*
94-
tag_name: v${{ github.run_number }}
95-
name: Release v${{ github.run_number }}
96-
body: Automated build of wintool CLI
97-
98-
- name: Publish to PyPI
99-
if: ${{ success() }}
100-
run: |
101-
twine upload dist/*
102-
env:
103-
TWINE_USERNAME: __token__
104-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
29+
pip install flake8 pytest
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

0 commit comments

Comments
 (0)