Skip to content

Commit 09c3b57

Browse files
authored
Add render tests (#477)
* Add Monaco build test * Move to script * Add render tests folder * First successful render test run * Remove custom layer * Use express instead of st for range request support in pmtiles protocol * Trim * Trim * Use basemap styles * Rename * Add monaco osm extract * Add generate pmtiles script * Update github workflow * Upload results.html on failure * Update expected image * Change roads label color * Update readme * Revert font color changes * Remove tiles monaco build script
1 parent d5a6bf7 commit 09c3b57

File tree

15 files changed

+6025
-0
lines changed

15 files changed

+6025
-0
lines changed

.github/workflows/render.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Derived from planetiler (Apache License)
2+
# https://github.com/onthegomap/planetiler/blob/main/.github/workflows/maven.yml
3+
4+
name: Render Tests CI
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
render_tests:
14+
name: Render tests
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: 21
23+
distribution: 'temurin'
24+
cache: 'maven'
25+
- uses: actions/setup-node@v3
26+
with:
27+
node-version-file: 'render-tests/.nvmrc'
28+
- name: Generate PMTiles
29+
working-directory: render-tests
30+
run: ./generate_pmtiles.sh
31+
- name: Build styles
32+
run: npm ci && npm run build
33+
working-directory: styles
34+
- name: Build render tests
35+
run: npm ci && npm run build
36+
working-directory: render-tests
37+
- name: Run render tests
38+
run: npm run test
39+
working-directory: render-tests
40+
- name: Upload render test results.html on failure
41+
if: failure()
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: render-test-report
45+
path: ${{ github.workspace }}/render-tests/results.html
46+

render-tests/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dist/
2+
pmtiles/
3+
node_modules/
4+
junit.xml
5+
*.txt
6+
results.html
7+
tests/**/diff.png
8+
tests/**/actual.png

render-tests/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.16.0

render-tests/LICENSE.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
Copyright (c) 2025, Protomaps
2+
3+
Copyright (c) 2023, MapLibre contributors
4+
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of MapLibre GL JS nor the names of its contributors
16+
may be used to endorse or promote products derived from this software
17+
without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
32+
-------------------------------------------------------------------------------
33+
34+
Contains code from mapbox-gl-js v1.13 and earlier
35+
36+
Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license
37+
38+
Copyright (c) 2020, Mapbox
39+
Redistribution and use in source and binary forms, with or without modification,
40+
are permitted provided that the following conditions are met:
41+
42+
* Redistributions of source code must retain the above copyright notice,
43+
this list of conditions and the following disclaimer.
44+
* Redistributions in binary form must reproduce the above copyright notice,
45+
this list of conditions and the following disclaimer in the documentation
46+
and/or other materials provided with the distribution.
47+
* Neither the name of Mapbox GL JS nor the names of its contributors
48+
may be used to endorse or promote products derived from this software
49+
without specific prior written permission.
50+
51+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
55+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
56+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
57+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
58+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
59+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
60+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
61+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62+
63+
64+
-------------------------------------------------------------------------------
65+
66+
Contains code from glfx.js
67+
68+
Copyright (C) 2011 by Evan Wallace
69+
70+
Permission is hereby granted, free of charge, to any person obtaining a copy
71+
of this software and associated documentation files (the "Software"), to deal
72+
in the Software without restriction, including without limitation the rights
73+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
74+
copies of the Software, and to permit persons to whom the Software is
75+
furnished to do so, subject to the following conditions:
76+
77+
The above copyright notice and this permission notice shall be included in
78+
all copies or substantial portions of the Software.
79+
80+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
81+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
82+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
83+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
84+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
85+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
86+
THE SOFTWARE.
87+
88+
--------------------------------------------------------------------------------
89+
90+
Contains a portion of d3-color https://github.com/d3/d3-color
91+
92+
Copyright 2010-2016 Mike Bostock
93+
All rights reserved.
94+
95+
Redistribution and use in source and binary forms, with or without modification,
96+
are permitted provided that the following conditions are met:
97+
98+
* Redistributions of source code must retain the above copyright notice, this
99+
list of conditions and the following disclaimer.
100+
101+
* Redistributions in binary form must reproduce the above copyright notice,
102+
this list of conditions and the following disclaimer in the documentation
103+
and/or other materials provided with the distribution.
104+
105+
* Neither the name of the author nor the names of contributors may be used to
106+
endorse or promote products derived from this software without specific prior
107+
written permission.
108+
109+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
110+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
111+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
112+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
113+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
114+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
115+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
116+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
117+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
118+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

render-tests/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Render Tests
2+
3+
## Usage
4+
5+
Use the node version in the nvmrc file with `nvm use`.
6+
7+
First build the styles package locally:
8+
9+
```
10+
cd ../styles
11+
npm ci
12+
npm run build
13+
```
14+
15+
Then install the dependencies in the render-test folder with:
16+
17+
```
18+
npm ci
19+
```
20+
21+
Then build the render test runner:
22+
23+
```
24+
npm run build
25+
```
26+
27+
The render test runner is now ready, but we still need to generate some pmtiles with:
28+
29+
```
30+
./generate_pmtiles.sh
31+
```
32+
33+
You should now have a folder `pmtiles`.
34+
35+
Then run the render tests with:
36+
37+
```
38+
npm run test
39+
```
40+
41+
This will create a `results.html` file. Have a look at it with something like
42+
43+
```
44+
npx serve .
45+
```
46+
47+
## Updating Tests
48+
49+
When `expected.png` images should change, you can tell the render test runner to copy the `actual.png` to the `expected.png` images with:
50+
51+
```
52+
UPDATE=true npm run test
53+
```
54+
55+
## Looking at CI `results.html`
56+
57+
The `results.html` generated by GitHub actions runners can be downloaded at the end of the run. The html file will be inside a zip container. This can be convenient to get access to exactly the pixels that are generate in CI.
58+
59+
## License
60+
61+
The code in this folder has been derived from the render tests of MapLibre GL, a fork of Mapbox GL. The license therefore is based on MapLibre's license (BSD), see [LICENSE.md](./LICENSE.md).
617 KB
Binary file not shown.

render-tests/generate_pmtiles.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mkdir -p pmtiles
2+
cd ../tiles
3+
mvn clean package -DskipTests
4+
java -Xmx2g -jar target/protomaps-basemap-HEAD-with-deps.jar \
5+
--osm_path=../render-tests/fixtures/monaco-2025-02-15.osm.pbf \
6+
--output=../render-tests/pmtiles/monaco-roads.pmtiles \
7+
--force \
8+
--nodemap-type=sparsearray \
9+
--layer=roads

0 commit comments

Comments
 (0)