@@ -17,30 +17,38 @@ inputs:
1717 description : Path to where the PyShp repo was checked out to (to keep separate from Shapefiles & artefacts repo).
1818 required : false
1919 default : ' .'
20- python-version :
21- description : Set to "2.7" to use caddy instead of python -m SimpleHTTPServer
22- required : true
2320
2421
2522
2623runs :
2724 using : " composite"
2825 steps :
2926 # The PyShp repo is required to already be checked out into pyshp_repo_directory,
27+ # and the wheel to be tested in ./dist within it.
3028 # e.g. by the calling workflow using:
3129 # steps:
3230 # - uses: actions/checkout@v4
3331 # with:
3432 # path: ./Pyshp
33+ #
34+ # - name: Build distribution artefacts (wheel and sdist)
35+ # uses: ./Pyshp/.github/actions/build_wheel_and_sdist
36+ #
3537 # and then calling this Action with:
38+ #
3639 # - name: Run tests
3740 # uses: ./Pyshp/.github/actions/test
3841 # with:
3942 # extra_args: ""
4043 # replace_remote_urls_with_localhost: 'yes'
4144 # pyshp_repo_directory: ./Pyshp
4245
43- # The Python to be tested with is required to already be setup, with "python" and "pip" on the system Path
46+ # The Python to be tested with is required to already be setup,
47+ # with "python" and "pip" on the system Path
48+ # (so that this custom Action can be used with both reproducible
49+ # Pythons from Python docker images, and more frequently deprecated Pythons
50+ # from - uses: actions/setup-python@v5)
51+
4452
4553 - name : Checkout shapefiles and zip file artefacts repo
4654 if : ${{ inputs.replace_remote_urls_with_localhost == 'yes' }}
@@ -50,58 +58,52 @@ runs:
5058 path : ./PyShp_test_shapefile
5159
5260 - name : Serve shapefiles and zip file artefacts on localhost
53- if : ${{ inputs.replace_remote_urls_with_localhost == 'yes' && inputs.python-version != '2.7' }}
61+ if : ${{ inputs.replace_remote_urls_with_localhost == 'yes' }}
5462 shell : bash
5563 working-directory : ./PyShp_test_shapefile
5664 run : |
5765 python -m http.server 8000 &
5866 echo "HTTP_SERVER_PID=$!" >> $GITHUB_ENV
5967 sleep 4 # give server time to start
6068
61- - name : Download and unzip Caddy binary
62- if : ${{ inputs.replace_remote_urls_with_localhost == 'yes' && inputs.python-version == '2.7'}}
63- working-directory : .
64- shell : bash
65- run : |
66- curl -L https://github.com/caddyserver/caddy/releases/download/v2.10.0/caddy_2.10.0_linux_amd64.tar.gz --output caddy.tar.gz
67- tar -xzf caddy.tar.gz
68-
69- - name : Serve shapefiles and zip file artefacts on localhost using Caddy
70- if : ${{ inputs.replace_remote_urls_with_localhost == 'yes' && inputs.python-version == '2.7'}}
71- shell : bash
72- working-directory : .
73- run : |
74- ./caddy file-server --root ./PyShp_test_shapefile --listen :8000 &
75- echo "HTTP_SERVER_PID=$!" >> $GITHUB_ENV
76- sleep 2 # give server time to start
77-
7869 - name : Doctests
7970 shell : bash
8071 working-directory : ${{ inputs.pyshp_repo_directory }}
8172 env :
8273 REPLACE_REMOTE_URLS_WITH_LOCALHOST : ${{ inputs.replace_remote_urls_with_localhost }}
8374 run : python shapefile.py ${{ inputs.extra_args }}
8475
85- - name : Install test dependencies.
76+
77+ - name : Download wheel and sdist (built in previous jobs)
78+ uses : actions/download-artifact@v4
79+ with :
80+ name : PyShp_wheel_and_sdist
81+ path : dist
82+
83+ - name : Install PyShp from the wheel (built in prev step)
8684 shell : bash
87- working-directory : ${{ inputs.pyshp_repo_directory }}
85+ working-directory : dist/
8886 run : |
89- python -m pip install --upgrade pip
90- pip install -e . [test]
87+ WHEEL_NAME=$(ls pyshp-*py3-none-any.whl)
88+ python -m pip install $WHEEL_NAME [test]
9189
92- - name : Pytest
90+ - name : Show Python and Pytest versions for logs.
91+ shell : bash
92+ run : |
93+ python --version
94+ python -m pytest --version
95+
96+ - name : Run Pytest
9397 shell : bash
9498 working-directory : ${{ inputs.pyshp_repo_directory }}
9599 env :
96100 REPLACE_REMOTE_URLS_WITH_LOCALHOST : ${{ inputs.replace_remote_urls_with_localhost }}
97101 run : |
102+ echo "Ensure the tests import the installed wheel"
103+ mv shapefile.py __tmp.py
98104 pytest -rA --tb=short ${{ inputs.extra_args }}
105+ mv __tmp.py shapefile.py
99106
100- - name : Show versions for logs.
101- shell : bash
102- run : |
103- python --version
104- python -m pytest --version
105107
106108
107109 # - name: Test http server
0 commit comments