1
+ name : Run tests
2
+
3
+ on :
4
+ push :
5
+ branches : [master]
6
+ pull_request :
7
+ branches : [master]
8
+ schedule :
9
+ - cron : " 0 0 * * *"
10
+
11
+ permissions :
12
+ contents : read
13
+
14
+ jobs :
15
+
16
+ test-ubuntu :
17
+
18
+ runs-on : ubuntu-latest
19
+
20
+ strategy :
21
+ matrix :
22
+ python-version : ['3.8', '3.9', '3.10', '3.11', '3.12']
23
+
24
+ steps :
25
+ - uses : actions/checkout@v4
26
+
27
+ - name : Set up Python
28
+
29
+ with :
30
+ cache : ' pip'
31
+ python-version : ${{ matrix.python-version }}
32
+
33
+ - name : Install dependencies
34
+ run : |
35
+ sudo apt-add-repository ppa:ubuntugis/ppa
36
+ sudo apt-get update
37
+ sudo apt-get install gdal-bin libgdal-dev
38
+ python -m pip install --upgrade pip
39
+ python -m pip install GDAL==`gdal-config --version`
40
+ python -m pip install -r requirements_dev.txt
41
+
42
+ - name : Set up docker-compose
43
+ run : |
44
+ docker compose -f tests/docker-compose.yaml up -d
45
+ sleep 60 # Geoserver takes quite a long time to boot up and there is no healthcheck
46
+
47
+ - name : Test with pytest
48
+ uses : dariocurr/pytest-summary@main
49
+ with :
50
+ paths : tests/test_geoserver.py
51
+ env :
52
+ DB_HOST : postgis
53
+
54
+ - name : Upload test summary
55
+ uses : actions/upload-artifact@v4
56
+ with :
57
+ name : test-summary-linux
58
+ path : test-summary-linux.md
59
+ if : always()
60
+
61
+ # test-windows:
62
+ #
63
+ # runs-on: windows-latest
64
+ #
65
+ # steps:
66
+ # - uses: actions/checkout@v4
67
+ #
68
+ # - name: Set up Python 3.10
69
+ # uses: actions/setup-python@v3
70
+ # with:
71
+ # python-version: '3.10'
72
+ #
73
+ # - name: Set up PostGIS
74
+ # run: |
75
+ #
76
+ # # Install PostGIS (PostgreSQL comes on the GitHub Actions runner by default but lacks PostGIS control files and dependencies)
77
+ # netsh advfirewall firewall show rule name="Allow Localhost 5432"
78
+ # Invoke-WebRequest -Uri "http://download.osgeo.org/postgis/windows/pg14/postgis-bundle-pg14x64-setup-3.4.1-1.exe" -OutFile "postgis-installer.exe"
79
+ # Start-Process "postgis-installer.exe" -ArgumentList "/S /D=C:\Program Files\PostgreSQL\14" -Wait -NoNewWindow
80
+ # & "C:\Program Files\PostgreSQL\14\bin\pg_ctl.exe" -D "C:\Program Files\PostgreSQL\14\data" start
81
+ # & "C:\Program Files\PostgreSQL\14\bin\psql.exe" -U postgres -c "CREATE DATABASE geodb;"
82
+ # & "C:\Program Files\PostgreSQL\14\bin\psql.exe" -U postgres -c "CREATE USER geodb_user WITH ENCRYPTED PASSWORD 'geodb_pass';"
83
+ # & "C:\Program Files\PostgreSQL\14\bin\psql.exe" -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE geodb TO geodb_user;"
84
+ # & "C:\Program Files\PostgreSQL\14\bin\psql.exe" -U postgres -d geodb -c "CREATE EXTENSION postgis;"
85
+ #
86
+ # - name: Set up Tomcat/GeoServer
87
+ # run: |
88
+ #
89
+ # # Configure firewall to allow connectiosn to localhost port 8080 (might not be necessary)
90
+ # netsh advfirewall firewall add rule name="Allow Localhost 5432" dir=in action=allow protocol=TCP localport=5432
91
+ #
92
+ # # Download and install Apache Tomcat (need version 9 because the JRE on the GitHub Actions runner is incompatible with 10+)
93
+ # curl -L https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.88/bin/apache-tomcat-9.0.88-windows-x64.zip -o tomcat.zip
94
+ # Expand-Archive -Path tomcat.zip -DestinationPath "C:\"
95
+ # $directory = Get-ChildItem -Path "C:\" -Directory | Where-Object { $_.Name -like "*apache-tomcat*" } | Select-Object -First 1
96
+ # if ($directory) { Rename-Item -Path $directory.FullName -NewName "Tomcat" }
97
+ #
98
+ # # Download and install Geoserver, then move it to the Tomcat directory
99
+ # # Version-locked to 2.22.0 beacause of Java 8
100
+ # curl -L https://sourceforge.net/projects/geoserver/files/GeoServer/2.22.0/geoserver-2.22.0-war.zip/download -o geoserver.zip
101
+ # Expand-Archive -Path geoserver.zip -DestinationPath "C:\GeoServer"
102
+ # cp C:\GeoServer\geoserver.war C:\Tomcat\webapps\geoserver.war
103
+ #
104
+ # # Set env vars for Tomcat and run it (it takes a little while, so wait 30 seconds after)
105
+ # $env:CATALINA_BASE = "C:\Tomcat"
106
+ # $env:CATALINA_HOME = "C:\Tomcat"
107
+ # $env:CATALINA_TMPDIR = "C:\Tomcat\temp"
108
+ # C:\Tomcat\bin\startup.bat
109
+ # Start-Sleep -Seconds 30
110
+ #
111
+ # shell: pwsh
112
+ #
113
+ # - name: Install Miniconda
114
+ # run: |
115
+ # curl -O https://repo.anaconda.com/miniconda/Miniconda3-py39_4.10.3-Windows-x86_64.exe
116
+ # Start-Process -FilePath "Miniconda3-py39_4.10.3-Windows-x86_64.exe" -ArgumentList '/InstallationType=JustMe /RegisterPython=0 /S /D="%UserProfile%\Miniconda3"' -Wait -NoNewWindow
117
+ # & "$env:UserProfile\Miniconda3\Scripts\conda" init powershell
118
+ # shell: pwsh
119
+ #
120
+ # - name: Configure Conda environment
121
+ # run: |
122
+ # $env:PATH = "$env:UserProfile\Miniconda3;$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin;$env:PATH"
123
+ # conda update conda -y
124
+ # conda create -n geospatial python=3.10 -y
125
+ # conda activate geospatial
126
+ # conda install -c conda-forge gdal>=3.4.1 -y
127
+ # python -m pip install --upgrade pip
128
+ # pip install -r requirements_dev.txt
129
+ # shell: pwsh
130
+ #
131
+ # #- name: Test with pytest
132
+ # # uses: dariocurr/pytest-summary@main
133
+ # # with:
134
+ # # paths: tests/test_geoserver.py
135
+ # # env:
136
+ # # DB_HOST: postgis
137
+ #
138
+ # - name: Test with pytest
139
+ # run: |
140
+ # conda activate geospatial
141
+ # pytest tests/test_geoserver.py
142
+ #
143
+ # - name: Upload test summary
144
+ # uses: actions/upload-artifact@v3
145
+ # with:
146
+ # name: test-summary-windows
147
+ # path: test-summary-windows.md
148
+ # if: always()
0 commit comments