From ca8f0d0b74007e042066f36631c49c8d703df48a Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Sat, 20 Jul 2019 22:59:16 +0300 Subject: [PATCH] CI: use pipe instead of separate tasks No more need to pass packages between tasks through http cache but will require a separate configuration for earch architecture. --- .cirrus.yml | 104 +++++++++++++---------- scripts/build/ci/cirrus-ci_dispatcher.sh | 66 ++------------ 2 files changed, 69 insertions(+), 101 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index f24726fa4..dd960e7ca 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,13 +1,68 @@ container: - image: termux/package-builder:latest cpu: 8 memory: 16 -# Build packages. -build_task: - # 2 hours is a maximal timeout for free use. +## +## * Maximal timeout is 120 minutes. +## * Each architecture require a separate pipe configuration. +## * Test builds (i.e. non-uploadable) are done via separate task. +## + +build_pipe_template: &BUILD_PIPE_TEMPLATE + only_if: $CIRRUS_BRANCH == 'master' + timeout_in: 120m + environment: + BINTRAY_USERNAME: xeffyr + BINTRAY_API_KEY: ENCRYPTED[c056d345d7a15f90b818dd9382129c27ce4ce2b802831ec890786414fc214c4203714c353a8fef3a6b9b1b1d68e4685e] + BINTRAY_GPG_SUBJECT: termux + BINTRAY_GPG_PASSPHRASE: ENCRYPTED[854c09c78b3318a30d3c9094b1010dfebd4c71ad9173b64479eaafaa7e941b050afaa936ad635af3709382492828316f] + + steps: + - image: termux/package-builder:latest + build_script: bash ./scripts/build/ci/cirrus-ci_dispatcher.sh + - image: termux/package-builder:latest + upload_script: bash ./scripts/build/ci/cirrus-ci_dispatcher.sh --upload + output_artifacts: + path: "./debs/*.deb" + + +pipe: + << : *BUILD_PIPE_TEMPLATE + name: Build and Upload - aarch64 + environment: + TERMUX_ARCH: aarch64 + +pipe: + << : *BUILD_PIPE_TEMPLATE + name: Build and Upload - arm + environment: + TERMUX_ARCH: arm + +pipe: + << : *BUILD_PIPE_TEMPLATE + name: Build and Upload - i686 + environment: + TERMUX_ARCH: i686 + +pipe: + << : *BUILD_PIPE_TEMPLATE + name: Build and Upload - x86_64 + environment: + TERMUX_ARCH: x86_64 + + +task: + name: Test build + + only_if: $CIRRUS_BRANCH != 'master' + + timeout_in: 120m + + container: + image: termux/package-builder:latest + environment: matrix: TERMUX_ARCH: aarch64 @@ -15,43 +70,4 @@ build_task: TERMUX_ARCH: i686 TERMUX_ARCH: x86_64 - # Do not use built-in git client provided by Cirrus as may - # cause problems when determining changed files. - clone_script: | - if [[ -z "$CIRRUS_PR" ]]; then - git clone --recursive --branch="$CIRRUS_BRANCH" "https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git" "$CIRRUS_WORKING_DIR" - git reset --hard "$CIRRUS_CHANGE_IN_REPO" - else - git clone --recursive "https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git" "$CIRRUS_WORKING_DIR" - git fetch origin "pull/$CIRRUS_PR/head:pull/$CIRRUS_PR" - git reset --hard "$CIRRUS_CHANGE_IN_REPO" - fi - - # Following script will determine changes via Git and build - # modified packages. - build_script: | - bash ./scripts/build/ci/cirrus-ci_dispatcher.sh - - # Make built packages downloadable from web UI. - output_artifacts: - path: "./debs/*.deb" - - -# Upload packages to Bintray. -# Should be done only on branch 'master'. -publish_task: - only_if: $CIRRUS_BRANCH == 'master' - - timeout_in: 60m - - depends_on: - - build - - environment: - BINTRAY_USERNAME: xeffyr - BINTRAY_API_KEY: ENCRYPTED[c056d345d7a15f90b818dd9382129c27ce4ce2b802831ec890786414fc214c4203714c353a8fef3a6b9b1b1d68e4685e] - BINTRAY_GPG_SUBJECT: termux - BINTRAY_GPG_PASSPHRASE: ENCRYPTED[854c09c78b3318a30d3c9094b1010dfebd4c71ad9173b64479eaafaa7e941b050afaa936ad635af3709382492828316f] - - upload_script: | - bash ./scripts/build/ci/cirrus-ci_dispatcher.sh --upload + build_script: bash ./scripts/build/ci/cirrus-ci_dispatcher.sh diff --git a/scripts/build/ci/cirrus-ci_dispatcher.sh b/scripts/build/ci/cirrus-ci_dispatcher.sh index 973ea5292..04243a575 100755 --- a/scripts/build/ci/cirrus-ci_dispatcher.sh +++ b/scripts/build/ci/cirrus-ci_dispatcher.sh @@ -35,14 +35,14 @@ set +e # Process tag '%ci:no-build' that may be added as line to commit message. # Will force CI to exit with status 'passed' without performing build. if grep -qiP '^\s*%ci:no-build\s*$' <(git log --format="%B" -n 1 "$CIRRUS_CHANGE_IN_REPO"); then - echo "[*] Exiting with status 'passed' (tag '%ci:no-build' applied)." + echo "[!] Exiting with status 'passed' (tag '%ci:no-build' applied)." exit 0 fi # Process tag '%ci:reset-backlog' that may be added as line to commit message. # Will force CI to build changes only for the current commit. if grep -qiP '^\s*%ci:reset-backlog\s*$' <(git log --format="%B" -n 1 "$CIRRUS_CHANGE_IN_REPO"); then - echo "[*] Building only last pushed commit (tag '%ci:reset-backlog' applied)." + echo "[!] Building only last pushed commit (tag '%ci:reset-backlog' applied)." unset CIRRUS_LAST_GREEN_CHANGE unset CIRRUS_BASE_SHA fi @@ -94,66 +94,18 @@ set -e if ! $DO_UPLOAD; then echo "[*] Building packages: $PACKAGE_NAMES" - echo if [ -n "$CIRRUS_PR" ]; then - echo " Pull request: https://github.com/termux/unstable-packages/pull/${CIRRUS_PR}" + echo "[*] Pull request: https://github.com/termux/unstable-packages/pull/${CIRRUS_PR}" else if [ -n "$CIRRUS_LAST_GREEN_CHANGE" ]; then - echo " Changes: ${CIRRUS_LAST_GREEN_CHANGE}..${CIRRUS_CHANGE_IN_REPO}" + echo "[*] Changes: ${CIRRUS_LAST_GREEN_CHANGE}..${CIRRUS_CHANGE_IN_REPO}" else - echo " Changes: ${CIRRUS_CHANGE_IN_REPO}" + echo "[*] Changes: ${CIRRUS_CHANGE_IN_REPO}" fi fi - echo - for pkg in $PACKAGE_NAMES; do - ./build-package.sh -a "$TERMUX_ARCH" -I "$pkg" - done - echo -fi - -############################################################################### -## -## Storing packages in cache. -## -############################################################################### - -if [ "$CIRRUS_BRANCH" = "master" ]; then - if ! $DO_UPLOAD; then - ARCHIVE_NAME="debs-${TERMUX_ARCH}-${CIRRUS_CHANGE_IN_REPO}.tar.gz" - - if [ -d "${REPO_DIR}/debs" ]; then - echo "[*] Archiving packages into '${ARCHIVE_NAME}'." - tar zcf "$ARCHIVE_NAME" debs - - echo "[*] Uploading '${ARCHIVE_NAME}' to cache:" - echo - curl --upload-file "$ARCHIVE_NAME" \ - "http://$CIRRUS_HTTP_CACHE_HOST/${ARCHIVE_NAME}" - echo - fi - else - for arch in aarch64 arm i686 x86_64; do - ARCHIVE_NAME="debs-${arch}-${CIRRUS_CHANGE_IN_REPO}.tar.gz" - - echo "[*] Downloading '$ARCHIVE_NAME' from cache:" - echo - curl --output "/tmp/${ARCHIVE_NAME}" \ - "http://$CIRRUS_HTTP_CACHE_HOST/${ARCHIVE_NAME}" - echo - - if [ -s "/tmp/${ARCHIVE_NAME}" ]; then - echo "[*] Unpacking '/tmp/${ARCHIVE_NAME}':" - echo - tar xvf "/tmp/${ARCHIVE_NAME}" - echo - else - echo "[!] Empty archive '/tmp/${ARCHIVE_NAME}'." - fi - done - - echo "[*] Uploading packages to Bintray:" - echo - "${REPO_DIR}/scripts/package_uploader.sh" -p "${PWD}/debs" $PACKAGE_NAMES - fi + ./build-package.sh -a "$TERMUX_ARCH" -I $PACKAGE_NAMES +else + echo "[*] Uploading packages to Bintray:" + ./scripts/package_uploader.sh -p "${PWD}/debs" $PACKAGE_NAMES fi