Browse Source

CI: switch to Cirrus

android-5
Leonid Plyushch 6 years ago
parent
commit
28751c7d55
No known key found for this signature in database GPG Key ID: 45F2964132545795
  1. 50
      .cirrus.yml
  2. 52
      .gitlab-ci.yml
  3. 29
      .travis.yml
  4. 5
      README.md
  5. 30
      scripts/build/ci/determine_git_changes.sh

50
.cirrus.yml

@ -0,0 +1,50 @@
container:
image: termux/package-builder:latest
cpu: 8
memory: 16
# Build packages.
build_task:
# 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: |
if grep -qiP '^\s*%ci:reset-backlog\s*$' <(git log --format="%B" -n 1 "$CIRRUS_CHANGE_IN_REPO"); then
# If commit message contains line '%ci:reset-backlog', builds will be done
# only for current commit.
unset CIRRUS_LAST_GREEN_CHANGE
unset CIRRUS_BASE_SHA
fi
MODIFIED_PACKAGES=$(./scripts/build/ci/determine_git_changes.sh)
for package in $MODIFIED_PACKAGES; 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
# Also make them downloadable from the UI.
output_artifacts:
path: "./debs/*.deb"

52
.gitlab-ci.yml

@ -1,52 +0,0 @@
image: termux/package-builder:latest
stages:
- build
## Common configuration for all build jobs.
## Variables BINTRAY_* should be unset to
## prevent leaking of sensitive information.
.job_template: &build_job
stage: build
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

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

5
README.md

@ -2,7 +2,6 @@
[![Powered by JFrog Bintray](./.github/static/powered-by-bintray.png)](https://bintray.com)
[![pipeline status](https://gitlab.com/termux-mirror/termux-packages/badges/master/pipeline.svg)](https://gitlab.com/termux-mirror/termux-packages/commits/android-5)
[![Join the chat at https://gitter.im/termux/termux](https://badges.gitter.im/termux/termux.svg)](https://gitter.im/termux/termux)
This project contains scripts and patches to build packages for the [Termux](https://termux.com/) Android application. Note that packages are cross-compiled and on-device builds are not currently supported.
@ -33,9 +32,9 @@ Also, if you want to request a particular package, you may suggest it in an issu
We welcome any pull requests. Nevertheless, a log file should be provided in order to show that it is at least working.
Normally, all pull requests will be tested by [Travis CI](https://travis-ci.org/termux/termux-packages). However, in case if you are banned or for whatever reason do no use Travis CI, you should provide a log file by yourself.
All pull requests will be built by [Cirrus CI](https://cirrus-ci.com/termux/termux-packages). Usually, it is expected that all tasks will pass. But do not worry if CI build timed out. Alternatively, you can provide build logs by yourself.
All tests for master branch are done by Gitlab CI.
Note that it is highly recommended to keep your pull requests up-to-date. If you do not know how to do this, take a look on manpage of `git-rebase`.
## Contacts

30
scripts/build/ci/determine_git_changes.sh

@ -1,7 +1,7 @@
#!/bin/bash
##
## 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
##
@ -42,6 +42,18 @@ elif [ -n "$CI_COMMIT_SHA" ]; then
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/")
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
# Something wrong.
echo "[!] Cannot determine git commit range." >&2
@ -68,5 +80,19 @@ fi
## Print names of modified packages.
for pkg in $PACKAGE_NAMES; do
echo "$pkg"
case "$pkg" in
# Skip packages that known to have long build time.
rust|texlive)
{
echo
echo "Package '$pkg' cannot be built via CI because it has"
echo "long build time."
echo
} >&2
continue
;;
*)
echo "$pkg"
;;
esac
done

Loading…
Cancel
Save