Skip to content

Commit 0860687

Browse files
committed
CI: split PR build functionality in separate file
1 parent 510cd55 commit 0860687

File tree

4 files changed

+120
-8
lines changed

4 files changed

+120
-8
lines changed

.github/workflows/python-dependencies.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ name: Python dependencies
55

66
on:
77
workflow_dispatch: {}
8-
push: {}
9-
pull_request:
8+
push:
109
branches: [ master ]
1110

1211
jobs:

.github/workflows/python-package.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ name: Python package
55

66
on:
77
workflow_dispatch: {}
8-
push: {}
9-
pull_request:
8+
push:
109
branches: [ master ]
1110

1211
jobs:
@@ -95,7 +94,7 @@ jobs:
9594
set -e
9695
gh --repo sourcehold/sourcehold-maps release create latest --latest
9796
fi
98-
- name: Upload pyinstaller to special latest release
97+
- name: Upload wheel to special latest release
9998
shell: bash
10099
env:
101100
GH_TOKEN: ${{ github.token }}

.github/workflows/python-pr.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python PR
5+
6+
on:
7+
workflow_dispatch: {}
8+
pull_request: {}
9+
10+
jobs:
11+
build:
12+
permissions:
13+
contents: write
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
# os: [ubuntu-latest, windows-latest, macOS-latest]
18+
os: [windows-latest]
19+
platform: [x86]
20+
python-version: ['3.8']
21+
python-platform: [x86]
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
architecture: ${{ matrix.python-platform }}
29+
- name: Enable Developer Command Prompt
30+
uses: ilammy/[email protected]
31+
with:
32+
arch: ${{ matrix.python-platform }}
33+
if: matrix.os == 'windows-latest'
34+
- name: Install dependencies
35+
shell: bash
36+
run: |
37+
python -m pip install --upgrade pip
38+
python -m pip install --upgrade wheel setuptools Cython
39+
pip install flake8 pytest
40+
pip install -r requirements.txt
41+
- name: Lint with flake8
42+
shell: bash
43+
run: |
44+
# stop the build if there are Python syntax errors or undefined names
45+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude examples
46+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
47+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude examples
48+
49+
- name: Run tests
50+
shell: bash
51+
run: |
52+
python -m pip install pytest
53+
python -m pytest
54+
55+
- name: Build package
56+
shell: bash
57+
run: |
58+
python setup.py sdist bdist_wheel
59+
60+
- name: Build wheel dependencies
61+
shell: bash
62+
run: |
63+
python -m pip wheel . -w dist
64+
65+
- name: Run pyinstaller
66+
shell: bash
67+
run: |
68+
python -m pip install pyinstaller
69+
pyinstaller --console --onefile ./sourcehold/__main__.py --name sourcehold
70+
71+
- name: Archive packages
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: sourcehold-py${{ matrix.python-version }}-${{ matrix.python-platform }}-${{ matrix.os }}-${{ matrix.platform }}
75+
path: |
76+
dist/sourcehold*
77+
78+
79+
test_package:
80+
needs: build
81+
runs-on: ${{ matrix.os }}
82+
strategy:
83+
matrix:
84+
# os: [ubuntu-latest, windows-latest, macOS-latest]
85+
os: [windows-latest]
86+
platform: [x86, x64]
87+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
88+
python-platform: [x86, x64]
89+
steps:
90+
- name: Download package
91+
uses: actions/[email protected]
92+
with:
93+
name: sourcehold-py${{ matrix.python-version }}-${{ matrix.python-platform }}-${{ matrix.os }}-${{ matrix.platform }}
94+
- name: Set up Python ${{ matrix.python-version }}
95+
uses: actions/setup-python@v5
96+
with:
97+
python-version: ${{ matrix.python-version }}
98+
architecture: ${{ matrix.python-platform }}
99+
- name: Install wheel
100+
shell: bash
101+
run: |
102+
python -m pip install --upgrade pip
103+
python -m pip install --upgrade wheel setuptools
104+
- name: Pip install module
105+
run: |
106+
python -m pip install $(ls *.whl)
107+
shell: bash
108+
- name: Pip test module
109+
run: |
110+
python -c "import sourcehold"
111+
shell: bash
112+
- name: Pip test cli
113+
run: |
114+
echo "hello world!" | python -m sourcehold compression --compress --input - --output - | python -m sourcehold compression --decompress --input - --output -
115+
shell: bash

.github/workflows/python-pyinstaller.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ name: Python pyinstaller
55

66
on:
77
workflow_dispatch: {}
8-
push: {}
9-
pull_request:
8+
push:
109
branches: [ master ]
1110

1211
jobs:
@@ -40,10 +39,10 @@ jobs:
4039
python -m pip install --upgrade wheel setuptools Cython
4140
pip install flake8 pytest
4241
pip install -r requirements.txt
43-
python -m pip install pyinstaller
4442
- name: Run pyinstaller
4543
shell: bash
4644
run: |
45+
python -m pip install pyinstaller
4746
pyinstaller --console --onefile ./sourcehold/__main__.py --name sourcehold
4847
- name: Ensure special latest release exists
4948
shell: bash

0 commit comments

Comments
 (0)