Browse Source

CI: sync setup with branch 'master'

android-5
Leonid Plyushch 6 years ago
parent
commit
32deebbb7c
No known key found for this signature in database GPG Key ID: 45F2964132545795
  1. 20
      .cirrus.yml
  2. 71
      scripts/build/ci/cirrus-ci_dispatcher.sh

20
.cirrus.yml

@ -3,14 +3,10 @@ container:
cpu: 8 cpu: 8
memory: 16 memory: 16
##
## * Only test build. No uploads here.
## * Timeout is 120 minutes.
##
task: task:
name: Test build name: Build
# 2 hours is a maximal timeout available for free use.
timeout_in: 120m timeout_in: 120m
environment: environment:
@ -20,6 +16,18 @@ task:
TERMUX_ARCH: i686 TERMUX_ARCH: i686
TERMUX_ARCH: x86_64 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
build_script: | build_script: |
bash ./scripts/build/ci/cirrus-ci_dispatcher.sh bash ./scripts/build/ci/cirrus-ci_dispatcher.sh

71
scripts/build/ci/cirrus-ci_dispatcher.sh

@ -5,6 +5,9 @@
set -e set -e
## Some packages should be excluded from auto builds.
EXCLUDED_PACKAGES="rust texlive"
############################################################################### ###############################################################################
## ##
## Preparation. ## Preparation.
@ -25,6 +28,18 @@ cd "$REPO_DIR" || {
set +e set +e
# Some environment variables are important for correct functionality
# of this script.
if [ -z "$CIRRUS_CHANGE_IN_REPO" ]; then
echo "[!] CIRRUS_CHANGE_IN_REPO is not set."
exit 1
fi
if [ -n "$CIRRUS_PR" ] && [ -z "$CIRRUS_BASE_SHA" ]; then
echo "[!] CIRRUS_BASE_SHA is not set."
exit 1
fi
# Process tag '%ci:no-build' that may be added as line to commit message. # 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. # 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 if grep -qiP '^\s*%ci:no-build\s*$' <(git log --format="%B" -n 1 "$CIRRUS_CHANGE_IN_REPO"); then
@ -41,42 +56,42 @@ if grep -qiP '^\s*%ci:reset-backlog\s*$' <(git log --format="%B" -n 1 "$CIRRUS_C
fi fi
if [ -z "$CIRRUS_PR" ]; then if [ -z "$CIRRUS_PR" ]; then
# Changes determined from the last commit where CI finished with status
# 'passed' (green) and the top commit.
if [ -z "$CIRRUS_LAST_GREEN_CHANGE" ]; 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/") GIT_CHANGES="$CIRRUS_CHANGE_IN_REPO"
else 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/") GIT_CHANGES="${CIRRUS_LAST_GREEN_CHANGE}..${CIRRUS_CHANGE_IN_REPO}"
fi fi
echo "[*] Changes: $GIT_CHANGES"
else else
# Pull requests are handled in a bit different way. # Changes in pull request are determined from commits between the
UPDATED_FILES=$(git diff-tree --no-commit-id --name-only -r "${CIRRUS_BASE_SHA}..${CIRRUS_CHANGE_IN_REPO}" 2>/dev/null | grep -P "packages/") # top commit of base branch and latest commit of PR's branch.
GIT_CHANGES="${CIRRUS_BASE_SHA}..${CIRRUS_CHANGE_IN_REPO}"
echo "[*] Pull request: https://github.com/termux/termux-packages/pull/${CIRRUS_PR}"
fi fi
## Determine modified packages. # Determine changes from commit range.
existing_dirs="" PACKAGE_NAMES=$(git diff-tree --no-commit-id --name-only -r "$GIT_CHANGES" packages/ 2>/dev/null | sed -E 's@^packages/([^/]*)/build.sh@\1@')
for dir in $(echo "$UPDATED_FILES" | grep -oP "packages/[a-z0-9+._-]+" | sort | uniq); do
if [ -d "${REPO_DIR}/${dir}" ]; then ## Filter deleted packages.
existing_dirs+=" $dir" for pkg in $PACKAGE_NAMES; do
if [ ! -d "${REPO_DIR}/packages/${pkg}" ]; then
PACKAGE_NAMES=$(sed "s/\<${pkg}\>//g" <<< "$PACKAGE_NAMES")
fi fi
done done
PACKAGE_DIRS="$existing_dirs"
unset dir existing_dirs
## Get names of modified packages. ## Filter excluded packages.
PACKAGE_NAMES=$(echo "$PACKAGE_DIRS" | sed 's/packages\///g') for pkg in $EXCLUDED_PACKAGES; do
PACKAGE_NAMES=$(sed "s/\<${pkg}\>//g" <<< "$PACKAGE_NAMES")
done
unset pkg
if [ -z "$PACKAGE_NAMES" ]; then if [ -z "$PACKAGE_NAMES" ]; then
echo "[*] No modified packages found." >&2 echo "[*] No modified packages found."
exit 0 exit 0
fi fi
## Some packages should be excluded from auto builds.
EXCLUDED_PACKAGES="rust texlive"
for excluded_pkg in $EXCLUDED_PACKAGES; do
PACKAGE_NAMES=$(echo "$PACKAGE_NAMES" | sed "s/\<${excluded_pkg}\>//g")
done
unset excluded_pkg
set -e set -e
############################################################################### ###############################################################################
@ -86,14 +101,4 @@ set -e
############################################################################### ###############################################################################
echo "[*] Building packages: $PACKAGE_NAMES" echo "[*] Building packages: $PACKAGE_NAMES"
if [ -n "$CIRRUS_PR" ]; then
echo "[*] Pull request: https://github.com/termux/termux-packages/pull/${CIRRUS_PR}"
else
if [ -n "$CIRRUS_LAST_GREEN_CHANGE" ]; then
echo "[*] Changes: ${CIRRUS_LAST_GREEN_CHANGE}..${CIRRUS_CHANGE_IN_REPO}"
else
echo "[*] Changes: ${CIRRUS_CHANGE_IN_REPO}"
fi
fi
./build-package.sh -a "$TERMUX_ARCH" -I $PACKAGE_NAMES ./build-package.sh -a "$TERMUX_ARCH" -I $PACKAGE_NAMES

Loading…
Cancel
Save