Skip to content

Commit

Permalink
CI: Fix GEOS main caching (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervdw committed Sep 30, 2021
1 parent 26ad6d5 commit b36c9b1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
36 changes: 26 additions & 10 deletions .github/workflows/test-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,33 @@ jobs:

env:
GEOS_VERSION: ${{ matrix.geos }}
GEOS_VERSION_SPEC: ${{ matrix.geos }}
GEOS_INSTALL: ${{ github.workspace }}/geosinstall/geos-${{ matrix.geos }}
GEOS_BUILD: ${{ github.workspace }}/geosbuild

steps:
- uses: actions/checkout@v2
- name: Correct slashes in GEOS_INSTALL (Windows)
run: |
echo 'GEOS_INSTALL=${{ github.workspace }}\geosinstall\geos-${{ matrix.geos }}' >> $GITHUB_ENV
echo 'GEOS_BUILD=${{ github.workspace }}\geosbuild' >> $GITHUB_ENV
if: ${{ matrix.os == 'windows-2019' }}

- name: Checkout PyGEOS
uses: actions/checkout@v2

- name: Checkout GEOS (main)
uses: actions/checkout@v2
with:
repository: libgeos/geos
ref: main
path: ${{ env.GEOS_BUILD }}
if: ${{ matrix.geos == 'main' }}

- name: Put the latest commit hash in the cache token
run: |
echo "GEOS_VERSION_SPEC=$(git rev-parse HEAD)" >> $GITHUB_ENV
working-directory: ${{ env.GEOS_BUILD }}
if: ${{ matrix.geos == 'main' }}

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
Expand All @@ -63,7 +86,7 @@ jobs:
- name: Cache GEOS and pip packages
uses: actions/cache@v2
with:
key: ${{ matrix.os }}-${{ matrix.architecture }}-geos-${{ matrix.geos }}-${{ hashFiles('ci/install_geos.sh') }}
key: ${{ matrix.os }}-${{ matrix.architecture }}-geos-${{ env.GEOS_VERSION_SPEC }}-${{ hashFiles('ci/install_geos.sh') }}
path: |
~/.cache/pip
${{ github.workspace }}/geosinstall
Expand All @@ -74,11 +97,6 @@ jobs:
arch: ${{ matrix.architecture }}
if: ${{ matrix.os == 'windows-2019' }}

- name: Correct slashes in GEOS_INSTALL (Windows)
run: |
echo 'GEOS_INSTALL=${{ github.workspace }}\geosinstall\geos-${{ matrix.geos }}' >> $GITHUB_ENV
if: ${{ matrix.os == 'windows-2019' }}

- name: Install GEOS
run: |
./ci/install_geos.sh
Expand Down Expand Up @@ -118,9 +136,7 @@ jobs:
if: ${{ matrix.os == 'windows-2019' }}

- name: Build PyGEOS
run: |
python setup.py build_ext --inplace
pip install --no-deps -e .
run: python setup.py build_ext --inplace

- name: Run tests
continue-on-error: ${{ matrix.geos == 'main' }}
Expand Down
28 changes: 6 additions & 22 deletions ci/install_geos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,13 @@ build_geos(){
cmake --install .
}

if [ "$GEOS_VERSION" = "main" ]; then
prepare_geos_build_dir
# use GitHub mirror
git clone --depth 1 https://github.com/libgeos/geos.git geos-$GEOS_VERSION
cd geos-$GEOS_VERSION
git log -1
git rev-parse HEAD > newrev.txt
BUILD=no
# Only build if nothing cached or if the GEOS revision changed
if test ! -f $GEOS_INSTALL/rev.txt; then
BUILD=yes
elif ! diff newrev.txt $GEOS_INSTALL/rev.txt >/dev/null; then
BUILD=yes
fi
if test "$BUILD" = "no"; then
echo "Using cached install $GEOS_INSTALL"
else
cp newrev.txt $GEOS_INSTALL/rev.txt
build_geos
fi
if [ -d "$GEOS_INSTALL/include/geos" ]; then
echo "Using cached install $GEOS_INSTALL"
else
if [ -d "$GEOS_INSTALL/include/geos" ]; then
echo "Using cached install $GEOS_INSTALL"
if [ "$GEOS_VERSION" = "main" ]; then
# Expect the CI to have put the latest checkout in GEOS_BUILD
cd $GEOS_BUILD
build_geos
else
prepare_geos_build_dir
curl -OL http://download.osgeo.org/geos/geos-$GEOS_VERSION.tar.bz2
Expand Down

0 comments on commit b36c9b1

Please sign in to comment.