Skip to content

Commit 295db9b

Browse files
authored
Merge pull request #300 from GeospatialPython/Refactor_workflows
Refactor workflows to support testing before deployment, and testing on Windows and MacOS.
2 parents 89498e4 + 4724d21 commit 295db9b

File tree

4 files changed

+102
-17
lines changed

4 files changed

+102
-17
lines changed

.github/actions/test/action.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name:
2+
Test
3+
4+
description:
5+
Run pytest, and run the doctest runner (shapefile.py as a script).
6+
7+
runs:
8+
using: "composite"
9+
steps:
10+
# The Repo is required to already be checked out, e.g. by the calling workflow
11+
12+
# The Python to be tested with is required to already be setup, with "python" and "pip" on the system Path
13+
14+
- name: Doctests
15+
shell: bash
16+
run: python shapefile.py
17+
18+
- name: Install test dependencies.
19+
shell: bash
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r requirements.test.txt
23+
24+
- name: Pytest
25+
shell: bash
26+
run: |
27+
pytest
28+
29+
- name: Show versions for logs.
30+
shell: bash
31+
run: |
32+
python --version
33+
python -m pytest --version
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow will run the tests on a variety of operating systems and architectures.
2+
3+
name: Run tests on low availability Github hosted runners
4+
5+
on:
6+
# Optionally run only, until the availability of the required Github hosted
7+
# runners does not slow down CI.
8+
workflow_call:
9+
workflow_dispatch:
10+
11+
jobs:
12+
run_tests:
13+
if: github.repository == 'GeospatialPython/pyshp'
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: [
18+
"3.12",
19+
]
20+
os: [
21+
# "macos-12",
22+
"ubuntu-24.04",
23+
# "windows-2022",
24+
]
25+
26+
runs-on: matrix.os
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ inputs.python_version }}
33+
34+
- name: Run tests
35+
uses: ./.github/actions/test

.github/workflows/deploy.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,47 @@ on:
1313
types: [published]
1414

1515
jobs:
16-
deploy:
16+
test:
1717

18+
# In general, tests should be run after building a distribution, to test that distribution.
19+
# However as long as PyShp is a pure Python library, with pure Python deps (or no deps)
20+
# then this would only test the packaging process, not so much the code as there are
21+
# no binaries.
1822
runs-on: ubuntu-latest
1923

2024
steps:
2125
- uses: actions/checkout@v4
2226
- name: Set up Python
23-
uses: actions/setup-python@v2
27+
uses: actions/setup-python@v5
2428
with:
2529
python-version: '3.x'
30+
31+
- name: Run tests and hooks
32+
uses: ./.github/workflows/run_tests_and_hooks.yml
33+
34+
deploy:
35+
# Prevent deployment of releases that fail any hooks (e.g. linting) or that fail any tests.
36+
needs: test
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
- name: Set up Python
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: '3.x'
45+
46+
47+
2648
- name: Install dependencies
2749
run: |
2850
python -m pip install --upgrade pip
2951
pip install build
3052
- name: Build package
3153
run: python -m build
54+
3255
- name: Publish package
56+
if: github.repository == 'GeospatialPython/pyshp'
3357
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
3458
with:
3559
user: __token__

.github/workflows/build.yml renamed to .github/workflows/run_tests_and_hooks.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
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
1+
# This workflow will run the pre-commit hooks (including linters), and the tests with a variety of Python versions
32

4-
name: build
3+
name: Run pre-commit hooks and tests
54

65
on:
76
push:
87
pull_request:
98
branches: [ master ]
9+
workflow_call:
1010
workflow_dispatch:
1111

1212
jobs:
@@ -16,8 +16,8 @@ jobs:
1616
- uses: actions/checkout@v4
1717
- uses: actions/setup-python@v5
1818
- uses: pre-commit/action@v3.0.1
19-
test:
2019

20+
run_tests_in_containers:
2121
strategy:
2222
fail-fast: false
2323
matrix:
@@ -40,14 +40,7 @@ jobs:
4040

4141
steps:
4242
- uses: actions/checkout@v4
43-
- name: Install dependencies
44-
run: |
45-
python -m pip install --upgrade pip
46-
python -m pip install pytest
47-
if [ -f requirements.test.txt ]; then pip install -r requirements.test.txt; fi
48-
- name: Test with doctest
49-
run: |
50-
python shapefile.py
51-
- name: Test with pytest
52-
run: |
53-
pytest
43+
44+
- name: Run tests
45+
uses: ./.github/actions/test
46+

0 commit comments

Comments
 (0)