Skip to content

Commit

Permalink
Merge pull request #5 from osmus/lint
Browse files Browse the repository at this point in the history
Add linting action
  • Loading branch information
quincylvania authored May 22, 2024
2 parents 79d3622 + 46bd08d commit 7d1e4d5
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 114 deletions.
12 changes: 12 additions & 0 deletions .github/linters/.yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
extends: default
rules:
indentation:
spaces: 2
indent-sequences: whatever
line-length: disable
new-line-at-end-of-file:
level: warning
trailing-spaces:
level: warning
truthy: disable
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Lint
on:
- push
- pull_request
permissions: {}
jobs:
build:
name: Lint
runs-on: ubuntu-latest

permissions:
contents: read
packages: read
# To report GitHub Actions status checks
statuses: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# super-linter needs the full git history to get the
# list of files that changed across commits
fetch-depth: 0

- name: Super-linter
uses: super-linter/[email protected] # x-release-please-version
env:
# To report GitHub Actions status checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_JSCPD: false
VALIDATE_NATURAL_LANGUAGE: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# osmus/tileservice
Central repo for the OSM US vector tile service
Central repository for the OSM US vector tile service
14 changes: 7 additions & 7 deletions renderer/_example.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ LOCKFILE="/tmp/planet-render.lock"

# Check if lock file exists
if [ -e "${LOCKFILE}" ]; then
echo "A rendering process is already running."
exit 1
echo "A rendering process is already running."
exit 1
else
# Create a lock file
touch "${LOCKFILE}"
# Create a lock file
touch "${LOCKFILE}"

# Ensure the lock file is removed when we exit and when we receive signals
trap "rm -f ${LOCKFILE}; trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
# Ensure the lock file is removed when we exit and when we receive signals
trap 'rm -f ${LOCKFILE}; trap - SIGTERM && kill -- -$$' SIGINT SIGTERM EXIT
fi

# The local path to the tileservice repo
Expand All @@ -32,4 +32,4 @@ mkdir "$REPO_DIR"
git clone https://github.com/osmus/tileservice.git "$REPO_DIR"

# Start the render, assuming the directory format hasn't changed
"$REPO_DIR/renderer/render.sh"
"$REPO_DIR/renderer/render.sh"
2 changes: 1 addition & 1 deletion renderer/layers/trails.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
schema_name: OSM US Trails
schema_description: A map of trails
attribution: <a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>
Expand Down Expand Up @@ -296,4 +297,3 @@ args:
area:
description: Geofabrik area to download
default: rhode-island

2 changes: 1 addition & 1 deletion renderer/layers/water_trails.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
schema_name: OSM US Water Trails
schema_description: Canoe and kayak waterways and portages.
attribution: <a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>
Expand Down Expand Up @@ -229,4 +230,3 @@ args:
area:
description: Geofabrik area to download
default: rhode-island

4 changes: 2 additions & 2 deletions renderer/layers/water_trails_poi.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
schema_name: OSM US Water Trail POIs
schema_description: Slipways, access points, dams, weirs, and waterfalls.
schema_description: Slipways, access points, dams, weirs, and waterfalls.
attribution: <a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>
sources:
osm:
Expand Down Expand Up @@ -100,4 +101,3 @@ args:
area:
description: Geofabrik area to download
default: rhode-island

2 changes: 1 addition & 1 deletion renderer/render.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Get the directory of the current script
DIR="$(dirname "$0")"

"$DIR/render_seashells.sh" $1
"$DIR/render_seashells.sh" "$1"
79 changes: 41 additions & 38 deletions renderer/render_once.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,60 +26,63 @@ docker system prune --force
docker pull ghcr.io/onthegomap/planetiler:latest

docker run -e JAVA_TOOL_OPTIONS='-Xmx2g' \
-v "$WORKING_DIR/data":/data \
-v "$DIR/layers":/layers \
ghcr.io/onthegomap/planetiler:latest --area=planet \
--download --download-only --only-fetch-wikidata
-v "$WORKING_DIR/data":/data \
-v "$DIR/layers":/layers \
ghcr.io/onthegomap/planetiler:latest --area=planet \
--download --download-only --only-fetch-wikidata

# Remove default downloaded OSM file
rm -rf "$WORKING_DIR/data/sources/monaco.osm.pbf"

PLANET="$WORKING_DIR/data/planet.pmtiles"

docker run -e JAVA_TOOL_OPTIONS='-Xmx150g' \
-v "$WORKING_DIR/data":/data \
-v "$DIR/layers":/layers \
ghcr.io/onthegomap/planetiler:latest --area=planet --bounds=world \
--output="/data/planet.pmtiles" \
--transportation_name_size_for_shield \
--transportation_name_limit_merge \
--boundary-osm-only \
--storage=ram --nodemap-type=array \
--max-point-buffer=4 \
--building_merge_z13=false \
--languages=ab,ace,af,als,am,an,ar,arz,as,ast,az,az-Arab,az-cyr,azb,ba,bar,bat-smg,be,be-tarask,ber,bg,bm,bn,bo,bpy,br,bs,bxr,ca,cdo,ce,ceb,cho,chr,chy,ckb,co,cr,crh,crh-cyr,crk,cs,csb,cv,cy,da,dak,de,dsb,dv,dz,ee,egl,el,en,eo,es,et,eu,fa,fi,fil,fit,fo,fr,frr,full,fur,fy,ga,gag,gan,gcf,gd,gl,gn,gr,grc,gsw,gu,gv,ha,hak,hak-HJ,haw,he,hi,hif,hr,hsb,ht,hu,hur,hy,ia,id,ie,ilo,int,io,is,it,iu,ja,ja_kana,ja_rm,ja-Hira,ja-Latn,jv,ka,kab,kbd,ki,kk,kk-Arab,kl,km,kn,ko,ko-Hani,ko-Latn,krc,krl,ks,ku,kv,kw,ky,la,lb,left,lez,li,lij,lld,lmo,ln,lo,lrc,lt,lv,lzh,md,mdf,mez,mg,mhr,mi,mia,mk,ml,mn,mo,moh,mr,mrj,ms,ms-Arab,mt,mwl,my,myv,mzn,nah,nan,nan-HJ,nan-POJ,nan-TL,nds,ne,nl,nn,no,nov,nv,oc,oj,old,or,os,ota,pa,pam,pcd,pfl,pl,pms,pnb,pot,ps,pt,pt-BR,pt-PT,qu,right,rm,ro,ru,rue,rw,sah,sat,sc,scn,sco,sd,se,sh,si,sju,sk,sl,sma,smj,so,sq,sr,sr-Latn,su,sv,sw,syc,szl,ta,te,TEC,tg,th,th-Latn,ti,tk,tl,tr,tt,tt-lat,udm,ug,uk,ur,uz,uz-Arab,uz-cyr,uz-Cyrl,uz-Latn,vec,vi,vls,vo,wa,war,win,wiy,wo,wuu,xmf,yi,yo,yue,yue-Hant,yue-Latn,za,zgh,zh,zh_pinyin,zh_zhuyin,zh-Hans,zh-Hant,zh-Latn-pinyin,zu,zza
-v "$WORKING_DIR/data":/data \
-v "$DIR/layers":/layers \
ghcr.io/onthegomap/planetiler:latest --area=planet --bounds=world \
--output="/data/planet.pmtiles" \
--transportation_name_size_for_shield \
--transportation_name_limit_merge \
--boundary-osm-only \
--storage=ram --nodemap-type=array \
--max-point-buffer=4 \
--building_merge_z13=false \
--languages=ab,ace,af,als,am,an,ar,arz,as,ast,az,az-Arab,az-cyr,azb,ba,bar,bat-smg,be,be-tarask,ber,bg,bm,bn,bo,bpy,br,bs,bxr,ca,cdo,ce,ceb,cho,chr,chy,ckb,co,cr,crh,crh-cyr,crk,cs,csb,cv,cy,da,dak,de,dsb,dv,dz,ee,egl,el,en,eo,es,et,eu,fa,fi,fil,fit,fo,fr,frr,full,fur,fy,ga,gag,gan,gcf,gd,gl,gn,gr,grc,gsw,gu,gv,ha,hak,hak-HJ,haw,he,hi,hif,hr,hsb,ht,hu,hur,hy,ia,id,ie,ilo,int,io,is,it,iu,ja,ja_kana,ja_rm,ja-Hira,ja-Latn,jv,ka,kab,kbd,ki,kk,kk-Arab,kl,km,kn,ko,ko-Hani,ko-Latn,krc,krl,ks,ku,kv,kw,ky,la,lb,left,lez,li,lij,lld,lmo,ln,lo,lrc,lt,lv,lzh,md,mdf,mez,mg,mhr,mi,mia,mk,ml,mn,mo,moh,mr,mrj,ms,ms-Arab,mt,mwl,my,myv,mzn,nah,nan,nan-HJ,nan-POJ,nan-TL,nds,ne,nl,nn,no,nov,nv,oc,oj,old,or,os,ota,pa,pam,pcd,pfl,pl,pms,pnb,pot,ps,pt,pt-BR,pt-PT,qu,right,rm,ro,ru,rue,rw,sah,sat,sc,scn,sco,sd,se,sh,si,sju,sk,sl,sma,smj,so,sq,sr,sr-Latn,su,sv,sw,syc,szl,ta,te,TEC,tg,th,th-Latn,ti,tk,tl,tr,tt,tt-lat,udm,ug,uk,ur,uz,uz-Arab,uz-cyr,uz-Cyrl,uz-Latn,vec,vi,vls,vo,wa,war,win,wiy,wo,wuu,xmf,yi,yo,yue,yue-Hant,yue-Latn,za,zgh,zh,zh_pinyin,zh_zhuyin,zh-Hans,zh-Hant,zh-Latn-pinyin,zu,zza

# Check if the file exists and is at least 50GB
if [[ ! -f "$PLANET" ]]; then
echo "Error: File $PLANET does not exist."
exit 1
elif [[ $(stat -c %s "$PLANET") -lt $((50*1024*1024*1024)) ]]; then
echo "Error: File $PLANET is smaller than 50GB."
exit 1
echo "Error: File $PLANET does not exist."
exit 1
elif [[ $(stat -c %s "$PLANET") -lt $((50 * 1024 * 1024 * 1024)) ]]; then
echo "Error: File $PLANET is smaller than 50GB."
exit 1
fi

echo 'Uploading planet to s3 bucket in background'
aws s3 cp "$PLANET" s3://planet-pmtiles/ --only-show-errors &

# Render optional layers
for file in "$DIR/layers/"*.yml; do
# Get the base name of the file without the .yml extension
layer_name=$(basename "$file" .yml)

echo "Processing layer: $layer_name"

docker run -e JAVA_TOOL_OPTIONS='-Xmx24g' \
-v "$WORKING_DIR/data":/data \
-v "$DIR/layers":/layers \
ghcr.io/onthegomap/planetiler:latest generate-custom \
--area=planet --bounds=world \
--output="/data/$layer_name.pmtiles" \
--schema="/layers/$layer_name.yml" \
--storage=mmap --nodemap-type=array \
--max-point-buffer=4

echo "Uploading $layer_name to s3 bucket in background"
{ aws s3 cp "$WORKING_DIR/data/$layer_name.pmtiles" s3://planet-pmtiles/ --only-show-errors; rm -rf "$WORKING_DIR/data/$layer_name.pmtiles"; } &
# Get the base name of the file without the .yml extension
layer_name=$(basename "$file" .yml)

echo "Processing layer: $layer_name"

docker run -e JAVA_TOOL_OPTIONS='-Xmx24g' \
-v "$WORKING_DIR/data":/data \
-v "$DIR/layers":/layers \
ghcr.io/onthegomap/planetiler:latest generate-custom \
--area=planet --bounds=world \
--output="/data/$layer_name.pmtiles" \
--schema="/layers/$layer_name.yml" \
--storage=mmap --nodemap-type=array \
--max-point-buffer=4

echo "Uploading $layer_name to s3 bucket in background"
{
aws s3 cp "$WORKING_DIR/data/$layer_name.pmtiles" s3://planet-pmtiles/ --only-show-errors
rm -rf "$WORKING_DIR/data/$layer_name.pmtiles"
} &
done

echo 'Waiting for all background jobs to finish'
Expand All @@ -89,4 +92,4 @@ echo 'Invalidating the CDN cache'
aws cloudfront create-invalidation --distribution-id E1E7N0LWX2WY4E --invalidation-batch "{\"Paths\": {\"Quantity\": 1, \"Items\": [\"/*\"]}, \"CallerReference\": \"invalidation-$DATE\"}"

echo 'Render Complete'
date -u '+%Y-%m-%d %H:%M:%S'
date -u '+%Y-%m-%d %H:%M:%S'
83 changes: 41 additions & 42 deletions renderer/render_seashells.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,58 @@ LOG_TIMESTAMP=$(date +%Y%m%d%H%M%S)
LOG_FILE="/var/log/render/logs_$LOG_TIMESTAMP.txt"

touch "$LOG_FILE"
tail -f "$LOG_FILE" | nc seashells.io 1337 > /tmp/seashells_render & sleep 10
tail -f "$LOG_FILE" | nc seashells.io 1337 >/tmp/seashells_render &
sleep 10

# Get the size of the file in bytes
OSM_PLANET_SIZE=$(stat -c%s "$WORKING_DIR/data/sources/planet.osm.pbf")

# Print the size with comma separators
OSM_PLANET_SIZE=$(printf "%'d" $OSM_PLANET_SIZE)
OSM_PLANET_SIZE=$(printf "%'d" "$OSM_PLANET_SIZE")

RSS_FILE="$WORKING_DIR/rss.xml"
PLANET="$WORKING_DIR/data/planet.pmtiles"

"$DIR/rss_update.sh" "$RSS_FILE" "Build Started." "The OSM planet file is ${OSM_PLANET_SIZE} bytes."

run() {
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
START_TIME=$(date +%s)
"$DIR/render_once.sh" "$WORKING_DIR"

# Check the exit status of render_once.sh
if [ $? -eq 0 ]; then
# Record the end time
END_TIME=$(date +%s)

# Calculate the time difference
TIME_DIFF=$((END_TIME - START_TIME))

# Convert the time difference to hours and minutes
HOURS=$((TIME_DIFF / 3600))
MINUTES=$(((TIME_DIFF / 60) % 60))

# Format hours and minutes with singular or plural as appropriate
HOUR_TEXT="hours"
MINUTE_TEXT="minutes"
if [ "$HOURS" -eq 1 ]; then
HOUR_TEXT="hour"
fi
if [ "$MINUTES" -eq 1 ]; then
MINUTE_TEXT="minute"
fi

# Get the size of the file in bytes
PMTILES_PLANET_SIZE=$(stat -c%s "$PLANET")

# Print the size with comma separators
PMTILES_PLANET_SIZE=$(printf "%'d" $PMTILES_PLANET_SIZE)

"$DIR/rss_update.sh" "$RSS_FILE" "Build Complete" "Tiles are up to date as of ${TIMESTAMP}Z. Render took ${HOURS} ${HOUR_TEXT} and ${MINUTES} ${MINUTE_TEXT}. The planet PMTiles file is ${PMTILES_PLANET_SIZE} bytes."
else
"$DIR/rss_update.sh" "$RSS_FILE" "Build Failed" "Review the build log to find out why."
fi

echo 'Removing local planet file'
rm -rf "$PLANET"
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
START_TIME=$(date +%s)

if "$DIR/render_once.sh" "$WORKING_DIR"; then
# Record the end time
END_TIME=$(date +%s)

# Calculate the time difference
TIME_DIFF=$((END_TIME - START_TIME))

# Convert the time difference to hours and minutes
HOURS=$((TIME_DIFF / 3600))
MINUTES=$(((TIME_DIFF / 60) % 60))

# Format hours and minutes with singular or plural as appropriate
HOUR_TEXT="hours"
MINUTE_TEXT="minutes"
if [ "$HOURS" -eq 1 ]; then
HOUR_TEXT="hour"
fi
if [ "$MINUTES" -eq 1 ]; then
MINUTE_TEXT="minute"
fi

# Get the size of the file in bytes
PMTILES_PLANET_SIZE=$(stat -c%s "$PLANET")

# Print the size with comma separators
PMTILES_PLANET_SIZE=$(printf "%'d" "$PMTILES_PLANET_SIZE")

"$DIR/rss_update.sh" "$RSS_FILE" "Build Complete" "Tiles are up to date as of ${TIMESTAMP}Z. Render took ${HOURS} ${HOUR_TEXT} and ${MINUTES} ${MINUTE_TEXT}. The planet PMTiles file is ${PMTILES_PLANET_SIZE} bytes."
else
"$DIR/rss_update.sh" "$RSS_FILE" "Build Failed" "Review the build log to find out why."
fi

echo 'Removing local planet file'
rm -rf "$PLANET"
}

run 2>&1 | tee -a "$LOG_FILE"
run 2>&1 | tee -a "$LOG_FILE"
Loading

0 comments on commit 7d1e4d5

Please sign in to comment.