Browse Source

CI: switch to Cirrus

emacs-27
Leonid Plyushch 6 years ago
parent
commit
d8e85d023f
  1. 79
      .cirrus.yml
  2. 92
      .gitlab-ci.yml
  3. 29
      .travis.yml
  4. 14
      scripts/build/ci/determine_git_changes.sh
  5. 2
      scripts/package_uploader.sh

79
.cirrus.yml

@ -0,0 +1,79 @@
container:
image: termux/package-builder:latest
cpu: 8
memory: 16
# Build packages.
build_task:
# Run task only if packages were modified.
# Note that similar check is done in 'scripts/build/ci/determine_git_changes.sh'.
only_if: "changesInclude('packages/**')"
# 2 hours is a maximal timeout for free use.
timeout_in: 120m
environment:
matrix:
TERMUX_ARCH: aarch64
TERMUX_ARCH: arm
TERMUX_ARCH: i686
TERMUX_ARCH: x86_64
# Do not use built-in git client provided by Cirrus as it
# causes 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
# Determine changes in repository and build modified packages.
build_script: |
for package in $(./scripts/build/ci/determine_git_changes.sh); do
if [ -n "$CIRRUS_PR" ]; then
# Perform full builds for PR.
./build-package.sh -a "$TERMUX_ARCH" "$package"
else
./build-package.sh -I -a "$TERMUX_ARCH" "$package"
fi
done
# Make built packages available for the next tasks.
share_packages_cache:
folder: "./debs"
fingerprint_script: echo "$CIRRUS_CHANGE_IN_REPO"
# Also make them downloadable from the UI.
store_packages_artifacts:
path: "./debs/*.deb"
# Publish packages to Bintray.
publish_task:
only_if: $CIRRUS_BRANCH == 'master'
timeout_in: 30m
depends_on:
- build
environment:
BINTRAY_USERNAME: ENCRYPTED[5f767b4b9d6437b98e81c7a9c510363be8c71458efe17b73692898f5bd2720b359a962677b68930e298febf440bea75b]
BINTRAY_API_KEY: ENCRYPTED[c056d345d7a15f90b818dd9382129c27ce4ce2b802831ec890786414fc214c4203714c353a8fef3a6b9b1b1d68e4685e]
BINTRAY_GPG_SUBJECT: ENCRYPTED[adefd71182b37f4cfe2ef734bb400f5d273c562d45536edce46fd63d260a0c0717df7e73f2bb492afb4f5c0ef6d0460d]
BINTRAY_GPG_PASSPHRASE: ENCRYPTED[854c09c78b3318a30d3c9094b1010dfebd4c71ad9173b64479eaafaa7e941b050afaa936ad635af3709382492828316f]
# Retrieve built packages.
share_packages_cache:
folder: "./debs"
fingerprint_script: echo "$CIRRUS_CHANGE_IN_REPO"
# Publish.
upload_to_bintray_script: |
MODIFIED_PACKAGES=$(./scripts/build/ci/determine_git_changes.sh)
if [ -n "$MODIFIED_PACKAGES" ]; then
./scripts/package_uploader.sh $MODIFIED_PACKAGES
fi

92
.gitlab-ci.yml

@ -1,92 +0,0 @@
image: termux/package-builder:latest
stages:
- build
- deploy
## Common configuration for all build jobs.
## Variables BINTRAY_* should be unset to
## prevent leaking of sensitive information.
.job_template: &build_job
stage: build
except:
- schedules
script:
- unset BINTRAY_USERNAME
- unset BINTRAY_API_KEY
- unset BINTRAY_GPG_SUBJECT
- unset BINTRAY_GPG_PASSPHRASE
- |
for package in $(./scripts/build/ci/determine_git_changes.sh); do
./build-package.sh -q -I -a "$TERMUX_ARCH" "$package" || exit 1
done
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
artifacts:
when: always
paths:
- debs
## Building packages for AArch64.
build-aarch64:
<<: *build_job
variables:
TERMUX_ARCH: aarch64
## Building packages for ARM.
build-arm:
<<: *build_job
variables:
TERMUX_ARCH: arm
## Building packages for i686.
build-i686:
<<: *build_job
variables:
TERMUX_ARCH: i686
## Building packages for x86_64.
build-x86_64:
<<: *build_job
variables:
TERMUX_ARCH: x86_64
## Submit build packages to repository.
upload-packages:
stage: deploy
only:
- master@termux-mirror/termux-packages
except:
- schedules
script:
- MODIFIED_PACKAGES=$(./scripts/build/ci/determine_git_changes.sh)
- |
if [ -n "$MODIFIED_PACKAGES" ]; then
./scripts/package_uploader.sh $MODIFIED_PACKAGES
else
exit 0
fi
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
## Remove old versions from the APT repository.
repository-cleanup:
stage: deploy
only:
- schedules
script:
- |
if [ -n "$SCHEDULED_REPOSITORY_CLEANUP" ]; then
./scripts/package_uploader.sh --cleanup $(cd ./packages; echo *)
fi
retry:
max: 2
when:
- runner_system_failure
- unknown_failure

29
.travis.yml

@ -1,29 +0,0 @@
language: generic
## Force usage of "Ubuntu Xenial" as on older versions
## program "realpath" is not working for some reason.
os: linux
dist: xenial
services: docker
sudo: required
## Split per-architecture builds into separate jobs.
env:
matrix:
- TERMUX_ARCH=aarch64
- TERMUX_ARCH=arm
- TERMUX_ARCH=i686
- TERMUX_ARCH=x86_64
## Build modified packages.
## Variables BINTRAY_* should be unset to
## prevent leaking of sensitive information.
script:
- unset BINTRAY_USERNAME
- unset BINTRAY_API_KEY
- unset BINTRAY_GPG_SUBJECT
- unset BINTRAY_GPG_PASSPHRASE
- |
for package in $(./scripts/build/ci/determine_git_changes.sh); do
./scripts/run-docker.sh ./build-package.sh -q -a "$TERMUX_ARCH" "$package" || exit 1
done

14
scripts/build/ci/determine_git_changes.sh

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
## ##
## Script for detecting modified packages. ## Script for detecting modified packages.
## Designed for use with Travis or Gitlab CI. ## Designed for use with Cirrus, Gitlab or Travis CI.
## ##
## Leonid Plyushch <leonid.plyushch@gmail.com> (C) 2019 ## Leonid Plyushch <leonid.plyushch@gmail.com> (C) 2019
## ##
@ -42,6 +42,18 @@ elif [ -n "$CI_COMMIT_SHA" ]; then
else else
UPDATED_FILES=$(git diff-tree --no-commit-id --name-only -r "${CI_COMMIT_BEFORE_SHA}..${CI_COMMIT_SHA}" 2>/dev/null | grep -P "packages/") UPDATED_FILES=$(git diff-tree --no-commit-id --name-only -r "${CI_COMMIT_BEFORE_SHA}..${CI_COMMIT_SHA}" 2>/dev/null | grep -P "packages/")
fi fi
elif [ -n "$CIRRUS_CI" ]; then
# We are on Cirrus CI.
if [ -z "$CIRRUS_PR" ]; then
if [ -z "$CIRRUS_LAST_GREEN_CHANGE" ]; then
UPDATED_FILES=$(git diff-tree --no-commit-id --name-only -r "$CIRRUS_CHANGE_IN_REPO" 2>/dev/null | grep -P "packages/")
else
UPDATED_FILES=$(git diff-tree --no-commit-id --name-only -r "${CIRRUS_LAST_GREEN_CHANGE}..${CIRRUS_CHANGE_IN_REPO}" 2>/dev/null | grep -P "packages/")
fi
else
# Pull requests are handled in a bit different way.
UPDATED_FILES=$(git diff-tree --no-commit-id --name-only -r "${CIRRUS_BASE_SHA}..${CIRRUS_CHANGE_IN_REPO}" 2>/dev/null | grep -P "packages/")
fi
else else
# Something wrong. # Something wrong.
echo "[!] Cannot determine git commit range." >&2 echo "[!] Cannot determine git commit range." >&2

2
scripts/package_uploader.sh

@ -619,7 +619,7 @@ show_usage() {
msg msg
msg "==========================================================" msg "=========================================================="
msg msg
msg "Primarily indended to be used by Gitlab CI for automatic" msg "Primarily indended to be used by CI systems for automatic"
msg "package uploads but it can be used for manual uploads too." msg "package uploads but it can be used for manual uploads too."
msg msg
msg "Before using this script, check that you have all" msg "Before using this script, check that you have all"

Loading…
Cancel
Save