1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
#!/bin/bash -e
# SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
# SPDX-FileCopyrightText: 2017 Claudio André <claudioandre.br@gmail.com>
do_Set_Env () {
#Save cache on $pwd (required by artifacts)
mkdir -p "$(pwd)"/.cache
XDG_CACHE_HOME="$(pwd)"/.cache
export XDG_CACHE_HOME
#SpiderMonkey and libgjs
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib64:/usr/local/lib"
export GI_TYPELIB_PATH="$GI_TYPELIB_PATH:/usr/lib64/girepository-1.0"
#Macros
export ACLOCAL_PATH="$ACLOCAL_PATH:/usr/local/share/aclocal"
export SHELL=/bin/bash
PATH=$PATH:~/.local/bin
export DISPLAY="${DISPLAY:-:0}"
}
do_Get_Upstream_Base () {
echo '-----------------------------------------'
echo 'Finding common ancestor'
if git show-branch ci-upstream-base 2> /dev/null; then
echo "Already found"
return
fi
# We need to add a new remote for the upstream target branch, since this
# script could be running in a personal fork of the repository which has out
# of date branches.
#
# Limit the fetch to a certain date horizon to limit the amount of data we
# get. If the branch was forked from the main branch before this horizon, it
# should probably be rebased.
git remote add upstream https://gitlab.gnome.org/GNOME/gjs.git || \
git remote set-url upstream https://gitlab.gnome.org/GNOME/gjs.git
# $CI_MERGE_REQUEST_TARGET_BRANCH_NAME is only defined if we’re running in a
# merge request pipeline; fall back to $CI_DEFAULT_BRANCH otherwise.
base_branch="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}"
if ! git fetch --shallow-since="28 days ago" --no-tags upstream "$base_branch"; then
echo "Main branch doesn't have history in the past 28 days, fetching "
echo "the last 30 commits."
git fetch --depth=30 --no-tags upstream "$base_branch"
fi
git branch -f ci-upstream-base-branch FETCH_HEAD
# Work out the newest common ancestor between the detached HEAD that this CI
# job has checked out, and the upstream target branch (which will typically
# be `upstream/main` or `upstream/gnome-nn`).
newest_common_ancestor_sha=$(git merge-base ci-upstream-base-branch HEAD)
if test -z "$newest_common_ancestor_sha"; then
echo "Couldn’t find common ancestor with the upstream main branch. This"
echo "typically happens if you branched a long time ago. Please update"
echo "your clone, rebase, and re-push your branch."
echo "Base revisions:"
git log --oneline -10 ci-upstream-base-branch
echo "Branch revisions:"
git log --oneline -10 HEAD
exit 1
fi
echo "Merge base:"
git show --no-patch "$newest_common_ancestor_sha"
git branch -f ci-upstream-base "$newest_common_ancestor_sha"
echo '-----------------------------------------'
}
do_Create_Artifacts_Folder () {
# Create the artifacts folders
save_dir="$(pwd)"
mkdir -p "$save_dir"/analysis; touch "$save_dir"/analysis/doing-"$1"
}
do_Check_Script_Errors () {
local total=0
total=$(grep -c 'not ok ' scripts.log) || true
if test "$total" -gt 0; then
echo '-----------------------------------------'
echo "### Found $total errors on scripts.log ###"
echo '-----------------------------------------'
exit 1
fi
}
# ----------- Run the Tests -----------
if test -n "$TEST"; then
extra_opts="($TEST)"
fi
. test/extra/do_environment.sh
# Show some environment info
do_Print_Labels 'ENVIRONMENT'
echo "Running on: $BASE $OS"
echo "Job: $CI_JOB_NAME"
echo "Configure options: ${CONFIG_OPTS-$BUILD_OPTS}"
echo "Doing: $1 $extra_opts"
do_Create_Artifacts_Folder "$1"
# Ignore extra git security checks as we don't care in CI.
git config --global --add safe.directory "${PWD}"
git config --global --add safe.directory \
"${PWD}/subprojects/gobject-introspection-tests"
if test "$1" = "SETUP"; then
do_Show_Info
do_Print_Labels 'Show GJS git information'
git log --pretty=format:"%h %cd %s" -1
elif test "$1" = "BUILD"; then
do_Set_Env
DEFAULT_CONFIG_OPTS=(-Dreadline=enabled -Dprofiler=enabled -Ddtrace=false \
-Dsystemtap=false -Dverbose_logs=false --werror -Dglib:werror=false)
# shellcheck disable=SC2086 # CONFIG_OPTS comes from .gitlab-ci.yml
meson setup _build "${DEFAULT_CONFIG_OPTS[@]}" $CONFIG_OPTS
ninja -C _build
if test "$TEST" != "skip"; then
# shellcheck disable=SC2086 # TEST_OPTS comes from .gitlab-ci.yml
xvfb-run -a meson test -C _build --suite=gjs $TEST_OPTS
fi
elif test "$1" = "SH_CHECKS"; then
# It doesn't (re)build, just run the 'Tests'
do_Print_Labels 'Shell Scripts Check'
do_Set_Env
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export LANGUAGE=C.UTF-8
export NO_AT_BRIDGE=1
sudo ninja -C _build install
installed-tests/scripts/testExamples.sh > scripts.log
do_Check_Script_Errors
elif test "$1" = "UPSTREAM_BASE"; then
do_Get_Upstream_Base
exit 0
fi
# Releases stuff and finishes
do_Done
|