From 46cadf6e943bf8ec4019994e94654f86b8af59e5 Mon Sep 17 00:00:00 2001 From: David Canas Date: Fri, 1 Nov 2019 16:45:36 -0700 Subject: [PATCH 01/14] First attempt at adding dedicated build pipeline --- .buildkite/pipeline.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .buildkite/pipeline.yaml diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml new file mode 100644 index 00000000..ef54d552 --- /dev/null +++ b/.buildkite/pipeline.yaml @@ -0,0 +1,14 @@ +steps: + - block: "Build :android:?" + # TODO make this independantly triggerable + # Only block when build is triggered by another build + # - if: build.source == "trigger_job" + - label: "Downloading Kolibri WHL File" + commands: + - "mkdir whl" + - "buildkite-agent artifact download 'dist/*.whl' whl/ --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID}" + - label: "Building the APK" + command: + - "make rundocker" + - label: "Upload Artifact" + command: buildkite-agent artifact upload '*-release.apk' \ No newline at end of file From 23ed35d648ccaba561f51b7d06fbcf39362cc774 Mon Sep 17 00:00:00 2001 From: David Canas Date: Sat, 2 Nov 2019 12:14:21 -0700 Subject: [PATCH 02/14] Removing block step to see if build will continue. --- .buildkite/pipeline.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index ef54d552..32266afb 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -1,5 +1,5 @@ steps: - - block: "Build :android:?" + # - block: "Build :android:?" # TODO make this independantly triggerable # Only block when build is triggered by another build # - if: build.source == "trigger_job" From 063436357197d4de0ec17b86bc52df195ee86ae8 Mon Sep 17 00:00:00 2001 From: David Canas Date: Sat, 2 Nov 2019 12:27:47 -0700 Subject: [PATCH 03/14] Making first few steps synchronous Adding means for building without trigger --- .buildkite/build.sh | 23 +++++++++++++++++++++++ .buildkite/pipeline.yaml | 11 ++--------- 2 files changed, 25 insertions(+), 9 deletions(-) create mode 100755 .buildkite/build.sh diff --git a/.buildkite/build.sh b/.buildkite/build.sh new file mode 100755 index 00000000..32ec6a44 --- /dev/null +++ b/.buildkite/build.sh @@ -0,0 +1,23 @@ +#! /bin/bash +set -euo pipefail + +mkdir -p whl + +echo "--- Downloading whl file" + +# Allows for building directly from pipeline or trigger +if [[ $BUILDKITE_TRIGGERED_FROM_BUILD_ID ]] +then + echo "Downloading from triggered build" + buildkite-agent artifact download 'dist/*.whl' whl/ --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID} +else + echo "Downloading from pip" + pip download -d ./whl kolibri +fi + +echo "--- :android: Build APK" +make run_docker + +echo "--- :gcloud: Uploading APK" +# TODO upload directly to google cloud +buildkite-agent artifact upload '*-release.apk' \ No newline at end of file diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index 32266afb..d568a778 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -3,12 +3,5 @@ steps: # TODO make this independantly triggerable # Only block when build is triggered by another build # - if: build.source == "trigger_job" - - label: "Downloading Kolibri WHL File" - commands: - - "mkdir whl" - - "buildkite-agent artifact download 'dist/*.whl' whl/ --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID}" - - label: "Building the APK" - command: - - "make rundocker" - - label: "Upload Artifact" - command: buildkite-agent artifact upload '*-release.apk' \ No newline at end of file + - label: "Dev Build APK" + command: ".buildkite/build.sh" \ No newline at end of file From f4b76499afd1bca19f71103a61bf8f5aaab1c14f Mon Sep 17 00:00:00 2001 From: David Canas Date: Mon, 4 Nov 2019 19:30:29 -0800 Subject: [PATCH 04/14] Fixing asset uploading --- .buildkite/build.sh | 4 ++-- .buildkite/pipeline.yaml | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.buildkite/build.sh b/.buildkite/build.sh index 32ec6a44..4734837f 100755 --- a/.buildkite/build.sh +++ b/.buildkite/build.sh @@ -19,5 +19,5 @@ echo "--- :android: Build APK" make run_docker echo "--- :gcloud: Uploading APK" -# TODO upload directly to google cloud -buildkite-agent artifact upload '*-release.apk' \ No newline at end of file + +# TODO upload directly to google cloud \ No newline at end of file diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index d568a778..159a1506 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -4,4 +4,8 @@ steps: # Only block when build is triggered by another build # - if: build.source == "trigger_job" - label: "Dev Build APK" - command: ".buildkite/build.sh" \ No newline at end of file + command: ".buildkite/build.sh" + + # Automatically uploads from this directory when step completes + artifact_paths: + - "dist/android/*release.apk" \ No newline at end of file From e64bed56c47b84ec49ad78c9b977d01b01b94ddb Mon Sep 17 00:00:00 2001 From: David Canas Date: Thu, 7 Nov 2019 22:57:02 -0800 Subject: [PATCH 05/14] Fixing buildkite agent download syntax --- .buildkite/build.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.buildkite/build.sh b/.buildkite/build.sh index 4734837f..ceffcc6e 100755 --- a/.buildkite/build.sh +++ b/.buildkite/build.sh @@ -9,7 +9,8 @@ echo "--- Downloading whl file" if [[ $BUILDKITE_TRIGGERED_FROM_BUILD_ID ]] then echo "Downloading from triggered build" - buildkite-agent artifact download 'dist/*.whl' whl/ --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID} + buildkite-agent artifact download 'dist/*.whl' --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID} + mv dist whl else echo "Downloading from pip" pip download -d ./whl kolibri @@ -18,6 +19,4 @@ fi echo "--- :android: Build APK" make run_docker -echo "--- :gcloud: Uploading APK" - # TODO upload directly to google cloud \ No newline at end of file From 5a23dd616df55815f9d31ca177738305ca9a00dc Mon Sep 17 00:00:00 2001 From: David Canas Date: Wed, 13 Nov 2019 19:30:30 -0800 Subject: [PATCH 06/14] Correcting buildkite download syntax --- .buildkite/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.buildkite/build.sh b/.buildkite/build.sh index ceffcc6e..b4104be3 100755 --- a/.buildkite/build.sh +++ b/.buildkite/build.sh @@ -9,8 +9,8 @@ echo "--- Downloading whl file" if [[ $BUILDKITE_TRIGGERED_FROM_BUILD_ID ]] then echo "Downloading from triggered build" - buildkite-agent artifact download 'dist/*.whl' --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID} - mv dist whl + buildkite-agent artifact download 'dist/*.whl' . --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID} + mv dist/* whl else echo "Downloading from pip" pip download -d ./whl kolibri From ec4313bdfc21dc6ddf75678fc7300952fc7c9305 Mon Sep 17 00:00:00 2001 From: David Canas Date: Thu, 19 Dec 2019 09:48:23 -0800 Subject: [PATCH 07/14] Adding blockstep by default --- .buildkite/build.sh | 2 +- .buildkite/pipeline.yaml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.buildkite/build.sh b/.buildkite/build.sh index b4104be3..1dd95534 100755 --- a/.buildkite/build.sh +++ b/.buildkite/build.sh @@ -6,7 +6,7 @@ mkdir -p whl echo "--- Downloading whl file" # Allows for building directly from pipeline or trigger -if [[ $BUILDKITE_TRIGGERED_FROM_BUILD_ID ]] +if [[ $LE_TRIGGERED_FROM_BUILD_ID ]] then echo "Downloading from triggered build" buildkite-agent artifact download 'dist/*.whl' . --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID} diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index 159a1506..7042d119 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -1,8 +1,9 @@ steps: - # - block: "Build :android:?" + - block: "Build :android:?" + - if: build.source == "trigger_job" + # TODO make this independantly triggerable # Only block when build is triggered by another build - # - if: build.source == "trigger_job" - label: "Dev Build APK" command: ".buildkite/build.sh" From e3c4f80ea759d7dec86c3930733cd8ecea285711 Mon Sep 17 00:00:00 2001 From: David Canas Date: Thu, 19 Dec 2019 12:14:56 -0800 Subject: [PATCH 08/14] Stop automatic artifact search --- .buildkite/pipeline.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index 7042d119..ae749d2c 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -6,7 +6,3 @@ steps: # Only block when build is triggered by another build - label: "Dev Build APK" command: ".buildkite/build.sh" - - # Automatically uploads from this directory when step completes - artifact_paths: - - "dist/android/*release.apk" \ No newline at end of file From 13d50ca2843a7f054ec324c9cba05f6eb98f4f13 Mon Sep 17 00:00:00 2001 From: David Canas Date: Thu, 19 Dec 2019 12:19:38 -0800 Subject: [PATCH 09/14] Removing dist folder after downloaded. --- .buildkite/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.buildkite/build.sh b/.buildkite/build.sh index 1dd95534..63fae23c 100755 --- a/.buildkite/build.sh +++ b/.buildkite/build.sh @@ -10,7 +10,8 @@ if [[ $LE_TRIGGERED_FROM_BUILD_ID ]] then echo "Downloading from triggered build" buildkite-agent artifact download 'dist/*.whl' . --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID} - mv dist/* whl + mv dist/* whl/ + rm -r dist else echo "Downloading from pip" pip download -d ./whl kolibri From 0d5a864daedae9bae41085471727937f9a77fe4d Mon Sep 17 00:00:00 2001 From: David Canas Date: Fri, 20 Dec 2019 15:27:57 -0800 Subject: [PATCH 10/14] Revert "Adding blockstep by default" This reverts commit e63210da021df34f97336cb2db933f798429cfdb. --- .buildkite/build.sh | 2 +- .buildkite/pipeline.yaml | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.buildkite/build.sh b/.buildkite/build.sh index 63fae23c..441662da 100755 --- a/.buildkite/build.sh +++ b/.buildkite/build.sh @@ -6,7 +6,7 @@ mkdir -p whl echo "--- Downloading whl file" # Allows for building directly from pipeline or trigger -if [[ $LE_TRIGGERED_FROM_BUILD_ID ]] +if [[ $BUILDKITE_TRIGGERED_FROM_BUILD_ID ]] then echo "Downloading from triggered build" buildkite-agent artifact download 'dist/*.whl' . --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID} diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index ae749d2c..35eed915 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -1,8 +1,7 @@ steps: - - block: "Build :android:?" - - if: build.source == "trigger_job" - + # - block: "Build :android:?" # TODO make this independantly triggerable # Only block when build is triggered by another build + # - if: build.source == "trigger_job" - label: "Dev Build APK" command: ".buildkite/build.sh" From ed879e202a35978430582467cfa8538bc650d89b Mon Sep 17 00:00:00 2001 From: David Canas Date: Fri, 20 Dec 2019 16:10:31 -0800 Subject: [PATCH 11/14] Explicitly uploading to current step. --- .buildkite/build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.buildkite/build.sh b/.buildkite/build.sh index 441662da..3e6be78f 100755 --- a/.buildkite/build.sh +++ b/.buildkite/build.sh @@ -20,4 +20,7 @@ fi echo "--- :android: Build APK" make run_docker -# TODO upload directly to google cloud \ No newline at end of file +# Making folder structure match other installers (convention) +mv ./dist/android/*.apk ./dist + +buildkite-agent artifact upload dist/*-release.apk \ No newline at end of file From 3ae2e89e38b34198b455d30afd0bde4e8ec88cae Mon Sep 17 00:00:00 2001 From: David Canas Date: Fri, 20 Dec 2019 18:33:02 -0800 Subject: [PATCH 12/14] Changing job label to include the word "android" --- .buildkite/pipeline.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index 35eed915..b0a63bff 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -3,5 +3,5 @@ steps: # TODO make this independantly triggerable # Only block when build is triggered by another build # - if: build.source == "trigger_job" - - label: "Dev Build APK" + - label: "Build Android App" command: ".buildkite/build.sh" From e94747029735898c054da4eb30b192c7d4891d12 Mon Sep 17 00:00:00 2001 From: David Canas Date: Fri, 20 Dec 2019 18:55:56 -0800 Subject: [PATCH 13/14] Switching to container ID for container reference Rather than container name. Makes concurrency easier. --- scripts/rundocker.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/rundocker.sh b/scripts/rundocker.sh index e8f59238..7bc698bb 100755 --- a/scripts/rundocker.sh +++ b/scripts/rundocker.sh @@ -1,11 +1,9 @@ #!/bin/bash CONTAINER_HOME=/home/kivy -CONTAINER_NAME=android_container # create the container to be used throughout the script -echo -ne "Creating container ${CONTAINER_NAME} \n\t id: " -docker create -it --name ${CONTAINER_NAME} \ +CONTAINER_ID=$(docker create -it --name ${CONTAINER_ID} \ --mount type=bind,src=${PWD}/whl,dst=${CONTAINER_HOME}/whl \ --mount type=bind,src=${PWD}/src,dst=${CONTAINER_HOME}/src \ --mount type=bind,src=${PWD}/scripts,dst=${CONTAINER_HOME}/scripts \ @@ -16,26 +14,28 @@ docker create -it --name ${CONTAINER_NAME} \ --env P4A_RELEASE_KEYALIAS \ --env P4A_RELEASE_KEYSTORE_PASSWD \ --env P4A_RELEASE_KEYALIAS_PASSWD \ - android_kolibri + android_kolibri) + +echo -ne "Creating container ${CONTAINER_ID} \n\t id: " # make sure the environment variable is defined if [ "${P4A_RELEASE_KEYSTORE}" ]; then # make sure the directory is valid if [ -a ${P4A_RELEASE_KEYSTORE} ]; then - echo -e "Copying the signing key \n\t From ${P4A_RELEASE_KEYSTORE} to ${CONTAINER_NAME}:${CONTAINER_HOME}" + echo -e "Copying the signing key \n\t From ${P4A_RELEASE_KEYSTORE} to ${CONTAINER_ID}:${CONTAINER_HOME}" # copy keystore to same location on the container - docker cp ${P4A_RELEASE_KEYSTORE} ${CONTAINER_NAME}:${CONTAINER_HOME} + docker cp ${P4A_RELEASE_KEYSTORE} ${CONTAINER_ID}:${CONTAINER_HOME} fi fi # run the container, generating the apk -echo "Starting ${CONTAINER_NAME}" -docker start -i ${CONTAINER_NAME} +echo "Starting ${CONTAINER_ID}" +docker start -i ${CONTAINER_ID} # copy the apk to our host. Handles permissions. -echo -e "Coping APK \n\t From ${CONTAINER_NAME}:${CONTAINER_HOME}/dist/ to ${PWD}" -docker cp ${CONTAINER_NAME}:${CONTAINER_HOME}/dist/ . +echo -e "Coping APK \n\t From ${CONTAINER_ID}:${CONTAINER_HOME}/dist/ to ${PWD}" +docker cp ${CONTAINER_ID}:${CONTAINER_HOME}/dist/ . # manually remove the container afterward echo -n "Removing " -docker rm ${CONTAINER_NAME} +docker rm ${CONTAINER_ID} From dd7b37d03f3977bc71486a8a15fd00c438b390dd Mon Sep 17 00:00:00 2001 From: David Canas Date: Fri, 20 Dec 2019 19:02:51 -0800 Subject: [PATCH 14/14] Switching to manually defined build triggers. Uploading to parent job. --- .buildkite/build.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.buildkite/build.sh b/.buildkite/build.sh index 3e6be78f..ef0f3c0d 100755 --- a/.buildkite/build.sh +++ b/.buildkite/build.sh @@ -1,12 +1,12 @@ #! /bin/bash -set -euo pipefail +set -eo pipefail mkdir -p whl echo "--- Downloading whl file" # Allows for building directly from pipeline or trigger -if [[ $BUILDKITE_TRIGGERED_FROM_BUILD_ID ]] +if [[ $LE_TRIGGERED_FROM_BUILD_ID ]] then echo "Downloading from triggered build" buildkite-agent artifact download 'dist/*.whl' . --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID} @@ -23,4 +23,11 @@ make run_docker # Making folder structure match other installers (convention) mv ./dist/android/*.apk ./dist +if [[ $LE_TRIGGERED_FROM_JOB_ID && $BUILDKITE_TRIGGERED_FROM_BUILD_ID ]] +then + echo "--- Uploading artifact to parent job" + buildkite-agent artifact upload dist/*-release.apk --job $LE_TRIGGERED_FROM_JOB_ID +fi + +echo "--- Uploading artifact" buildkite-agent artifact upload dist/*-release.apk \ No newline at end of file