Skip to content

Define test running in a reuseable action. Rename build.yml. Test before deployment. Only deploy from this repo, and only test on MacOS and Windows here.. #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name:
Test

description:
Run pytest, and run the doctest runner (shapefile.py as a script).

runs:
using: "composite"
steps:
# The Repo is required to already be checked out, e.g. by the calling workflow

# The Python to be tested with is required to already be setup, with "python" and "pip" on the system Path

- name: Doctests
shell: bash
run: python shapefile.py

- name: Install test dependencies.
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r requirements.test.txt

- name: Pytest
shell: bash
run: |
pytest

- name: Show versions for logs.
shell: bash
run: |
python --version
python -m pytest --version
53 changes: 0 additions & 53 deletions .github/workflows/build.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,24 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: '3.x'

# In general tests should be run after building a distribution, to test that distribution.
# However as long as PyShp is a pure Python library, with pure Python deps (or no deps)
# then it's not crucial.

# Prevent deployment of releases that fail any hooks (e.g. linting) or that fail any tests.
- name: Run tests and hooks
uses: ./.github/workflows/run_tests_and_hooks.yml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build

- name: Publish package
if: github.repository == 'GeospatialPython/pyshp'
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/run_tests_and_hooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This workflow will run the pre-commit hooks (including linters), and the tests with a variety of Python versions

name: Run pre-commit hooks and tests

on:
push:
pull_request:
branches: [ master ]
workflow_call:
workflow_dispatch:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1

test_in_slim_Python_containers:
strategy:
fail-fast: false
matrix:
python-version: [
"2.7",
"3.5",
"3.6",
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
"3.13.0a2",
]

runs-on: ubuntu-latest
container:
image: python:${{ matrix.python-version }}-slim

steps:
- uses: actions/checkout@v4

- name: Run tests
uses: ./.github/actions/test


test_on_MacOS_and_Windows:
if: github.repository == 'GeospatialPython/pyshp'
strategy:
fail-fast: false
matrix:
python-version: [
"3.12",
]
os: [
"macos-latest",
"windows-latest",
]
# include:
# - os: "windows-latest"
# python-version: "3.13"
# - os: "macos-latest"
# python-version: "3.13"

runs-on: matrix.os
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}

- name: Run tests
uses: ./.github/actions/test