diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index da207ba..35d117e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -11,8 +11,11 @@ on: types: [created] jobs: - docker: + build-and-deploy: runs-on: ubuntu-latest + outputs: + tags: ${{ steps.meta.outputs.tags }} + version: ${{ steps.meta.outputs.version }} steps: - name: Checkout uses: actions/checkout@v4 @@ -47,28 +50,62 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} repository: communityfirst/mapgl-tile-renderer short-description: 'Node.js MapGL renderer for styled raster tiles in MBTiles format.' - - name: Test run of Docker image with self-provided style - run: | - docker run --rm -v ${{ github.workspace }}/outputs:/app/outputs ${{ steps.meta.outputs.tags }} --style self --stylelocation tests/fixtures/alert/style-with-geojson.json --stylesources tests/fixtures/alert/sources --bounds "-54.28772,3.11460,-54.03630,3.35025" -Z 10 -f self-${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} - - name: Test run of Docker image with Bing source - run: | - docker run --rm -v ${{ github.workspace }}/outputs:/app/outputs ${{ steps.meta.outputs.tags }} --style bing --bounds "-54.28772,3.11460,-54.03630,3.35025" -Z 10 -f bing-${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} - - name: Test run of Docker image with Esri source and GeoJSON overlay - run: | - docker run --rm -v ${{ github.workspace }}/outputs:/app/outputs ${{ steps.meta.outputs.tags }} --style esri --bounds "-54.28772,3.11460,-54.03630,3.35025" -Z 10 --overlay '{"type": "FeatureCollection", "name": "alert", "features": [{"geometry": {"coordinates": [[[-54.25348208981326, 3.140689896338671], [-54.25348208981326, 3.140600064810259], [-54.253841415926914, 3.140600064810259], [-54.25348208981326, 3.140689896338671]]], "geodesic": false, "type": "Polygon"}, "id": "-603946+34961", "properties": {"month_detec": "09", "year_detec": "2023"}, "type": "Feature"}]}' -f esri-${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} - - name: Test run of Docker image with Mapbox source + test-docker-image: + needs: build-and-deploy + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: true + matrix: + style: [self, bing, esri, mapbox, planet, protomaps] + include: + - style: self + command: "--style self --stylelocation tests/fixtures/alert/style-with-geojson.json --stylesources tests/fixtures/alert/sources" + apikey_secret: "" + - style: bing + command: "--style bing" + apikey_secret: "" + - style: esri + command: "--style esri --overlay '{\"type\": \"FeatureCollection\", \"name\": \"alert\", \"features\": [{\"geometry\": {\"coordinates\": [[[-54.25348208981326, 3.140689896338671], [-54.25348208981326, 3.140600064810259], [-54.253841415926914, 3.140600064810259], [-54.25348208981326, 3.140689896338671]]], \"geodesic\": false, \"type\": \"Polygon\"}, \"id\": \"-603946+34961\", \"properties\": {\"month_detec\": \"09\", \"year_detec\": \"2023\"}, \"type\": \"Feature\"}]}'" + apikey_secret: "" + - style: mapbox + command: "--style mapbox" + apikey_secret: MAPBOX_API_KEY + - style: planet + command: "--style planet --monthyear 2013-12" + apikey_secret: PLANET_API_KEY + - style: protomaps + command: "--style protomaps" + apikey_secret: PROTOMAPS_API_KEY + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up environment variables for API key and Mapbox style run: | - docker run --rm -v ${{ github.workspace }}/outputs:/app/outputs ${{ steps.meta.outputs.tags }} --style mapbox --mapboxstyle ${{ secrets.MAPBOX_STYLE }} --apikey ${{ secrets.MAPBOX_API_KEY }} --bounds "-54.28772,3.11460,-54.03630,3.35025" -Z 10 -f mapbox-${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} - - name: Test run of Docker image with Planet source + if [ "${{ matrix.apikey_secret }}" != "" ]; then + echo "APIKEY=${{ secrets[matrix.apikey_secret] }}" >> $GITHUB_ENV + fi + if [ "${{ matrix.style }}" == "mapbox" ]; then + echo "MAPBOX_STYLE=${{ secrets.MAPBOX_STYLE }}" >> $GITHUB_ENV + fi + - name: Test run of Docker image with ${{ matrix.style }} style run: | - docker run --rm -v ${{ github.workspace }}/outputs:/app/outputs ${{ steps.meta.outputs.tags }} --style planet --monthyear 2023-12 --apikey ${{ secrets.PLANET_API_KEY }} --bounds "-54.28772,3.11460,-54.03630,3.35025" -Z 5 -f planet-${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} - - name: Test run of Docker image with Protomaps source + docker run --rm -v ${{ github.workspace }}/outputs:/app/outputs ${{ needs.build-and-deploy.outputs.tags }} ${{ matrix.command }} --bounds "-54.28772,3.11460,-54.03630,3.35025" -Z ${{ matrix.style == 'planet' && '5' || '10' }} -f ${{ matrix.style }}-${{ needs.build-and-deploy.outputs.version }} ${{ env.MAPBOX_STYLE && '--mapboxstyle' || '' }} ${{ env.MAPBOX_STYLE || '' }} ${{ env.APIKEY && '--apikey' || '' }} ${{ env.APIKEY || '' }} + - name: Install mbview and render tiles run: | - docker run --rm -v ${{ github.workspace }}/outputs:/app/outputs ${{ steps.meta.outputs.tags }} --style protomaps --apikey ${{ secrets.PROTOMAPS_API_KEY }} --bounds "-54.28772,3.11460,-54.03630,3.35025" -Z 5 -f protomaps-${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} + npm install -g @mapbox/mbview + MAPBOX_ACCESS_TOKEN=${{ secrets.MAPBOX_API_KEY }} mbview --port 9000 outputs/*.mbtiles & + sleep 10 + - name: Screenshot rendered tile + uses: swinton/screenshot-website@v1.x + with: + source: http://localhost:9000 + destination: ouputs/${{ matrix.style }}-${{ needs.build-and-deploy.outputs.version }}.png + full-page: true - name: Upload mbtiles artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: mbtiles-${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} - path: outputs/*.mbtiles + name: mbtiles-${{ needs.build-and-deploy.outputs.version }} + path: outputs/*.{mbtiles,png} if-no-files-found: error # 'warn' or 'ignore' are also available, 'error' will fail the step retention-days: ${{ github.event_name == 'release' && 90 || 15 }} diff --git a/package.json b/package.json index ab0e3c9..babcaed 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,7 @@ }, "lint-staged": { "src/**/*.{js,jsx,ts,tsx,json,css}": [ - "prettier --write ./src", - "git add" + "prettier --write ./src" ] }, "repository": "https://github.com/conservationmetrics/mapgl-tile-renderer",