Commit 51e37125 authored by Ralf Jung's avatar Ralf Jung

add main buildjob script

parent 799685e2
# provide some variables to get colorful output
DARKGRAY='\033[1;30m'
RED='\033[0;31m'
LIGHTRED='\033[1;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
LIGHTPURPLE='\033[1;35m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
RESET='\033[0m'
echo_color() {
# $1: the color
# $2: the string
echo "$1$2$RESET"
}
#!/bin/bash
set -e
#set -x
## This runs a default build job. The following variables are noteworthy:
## - $OPAM_PINS: Space-separated list of packages to pin in opam, in the format
## "PACKAGE KIND TARGET PACKAGE KIND TARGET ..."
## - $VALIDATE: If non-empty, run `make validate`
## - $OPAM_UPDATE_SECRET, $OPAM_PKG, $OPAM_PKG_BRANCH: IF $OPAM_PKG is
## non-empty, release this commit as a new package on opam when done.
## Requires the $OPAM_UPDATE_SECRET variable to be set. This only happens if
## the current branch is $OPAM_PKG_BRANCH, or master if that variable is
## empty.
# Parepare
. ci/ansi-colors
. ci/prepare-opam $OPAM_PINS
env | egrep '^(CI_BUILD_REF|CI_RUNNER)' > build-env.txt
# Build
echo_color "$GREEN" "[buildjob] Perfoming build"
time make -k -j$CPU_CORES TIMED=y 2>&1 | tee build-log.txt
if fgrep Axiom build-log.txt >/dev/null; then exit 1; fi
echo_color "$GREEN" "[buildjob] Build time summary"
cat build-log.txt | egrep "[a-zA-Z0-9_/-]+ \((real|user): [0-9]" | tee build-time.txt
# maybe validate
if [[ -n "$VALIDATE" ]]; then
echo_color "$GREEN" "[buildjob] Performing validation"
make validate;
fi
# maybe create opam package
if [[ -z "$OPAM_PKG_BRANCH" ]]; then
OPAM_PKG_BRANCH=master
fi
if [[ -n "$OPAM_PKG" && "$CI_COMMIT_REF_NAME" == "$OPAM_PKG_BRANCH" ]]; then
echo_color "$GREEN" "[buildjob] Releasing package on opam"
# determine package name prefix
if [[ "$CI_COMMIT_REF_NAME" == master ]]; then
OPAM_PKG_PREFIX=dev
else
OPAM_PKG_PREFIX="branch.$CI_COMMIT_REF_NAME"
fi
# Trigger opam updater
curl --fail -X POST -F "token=$OPAM_UPDATE_SECRET" -F "ref=master" \
-F "variables[REPO]=$CI_PROJECT_URL.git" \
-F "variables[REF]=$CI_COMMIT_REF_NAME" \
-F "variables[SHA]=$CI_COMMIT_SHA" \
-F "variables[NAME]=$OPAM_PKG" \
-F "variables[OPAM_PREFIX]=$OPAM_PKG_PREFIX" \
https://gitlab.mpi-sws.org/api/v4/projects/581/trigger/pipeline
fi
#!/bin/bash
set -e
set -x
## This script installs the build dependencies for CI builds.
# Prepare OPAM configuration
......@@ -9,10 +6,16 @@ export OPAMJOBS="$((2*$CPU_CORES))"
export OPAM_EDITOR="$(which false)"
# Make sure we got a good OPAM.
test -d "$OPAMROOT" || (mkdir "$OPAMROOT" && opam init --no-setup -y)
if test -d "$OPAMROOT"; then
echo_color "$GREEN" "[prepare-opam] Re-using cached opam root"
else
echo_color "$YELLOW" "[prepare-opam] Creating new opam root"
mkdir "$OPAMROOT"
opam init --no-setup -y
fi
eval `opam conf env`
# Make sure the pin for the builddep package is not stale.
# Make sure the pin for the builddep package exists and is up-to-date
make build-dep/opam
# Update repositories
......@@ -36,7 +39,7 @@ echo
# that is not currently possible.
# Install fixed versions of some dependencies.
echo
echo_color "$GREEN" "[prepare-opam] Processing pins"
while (( "$#" )); do # while there are arguments left
PACKAGE="$1" ; shift
KIND="$1" ; shift
......@@ -45,24 +48,24 @@ while (( "$#" )); do # while there are arguments left
# Check if the pin is already set
read -a PIN <<< $(opam pin list | (egrep "^$PACKAGE[. ]"))
if [[ "${PIN[1]}" == "$KIND" && "${PIN[2]}" == "$VERSION" ]]; then
echo "[opam-ci] $PACKAGE already $KIND-pinned to $VERSION"
echo_color "$GREEN" "[prepare-opam] $PACKAGE already $KIND-pinned to $VERSION"
else
echo "[opam-ci] $KIND-pinning $PACKAGE to $VERSION"
echo_color "$YELLOW" "[prepare-opam] $KIND-pinning $PACKAGE to $VERSION"
opam pin add -y -k "$KIND" "$PACKAGE" "$VERSION"
fi
done
echo
# Upgrade cached things.
echo
echo "[opam-ci] Upgrading opam"
echo_color "$GREEN" "[prepare-opam] Upgrading opam"
opam upgrade -y --fixup && opam upgrade -y
echo
# Install build-dependencies.
echo
echo "[opam-ci] Installing build-dependencies"
echo_color "$GREEN" "[prepare-opam] Installing build-dependencies"
make build-dep OPAMFLAGS=-y
echo
# done
set +x
echo
coqc -v
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment