From dd0a8fe143b5c778c17c92496de513ae066dc04f Mon Sep 17 00:00:00 2001 From: Andrew Harvey Date: Thu, 27 May 2021 15:59:07 +1000 Subject: test upload to API dev server --- .gitlab-ci.yml | 21 ++++++++++++++++++++- bin/upload.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100755 bin/upload.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b528229..1663c93 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,8 @@ stages: - prepare - build - conflate + - candidate + - upload docker prepare: image: docker:latest @@ -188,13 +190,30 @@ candidate: - yarn install - cp src/polygon-lookup-patch.js node_modules/polygon-lookup/index.js - make dist/candidate - - make testUploadCandidates when: manual artifacts: name: "candidate" paths: - dist +upload dev: + stage: upload + image: "registry.gitlab.com/alantgeo/vicmap2osm:candidate" + before_script: + - ls data dist + cache: + <<: *global_cache + policy: pull + script: + - yarn install + - cp src/polygon-lookup-patch.js node_modules/polygon-lookup/index.js + - ./bin/upload.sh + when: manual + artifacts: + name: "upload" + paths: + - uploadLog + build compareSuburb: stage: build image: "registry.gitlab.com/alantgeo/vicmap2osm:build-osm" diff --git a/bin/upload.sh b/bin/upload.sh new file mode 100755 index 0000000..2971026 --- /dev/null +++ b/bin/upload.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +set -e + +mkdir -p uploadLog + +IMPORT_DOC="https://wiki.openstreetmap.org/wiki/Imports/Vicmap_Address" + +i=0 +totalFiles=`ls -1 dist/candidates/newAddressWithoutConflicts/*.osm | wc -l` +for f in dist/candidates/newAddressWithoutConflicts/*.osm; do + i=$(($i + 1)) + + layerMessage="adding new addresses not found in OSM" + d=`dirname "$f"` + b=`basename "$f" .osm` + id=`echo "$b" | cut -d'_' -f1` + name=`echo "$b" | cut -d'_' -f2` + + echo "$i/$totalFiles $id: $name" + + echo " to osc" + ./upload/osm2change.py "$f" + + if [ ! -e "$d/$b.osc" ] ; then + echo "$d/$b.osc not found" + echo '$f' >> uploadLog/oscNotFound.txt + else + echo " upload" + ./upload/upload.py \ + -u 'vicmap_import' \ + -p "${OSM_DEV_PASSWORD}" \ + -c yes \ + -m "Vicmap Import $layerMessage: $name. See $IMPORT_DOC" \ + -y 'Vicmap Address' \ + "$d/$b.osc" + echo "$f" >> uploadLog/uploaded.txt + fi + + # give the api a rest + sleep 1s + + # stop after first, used during testing + exit +done -- cgit v1.2.3