summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkoan <jkoan@users.noreply.github.com>2018-02-13 08:25:04 +0100
committerGitHub <noreply@github.com>2018-02-13 08:25:04 +0100
commit0046dd08c3ed2ec7c176fdb44c922962fe6c8ecc (patch)
tree301594d76b741173a8265c0d1a179c1548405c4a
parent868b43dc4aba9e621420abab8a46f41e0af7c567 (diff)
downloadnavit-0046dd08c3ed2ec7c176fdb44c922962fe6c8ecc.tar.gz
add:build:Add download center (#405)
* Merge * Update Linux build to also build Artifacts * Okay okay, circleci does not like regex :D * futher work in the download center * Update Script * Change UUID to some fake * Next Test * Fix git? * Add SSH Key to known hosts * Add ssh for win build images * Add retry if the repo was modifyed in the time between pull and push This could happen if two builds finished exactly at the same time like here: https://circleci.com/gh/jkoan/navit/821 * Add Files in different dirs * Update script * Add another message * Only store really needed things for linux * Update update_download_center.sh * Update update_download_center.sh * Update config.yml
-rw-r--r--.circleci/config.yml31
-rw-r--r--ci/build_linux.sh2
-rw-r--r--ci/setup_common_requirements.sh2
-rw-r--r--ci/update_download_center.sh106
4 files changed, 139 insertions, 2 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index f4c9956d8..fbde5d317 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -16,6 +16,12 @@ jobs:
- run:
name: Build for Linux
command: bash ci/build_linux.sh
+ - store_artifacts:
+ path: linux/_CPack_Packages
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash ci/update_download_center.sh
run_doxygen:
<<: *defaults
steps:
@@ -49,6 +55,10 @@ jobs:
bash ci/build_android.sh
- store_artifacts:
path: android-arm/navit/android/bin
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash ci/update_download_center.sh
build_android_x86:
<<: *defaults
steps:
@@ -67,6 +77,10 @@ jobs:
bash ci/build_android_x86.sh
- store_artifacts:
path: android-x86/navit/android/bin
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash ci/update_download_center.sh
build_win32:
<<: *defaults
steps:
@@ -78,6 +92,10 @@ jobs:
bash ci/build_win32.sh
- store_artifacts:
path: win32/navit.exe
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash ci/update_download_center.sh
build_wince:
docker:
- image: navit/wince:8.04
@@ -88,6 +106,10 @@ jobs:
command: bash ci/build_wince.sh
- store_artifacts:
path: wince/output
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash ci/update_download_center.sh
build_tomtom_minimal:
<<: *defaults
docker:
@@ -104,6 +126,10 @@ jobs:
bash ci/build_tomtom_minimal.sh
- store_artifacts:
path: /output
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash ci/update_download_center.sh
build_tomtom_plugin:
<<: *defaults
docker:
@@ -120,7 +146,10 @@ jobs:
bash ci/build_tomtom_plugin.sh
- store_artifacts:
path: /output
-
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash ci/update_download_center.sh
workflows:
version: 2
doxygen:
diff --git a/ci/build_linux.sh b/ci/build_linux.sh
index dd3846710..483128558 100644
--- a/ci/build_linux.sh
+++ b/ci/build_linux.sh
@@ -17,6 +17,7 @@ if [[ "${CIRCLE_PROJECT_USERNAME}" == "navit-gps" && "${CIRCLE_BRANCH}" == "trun
cov-build --dir cov-int cmake ${cmake_opts} ../
cov-build --dir cov-int make -j $(nproc --all) || exit -1
+ cov-build --dir cov-int make -j $(nproc --all) package || exit -1
tar czvf navit.tgz cov-int
curl --form token=$COVERITY_TOKEN \
@@ -34,6 +35,7 @@ if [[ "${CIRCLE_PROJECT_USERNAME}" == "navit-gps" && "${CIRCLE_BRANCH}" == "trun
else
cmake ${cmake_opts} ../ || exit -1
make -j $(nproc --all) || exit -1
+ make package || exit -1
fi
if [[ "$CIRCLE_ARTIFACTS" != "" ]]; then
diff --git a/ci/setup_common_requirements.sh b/ci/setup_common_requirements.sh
index 9f15dd6b1..ad60a6625 100644
--- a/ci/setup_common_requirements.sh
+++ b/ci/setup_common_requirements.sh
@@ -1 +1 @@
-apt-get update && apt-get install -y wget unzip cmake build-essential gettext imagemagick
+apt-get update && apt-get install -y wget unzip cmake build-essential gettext imagemagick util-linux git ssh
diff --git a/ci/update_download_center.sh b/ci/update_download_center.sh
new file mode 100644
index 000000000..cec11808d
--- /dev/null
+++ b/ci/update_download_center.sh
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+
+#############################################
+############# Functions #############
+#############################################
+
+cleanup(){
+ if [ -d $TMP_DIR ]; then
+ rm -rf $TMP_DIR
+ fi
+}
+
+#############################################
+############# Functions END #############
+#############################################
+
+echo "Check the requirements"
+
+if [ -z $CI ];then
+ echo "This Script needs to be run by CI"
+fi
+if [ -z $CIRCLECI ];then
+ echo "This Script needs to be run on CircleCI"
+fi
+if [[ "${CIRCLE_PROJECT_USERNAME}" != "navit-gps" && "${CIRCLE_BRANCH}" != "trunk" ]]; then
+ echo "Only trunk on navit-gps may upload to the Download Center"
+ exit 0
+fi
+
+#############################################
+
+echo "Setting up all Variables"
+
+UUID=${RANDOM}-${RANDOM}-${RANDOM}-${RANDOM}
+TMP_DIR=$(mktemp -d)
+CIRCLECI_API_BASE="https://circleci.com/api/v1.1/"
+NAVIT_DOWNLOAD_CENTER_REPO="git@github.com:navit-gps/download-center"
+
+# To keep it generic
+CVS_TYPE="github"
+REPONAME=$CIRCLE_PROJECT_REPONAME
+USERNAME=$CIRCLE_PROJECT_USERNAME
+BUILD_NUM=$CIRCLE_BUILD_NUM
+JOB_NAME=$CIRCLE_JOB
+
+# Build all api urls
+URL_BUILD_ARTIFACTS="${CIRCLECI_API_BASE}project/${CVS_TYPE}/${USERNAME}/${REPONAME}/${BUILD_NUM}/artifacts"
+echo "Artifact URL: $URL_BUILD_ARTIFACTS"
+
+#############################################
+
+echo "Setup trap for cleanup"
+trap cleanup EXIT
+
+#############################################
+
+echo "Init Git Repo"
+export GIT_TERMINAL_PROMPT=0
+cd $TMP_DIR
+mkdir -p ~/.ssh/
+ssh-keyscan github.com >> ~/.ssh/known_hosts
+git clone $NAVIT_DOWNLOAD_CENTER_REPO $UUID
+if [ ! -d $UUID/_data/$JOB_NAME ]; then
+ mkdir -p $UUID/_data/$JOB_NAME
+fi
+cd $UUID/_data/$JOB_NAME
+
+#############################################
+
+echo "Download metadata of this build"
+wget --no-check-certificate $URL_BUILD_ARTIFACTS -O ${BUILD_NUM}.json
+RC=$?
+if [ $RC -ne 0 ]; then
+ echo "wget artifacts download failed"
+ exit 1
+fi
+
+#############################################
+
+echo "Push update to ${NAVIT_DOWNLOAD_CENTER_REPO}"
+git config --global push.default simple
+git config user.name "Circle CI"
+git config user.email "circleci@navit-project.org"
+git add ${BUILD_NUM}.json
+git commit -m "add:artifacts:Add artifacts for build #${BUILD_NUM} with SHA1:${CIRCLE_SHA1}"
+git push
+RC=$?
+if [ $RC -ne 0 ]; then
+ exit 0
+else
+ echo "Push to ${NAVIT_DOWNLOAD_CENTER_REPO} was not successful update repo and try again..."
+ for NUM in {1..10}; do
+ echo "Retry #${NUM} to push to github"
+ git pull
+ git push
+ RC=$?
+ if [ $RC -eq 0 ]; then
+ exit 0
+ fi
+ sleep $(($RANDOM%5)) # sleep between 1 and 5 seconds
+ done
+fi
+
+echo "Failed to push to github"
+exit 100