diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:08 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:08 +0000 |
commit | 29b5ab554790bb57337a3b6ab9dcd963cf69d22e (patch) | |
tree | be1456d2bc6c1fb078695fad7bc8f6b212062d3c /ci | |
parent | Initial commit. (diff) | |
download | libgit2-upstream/1.7.2+ds.tar.xz libgit2-upstream/1.7.2+ds.zip |
Adding upstream version 1.7.2+ds.upstream/1.7.2+ds
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ci')
-rwxr-xr-x | ci/build.sh | 93 | ||||
-rwxr-xr-x | ci/coverity.sh | 62 | ||||
-rw-r--r-- | ci/docker/bionic | 49 | ||||
-rw-r--r-- | ci/docker/centos7 | 60 | ||||
-rw-r--r-- | ci/docker/centos8 | 58 | ||||
-rw-r--r-- | ci/docker/docurium | 5 | ||||
-rw-r--r-- | ci/docker/focal | 85 | ||||
-rw-r--r-- | ci/docker/xenial | 84 | ||||
-rwxr-xr-x | ci/getcontainer.sh | 55 | ||||
-rwxr-xr-x | ci/setup-mingw-build.sh | 27 | ||||
-rwxr-xr-x | ci/setup-osx-benchmark.sh | 6 | ||||
-rwxr-xr-x | ci/setup-osx-build.sh | 8 | ||||
-rwxr-xr-x | ci/setup-ubuntu-benchmark.sh | 20 | ||||
-rwxr-xr-x | ci/setup-win32-benchmark.sh | 9 | ||||
-rwxr-xr-x | ci/setup-win32-build.sh | 27 | ||||
-rwxr-xr-x | ci/test.sh | 451 |
16 files changed, 1099 insertions, 0 deletions
diff --git a/ci/build.sh b/ci/build.sh new file mode 100755 index 0000000..80e7a61 --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# +# Environment variables: +# +# SOURCE_DIR: Set to the directory of the libgit2 source (optional) +# If not set, it will be derived relative to this script. + +set -e + +SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )} +BUILD_DIR=$(pwd) +BUILD_PATH=${BUILD_PATH:=$PATH} +CMAKE=$(which cmake) +CMAKE_GENERATOR=${CMAKE_GENERATOR:-Unix Makefiles} + +indent() { sed "s/^/ /"; } + +cygfullpath() { + result=$(echo "${1}" | tr \; \\n | while read -r element; do + if [ "${last}" != "" ]; then echo -n ":"; fi + echo -n $(cygpath "${element}") + last="${element}" + done) + if [ "${result}" = "" ]; then exit 1; fi + echo "${result}" +} + +if [[ "$(uname -s)" == MINGW* ]]; then + BUILD_PATH=$(cygfullpath "${BUILD_PATH}") +fi + + +echo "Source directory: ${SOURCE_DIR}" +echo "Build directory: ${BUILD_DIR}" +echo "" + +echo "Platform:" +uname -s | indent + +if [ "$(uname -s)" = "Darwin" ]; then + echo "macOS version:" + sw_vers | indent +fi + +if [ -f "/etc/debian_version" ]; then + echo "Debian version:" + (source /etc/lsb-release && echo "${DISTRIB_DESCRIPTION}") | indent +fi + +CORES=$(getconf _NPROCESSORS_ONLN || true) +echo "Number of cores: ${CORES:-(Unknown)}" + +echo "Kernel version:" +uname -a 2>&1 | indent + +echo "CMake version:" +env PATH="${BUILD_PATH}" "${CMAKE}" --version | head -1 2>&1 | indent + +if test -n "${CC}"; then + echo "Compiler version:" + "${CC}" --version 2>&1 | indent +fi +echo "Environment:" +if test -n "${CC}"; then + echo "CC=${CC}" | indent +fi +if test -n "${CFLAGS}"; then + echo "CFLAGS=${CFLAGS}" | indent +fi +echo "" + +echo "##############################################################################" +echo "## Configuring build environment" +echo "##############################################################################" + +echo "${CMAKE}" -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS} -S \"${SOURCE_DIR}\" +env PATH="${BUILD_PATH}" "${CMAKE}" -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS} -S "${SOURCE_DIR}" + +echo "" +echo "##############################################################################" +echo "## Building libgit2" +echo "##############################################################################" + +# Determine parallelism; newer cmake supports `--build --parallel` but +# we cannot yet rely on that. +if [ "${CMAKE_GENERATOR}" = "Unix Makefiles" -a "${CORES}" != "" -a "${CMAKE_BUILD_OPTIONS}" = "" ]; then + BUILDER=(make -j ${CORES}) +else + BUILDER=("${CMAKE}" --build . ${CMAKE_BUILD_OPTIONS}) +fi + +echo "${BUILDER[@]}" +env PATH="${BUILD_PATH}" "${BUILDER[@]}" diff --git a/ci/coverity.sh b/ci/coverity.sh new file mode 100755 index 0000000..c68b6f8 --- /dev/null +++ b/ci/coverity.sh @@ -0,0 +1,62 @@ +#!/bin/bash -e + +if test -z "$COVERITY_TOKEN" +then + echo "Need to set a coverity token" + exit 1 +fi + +case $(uname -m) in + i?86) + BITS=32;; + amd64|x86_64) + BITS=64;; + *) + echo "Unsupported arch '$(uname -m)'" + exit 1;; +esac + +SCAN_TOOL=https://scan.coverity.com/download/cxx/linux${BITS} +SOURCE_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..) +BUILD_DIR=${SOURCE_DIR}/coverity-build +TOOL_DIR=${BUILD_DIR}/coverity-tools + +# Install coverity tools +if ! test -d "$TOOL_DIR" +then + mkdir -p "$TOOL_DIR" + curl --silent --show-error --location --data "project=libgit2&token=$COVERITY_TOKEN" "$SCAN_TOOL" | + tar -xzC "$TOOL_DIR" + ln -s "$(find "$TOOL_DIR" -type d -name 'cov-analysis*')" "$TOOL_DIR"/cov-analysis +fi + +cp "${SOURCE_DIR}/script/user_nodefs.h" "$TOOL_DIR"/cov-analysis/config/ + +# Build libgit2 with Coverity +mkdir -p "$BUILD_DIR" +cd "$BUILD_DIR" +cmake "$SOURCE_DIR" +COVERITY_UNSUPPORTED=1 \ + "$TOOL_DIR/cov-analysis/bin/cov-build" --dir cov-int \ + cmake --build . + +# Upload results +tar -czf libgit2.tgz cov-int +REVISION=$(cd ${SOURCE_DIR} && git rev-parse --short HEAD) +HTML="$(curl \ + --silent --show-error \ + --write-out "\n%{http_code}" \ + --form token="$COVERITY_TOKEN" \ + --form email=libgit2@gmail.com \ + --form file=@libgit2.tgz \ + --form version="$REVISION" \ + --form description="libgit2 build" \ + https://scan.coverity.com/builds?project=libgit2)" + +# Status code is the last line +STATUS_CODE="$(echo "$HTML" | tail -n1)" +if test "${STATUS_CODE}" != 200 && test "${STATUS_CODE}" != 201 +then + echo "Received error code ${STATUS_CODE} from Coverity" + exit 1 +fi diff --git a/ci/docker/bionic b/ci/docker/bionic new file mode 100644 index 0000000..f1b69ed --- /dev/null +++ b/ci/docker/bionic @@ -0,0 +1,49 @@ +ARG BASE=ubuntu:bionic + +FROM ${BASE} AS apt +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + clang \ + cmake \ + curl \ + gcc \ + git \ + krb5-user \ + libcurl4-openssl-dev \ + libkrb5-dev \ + libpcre3-dev \ + libssh2-1-dev \ + libssl-dev \ + libz-dev \ + ninja-build \ + openjdk-8-jre-headless \ + openssh-server \ + openssl \ + pkgconf \ + python \ + sudo \ + valgrind \ + && \ + rm -rf /var/lib/apt/lists/* + +FROM apt AS mbedtls +RUN cd /tmp && \ + curl --location --silent --show-error https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-2.16.2.tar.gz | \ + tar -xz && \ + cd mbedtls-mbedtls-2.16.2 && \ + scripts/config.pl set MBEDTLS_MD4_C 1 && \ + CFLAGS=-fPIC cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON . && \ + ninja install && \ + cd .. && \ + rm -rf mbedtls-mbedtls-2.16.2 + +FROM mbedtls AS adduser +ARG UID="" +ARG GID="" +RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \ + if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \ + groupadd ${GROUP_ARG} libgit2 && \ + useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2 + +FROM adduser AS configure +RUN mkdir /var/run/sshd diff --git a/ci/docker/centos7 b/ci/docker/centos7 new file mode 100644 index 0000000..28ed650 --- /dev/null +++ b/ci/docker/centos7 @@ -0,0 +1,60 @@ +ARG BASE=centos:7 + +FROM ${BASE} AS yum +RUN yum install -y \ + which \ + bzip2 \ + git \ + libarchive \ + gcc \ + gcc-c++ \ + make \ + openssl-devel \ + openssh-server \ + git-daemon \ + java-1.8.0-openjdk-headless \ + sudo \ + python + +FROM yum AS libssh2 +RUN cd /tmp && \ + curl --location --silent --show-error https://www.libssh2.org/download/libssh2-1.8.0.tar.gz | tar -xz && \ + cd libssh2-1.8.0 && \ + ./configure && \ + make && \ + make install && \ + cd .. && \ + rm -rf libssh-1.8.0 + +FROM libssh2 AS valgrind +RUN cd /tmp && \ + curl --insecure --location --silent --show-error https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 | \ + tar -xj && \ + cd valgrind-3.15.0 && \ + ./configure && \ + make MAKEFLAGS="-j -l$(grep -c ^processor /proc/cpuinfo)" && \ + make install && \ + cd .. && \ + rm -rf valgrind-3.15.0 + +FROM valgrind AS cmake +RUN cd /tmp && \ + curl -L https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1.tar.gz | tar -xz && \ + cd cmake-3.21.1 && \ + ./configure && \ + make && \ + make install && \ + cd .. && \ + rm -rf cmake-3.21.1 + +FROM cmake AS adduser +ARG UID="" +ARG GID="" +RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \ + if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \ + groupadd ${GROUP_ARG} libgit2 && \ + useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2 + +FROM adduser AS configure +ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig +RUN mkdir /var/run/sshd diff --git a/ci/docker/centos8 b/ci/docker/centos8 new file mode 100644 index 0000000..81f0c3c --- /dev/null +++ b/ci/docker/centos8 @@ -0,0 +1,58 @@ +ARG BASE=centos:8 + +FROM ${BASE} AS stream +RUN dnf -y --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos && \ + dnf -y distro-sync + +FROM stream AS yum +RUN yum install -y \ + which \ + bzip2 \ + git \ + libarchive \ + cmake \ + gcc \ + make \ + openssl-devel \ + openssh-server \ + git-daemon \ + java-1.8.0-openjdk-headless \ + sudo \ + python39 \ + krb5-workstation \ + krb5-libs + +FROM yum AS libssh2 +RUN cd /tmp && \ + curl --location --silent --show-error https://www.libssh2.org/download/libssh2-1.8.0.tar.gz | tar -xz && \ + cd libssh2-1.8.0 && \ + ./configure && \ + make && \ + make install && \ + cd .. && \ + rm -rf libssh2-1.8.0 + +FROM libssh2 AS valgrind +RUN cd /tmp && \ + curl --insecure --location --silent --show-error https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 | \ + tar -xj && \ + cd valgrind-3.15.0 && \ + ./configure && \ + make MAKEFLAGS="-j -l$(grep -c ^processor /proc/cpuinfo)" && \ + make install && \ + cd .. && \ + rm -rf valgrind-3.15.0 + +FROM valgrind AS adduser +ARG UID="" +ARG GID="" +RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \ + if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \ + groupadd ${GROUP_ARG} libgit2 && \ + useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2 + +FROM adduser AS configure +ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig +RUN mkdir /var/run/sshd +RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local && \ + ldconfig diff --git a/ci/docker/docurium b/ci/docker/docurium new file mode 100644 index 0000000..1957bbb --- /dev/null +++ b/ci/docker/docurium @@ -0,0 +1,5 @@ +ARG BASE=ubuntu:bionic + +FROM ${BASE} +RUN apt update && apt install -y cmake pkg-config ruby ruby-dev llvm libclang-dev libssl-dev python-pygments +RUN gem install docurium diff --git a/ci/docker/focal b/ci/docker/focal new file mode 100644 index 0000000..b3a402c --- /dev/null +++ b/ci/docker/focal @@ -0,0 +1,85 @@ +ARG BASE=ubuntu:focal + +FROM ${BASE} AS apt +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + bzip2 \ + clang-10 \ + cmake \ + curl \ + gcc-10 \ + git \ + krb5-user \ + libcurl4-gnutls-dev \ + libgcrypt20-dev \ + libkrb5-dev \ + libpcre3-dev \ + libssl-dev \ + libz-dev \ + llvm-10 \ + make \ + ninja-build \ + openjdk-8-jre-headless \ + openssh-server \ + openssl \ + pkgconf \ + python \ + sudo \ + valgrind \ + && \ + rm -rf /var/lib/apt/lists/* && \ + mkdir /usr/local/msan + +FROM apt AS mbedtls +RUN cd /tmp && \ + curl --location --silent --show-error https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-2.16.2.tar.gz | \ + tar -xz && \ + cd mbedtls-mbedtls-2.16.2 && \ + scripts/config.pl unset MBEDTLS_AESNI_C && \ + scripts/config.pl set MBEDTLS_MD4_C 1 && \ + mkdir build build-msan && \ + cd build && \ + CC=clang-10 CFLAGS="-fPIC" cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DUSE_STATIC_MBEDTLS_LIBRARY=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/usr/local -DCMAKE_INSTALL_PREFIX=/usr/local .. && \ + ninja install && \ + cd ../build-msan && \ + CC=clang-10 CFLAGS="-fPIC" cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DUSE_STATIC_MBEDTLS_LIBRARY=OFF -DCMAKE_BUILD_TYPE=MemSanDbg -DCMAKE_INSTALL_PREFIX=/usr/local/msan .. && \ + ninja install && \ + cd .. && \ + rm -rf mbedtls-mbedtls-2.16.2 + +FROM mbedtls AS libssh2 +RUN cd /tmp && \ + curl --location --silent --show-error https://www.libssh2.org/download/libssh2-1.9.0.tar.gz | tar -xz && \ + cd libssh2-1.9.0 && \ + mkdir build build-msan && \ + cd build && \ + CC=clang-10 CFLAGS="-fPIC" cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCRYPTO_BACKEND=Libgcrypt -DCMAKE_PREFIX_PATH=/usr/local -DCMAKE_INSTALL_PREFIX=/usr/local .. && \ + ninja install && \ + cd ../build-msan && \ + CC=clang-10 CFLAGS="-fPIC -fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer" LDFLAGS="-fsanitize=memory" cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCRYPTO_BACKEND=mbedTLS -DCMAKE_PREFIX_PATH=/usr/local/msan -DCMAKE_INSTALL_PREFIX=/usr/local/msan .. && \ + ninja install && \ + cd .. && \ + rm -rf libssh2-1.9.0 + +FROM libssh2 AS valgrind +RUN cd /tmp && \ + curl --insecure --location --silent --show-error https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 | \ + tar -xj && \ + cd valgrind-3.15.0 && \ + CC=clang-10 ./configure && \ + make MAKEFLAGS="-j -l$(grep -c ^processor /proc/cpuinfo)" && \ + make install && \ + cd .. && \ + rm -rf valgrind-3.15.0 + +FROM valgrind AS adduser +ARG UID="" +ARG GID="" +RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \ + if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \ + groupadd ${GROUP_ARG} libgit2 && \ + useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2 + + +FROM adduser AS configure +RUN mkdir /var/run/sshd diff --git a/ci/docker/xenial b/ci/docker/xenial new file mode 100644 index 0000000..578f0a9 --- /dev/null +++ b/ci/docker/xenial @@ -0,0 +1,84 @@ +ARG BASE=ubuntu:xenial + +FROM ${BASE} AS apt +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + bzip2 \ + clang \ + cmake \ + curl \ + gettext \ + gcc \ + krb5-user \ + libcurl4-gnutls-dev \ + libexpat1-dev \ + libgcrypt20-dev \ + libintl-perl \ + libkrb5-dev \ + libpcre3-dev \ + libssl-dev \ + libz-dev \ + make \ + ninja-build \ + openjdk-8-jre-headless \ + openssh-server \ + openssl \ + pkgconf \ + python \ + sudo \ + valgrind \ + && \ + rm -rf /var/lib/apt/lists/* + +FROM apt AS git +RUN cd /tmp && \ + curl --location --silent --show-error https://github.com/git/git/archive/refs/tags/v2.39.1.tar.gz | \ + tar -xz && \ + cd git-2.39.1 && \ + make && \ + make prefix=/usr install && \ + cd .. && \ + rm -rf git-2.39.1 + +FROM git AS mbedtls +RUN cd /tmp && \ + curl --location --silent --show-error https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-2.16.2.tar.gz | \ + tar -xz && \ + cd mbedtls-mbedtls-2.16.2 && \ + scripts/config.pl set MBEDTLS_MD4_C 1 && \ + CFLAGS=-fPIC cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON . && \ + ninja install && \ + cd .. && \ + rm -rf mbedtls-mbedtls-2.16.2 + +FROM mbedtls AS libssh2 +RUN cd /tmp && \ + curl --location --silent --show-error https://www.libssh2.org/download/libssh2-1.8.2.tar.gz | tar -xz && \ + cd libssh2-1.8.2 && \ + CFLAGS=-fPIC cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCRYPTO_BACKEND=Libgcrypt . && \ + ninja install && \ + cd .. && \ + rm -rf libssh2-1.8.2 + +FROM libssh2 AS valgrind +RUN cd /tmp && \ + curl --insecure --location --silent --show-error https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 | \ + tar -xj && \ + cd valgrind-3.15.0 && \ + ./configure && \ + make && \ + make install && \ + cd .. && \ + rm -rf valgrind-3.15.0 + +FROM valgrind AS adduser +ARG UID="" +ARG GID="" +RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \ + if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \ + groupadd ${GROUP_ARG} libgit2 && \ + useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2 + + +FROM adduser AS configure +RUN mkdir /var/run/sshd diff --git a/ci/getcontainer.sh b/ci/getcontainer.sh new file mode 100755 index 0000000..81d0c1d --- /dev/null +++ b/ci/getcontainer.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +set -e + +IMAGE_NAME=$1 +DOCKERFILE_PATH=$2 + +if [ "${IMAGE_NAME}" = "" ]; then + echo "usage: $0 image_name [dockerfile]" + exit 1 +fi + +if [ "${DOCKERFILE_PATH}" = "" ]; then + DOCKERFILE_PATH="${IMAGE_NAME}" +fi + +if [ "${DOCKER_REGISTRY}" = "" ]; then + echo "DOCKER_REGISTRY environment variable is unset." + echo "Not running inside GitHub Actions or misconfigured?" + exit 1 +fi + +DOCKER_CONTAINER="${GITHUB_REPOSITORY}/${IMAGE_NAME}" +DOCKER_REGISTRY_CONTAINER="${DOCKER_REGISTRY}/${DOCKER_CONTAINER}" + +echo "dockerfile=${DOCKERFILE_PATH}" >> $GITHUB_ENV +echo "docker-container=${DOCKER_CONTAINER}" >> $GITHUB_ENV +echo "docker-registry-container=${DOCKER_REGISTRY_CONTAINER}" >> $GITHUB_ENV + +# Identify the last git commit that touched the Dockerfiles +# Use this as a hash to identify the resulting docker containers +DOCKER_SHA=$(git log -1 --pretty=format:"%h" -- "${DOCKERFILE_PATH}") +echo "docker-sha=${DOCKER_SHA}" >> $GITHUB_ENV + +DOCKER_REGISTRY_CONTAINER_SHA="${DOCKER_REGISTRY_CONTAINER}:${DOCKER_SHA}" + +echo "docker-registry-container-sha=${DOCKER_REGISTRY_CONTAINER_SHA}" >> $GITHUB_ENV +echo "docker-registry-container-latest=${DOCKER_REGISTRY_CONTAINER}:latest" >> $GITHUB_ENV + +echo "::: logging in to ${DOCKER_REGISTRY} as ${GITHUB_ACTOR}" + +exists="true" +docker login https://${DOCKER_REGISTRY} -u ${GITHUB_ACTOR} -p ${GITHUB_TOKEN} || exists="false" + +echo "::: pulling ${DOCKER_REGISTRY_CONTAINER_SHA}" + +if [ "${exists}" != "false" ]; then + docker pull ${DOCKER_REGISTRY_CONTAINER_SHA} || exists="false" +fi + +if [ "${exists}" = "true" ]; then + echo "docker-container-exists=true" >> $GITHUB_ENV +else + echo "docker-container-exists=false" >> $GITHUB_ENV +fi diff --git a/ci/setup-mingw-build.sh b/ci/setup-mingw-build.sh new file mode 100755 index 0000000..6c444f5 --- /dev/null +++ b/ci/setup-mingw-build.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -ex + +echo "##############################################################################" +echo "## Downloading mingw" +echo "##############################################################################" + +BUILD_TEMP=${BUILD_TEMP:=$TEMP} +BUILD_TEMP=$(cygpath $BUILD_TEMP) + +case "$ARCH" in + amd64) + MINGW_URI="https://github.com/libgit2/ci-dependencies/releases/download/2023-01-23/mingw-x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0.zip";; + x86) + MINGW_URI="https://github.com/libgit2/ci-dependencies/releases/download/2023-01-23/mingw-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip";; +esac + +if [ -z "$MINGW_URI" ]; then + echo "No URL" + exit 1 +fi + +mkdir -p "$BUILD_TEMP" + +curl -s -L "$MINGW_URI" -o "$BUILD_TEMP"/mingw-"$ARCH".zip +unzip -q "$BUILD_TEMP"/mingw-"$ARCH".zip -d "$BUILD_TEMP" diff --git a/ci/setup-osx-benchmark.sh b/ci/setup-osx-benchmark.sh new file mode 100755 index 0000000..80d8768 --- /dev/null +++ b/ci/setup-osx-benchmark.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -ex + +brew update +brew install hyperfine diff --git a/ci/setup-osx-build.sh b/ci/setup-osx-build.sh new file mode 100755 index 0000000..0b95e76 --- /dev/null +++ b/ci/setup-osx-build.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -ex + +brew update +brew install pkgconfig zlib curl openssl libssh2 ninja + +ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libLeaksAtExit.dylib /usr/local/lib diff --git a/ci/setup-ubuntu-benchmark.sh b/ci/setup-ubuntu-benchmark.sh new file mode 100755 index 0000000..561a18f --- /dev/null +++ b/ci/setup-ubuntu-benchmark.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -ex + +sudo apt-get update +sudo apt-get install -y --no-install-recommends \ + cargo \ + cmake \ + gcc \ + git \ + krb5-user \ + libkrb5-dev \ + libssl-dev \ + libz-dev \ + make \ + ninja-build \ + pkgconf + +wget https://github.com/sharkdp/hyperfine/releases/download/v1.12.0/hyperfine_1.12.0_amd64.deb +sudo dpkg -i hyperfine_1.12.0_amd64.deb diff --git a/ci/setup-win32-benchmark.sh b/ci/setup-win32-benchmark.sh new file mode 100755 index 0000000..0eac2f6 --- /dev/null +++ b/ci/setup-win32-benchmark.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -ex + +choco install hyperfine zip + +CHOCO_PATH=$(mktemp -d) +curl -L https://github.com/ethomson/PurgeStandbyList/releases/download/v1.0/purgestandbylist.1.0.0.nupkg -o "${CHOCO_PATH}/purgestandbylist.1.0.0.nupkg" +choco install purgestandbylist -s $(cygpath -w "${CHOCO_PATH}") diff --git a/ci/setup-win32-build.sh b/ci/setup-win32-build.sh new file mode 100755 index 0000000..a8b81e5 --- /dev/null +++ b/ci/setup-win32-build.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -ex + +echo "##############################################################################" +echo "## Downloading libssh2" +echo "##############################################################################" + +BUILD_TEMP=${BUILD_TEMP:=$TEMP} +BUILD_TEMP=$(cygpath $BUILD_TEMP) + +case "$ARCH" in + amd64) + LIBSSH2_URI="https://github.com/libgit2/ci-dependencies/releases/download/2023-02-01/libssh2-20230201-amd64.zip";; + x86) + LIBSSH2_URI="https://github.com/libgit2/ci-dependencies/releases/download/2023-02-01-v2/libssh2-20230201-x86.zip";; +esac + +if [ -z "$LIBSSH2_URI" ]; then + echo "No URL" + exit 1 +fi + +mkdir -p "$BUILD_TEMP" + +curl -s -L "$LIBSSH2_URI" -o "$BUILD_TEMP"/libssh2-"$ARCH".zip +unzip -q "$BUILD_TEMP"/libssh2-"$ARCH".zip -d "$BUILD_TEMP" diff --git a/ci/test.sh b/ci/test.sh new file mode 100755 index 0000000..ee6801a --- /dev/null +++ b/ci/test.sh @@ -0,0 +1,451 @@ +#!/usr/bin/env bash + +set -e + +if [ -n "$SKIP_TESTS" ]; then + exit 0 +fi + +# Windows doesn't run the NTLM tests properly (yet) +if [[ "$(uname -s)" == MINGW* ]]; then + SKIP_NTLM_TESTS=1 +fi + +SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )} +BUILD_DIR=$(pwd) +BUILD_PATH=${BUILD_PATH:=$PATH} +CTEST=$(which ctest) +TMPDIR=${TMPDIR:-/tmp} +USER=${USER:-$(whoami)} + +HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX` +export CLAR_HOMEDIR=${HOME} + +SUCCESS=1 +CONTINUE_ON_FAILURE=0 + +cleanup() { + echo "Cleaning up..." + + if [ ! -z "$GIT_STANDARD_PID" ]; then + echo "Stopping git daemon (standard)..." + kill $GIT_STANDARD_PID + fi + + if [ ! -z "$GIT_NAMESPACE_PID" ]; then + echo "Stopping git daemon (namespace)..." + kill $GIT_NAMESPACE_PID + fi + + if [ ! -z "$GIT_SHA256_PID" ]; then + echo "Stopping git daemon (sha256)..." + kill $GIT_SHA256_PID + fi + + if [ ! -z "$PROXY_BASIC_PID" ]; then + echo "Stopping proxy (Basic)..." + kill $PROXY_BASIC_PID + fi + + if [ ! -z "$PROXY_NTLM_PID" ]; then + echo "Stopping proxy (NTLM)..." + kill $PROXY_NTLM_PID + fi + + if [ ! -z "$HTTP_PID" ]; then + echo "Stopping HTTP server..." + kill $HTTP_PID + fi + + if [ ! -z "$SSHD_DIR" -a -f "${SSHD_DIR}/pid" ]; then + echo "Stopping SSH server..." + kill $(cat "${SSHD_DIR}/pid") + fi + + echo "Done." +} + +run_test() { + if [[ "$GITTEST_FLAKY_RETRY" > 0 ]]; then + ATTEMPTS_REMAIN=$GITTEST_FLAKY_RETRY + else + ATTEMPTS_REMAIN=1 + fi + + FAILED=0 + while [[ "$ATTEMPTS_REMAIN" > 0 ]]; do + if [ "$FAILED" -eq 1 ]; then + echo "" + echo "Re-running flaky ${1} tests..." + echo "" + fi + + RETURN_CODE=0 + + ( + export PATH="${BUILD_PATH}" + export CLAR_SUMMARY="${BUILD_DIR}/results_${1}.xml" + "${CTEST}" -V -R "^${1}$" + ) || RETURN_CODE=$? && true + + if [ "$RETURN_CODE" -eq 0 ]; then + FAILED=0 + break + fi + + echo "Test exited with code: $RETURN_CODE" + ATTEMPTS_REMAIN="$(($ATTEMPTS_REMAIN-1))" + FAILED=1 + done + + if [ "$FAILED" -ne 0 ]; then + if [ "$CONTINUE_ON_FAILURE" -ne 1 ]; then + exit 1 + fi + + SUCCESS=0 + fi +} + +indent() { sed "s/^/ /"; } + +cygfullpath() { + result=$(echo "${1}" | tr \; \\n | while read -r element; do + if [ "${last}" != "" ]; then echo -n ":"; fi + echo -n $(cygpath "${element}") + last="${element}" + done) + if [ "${result}" = "" ]; then exit 1; fi + echo "${result}" +} + +if [[ "$(uname -s)" == MINGW* ]]; then + BUILD_PATH=$(cygfullpath "$BUILD_PATH") +fi + + +# Configure the test environment; run them early so that we're certain +# that they're started by the time we need them. + +echo "CTest version:" +env PATH="${BUILD_PATH}" "${CTEST}" --version | head -1 2>&1 | indent + +echo "" + +echo "##############################################################################" +echo "## Configuring test environment" +echo "##############################################################################" + +echo "" + +if [ -z "$SKIP_GITDAEMON_TESTS" ]; then + echo "Starting git daemon (standard)..." + GIT_STANDARD_DIR=`mktemp -d ${TMPDIR}/git_standard.XXXXXXXX` + git init --bare "${GIT_STANDARD_DIR}/test.git" >/dev/null + git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GIT_STANDARD_DIR}" "${GIT_STANDARD_DIR}" 2>/dev/null & + GIT_STANDARD_PID=$! + + echo "Starting git daemon (namespace)..." + GIT_NAMESPACE_DIR=`mktemp -d ${TMPDIR}/git_namespace.XXXXXXXX` + cp -R "${SOURCE_DIR}/tests/resources/namespace.git" "${GIT_NAMESPACE_DIR}/namespace.git" + GIT_NAMESPACE="name1" git daemon --listen=localhost --port=9419 --export-all --enable=receive-pack --base-path="${GIT_NAMESPACE_DIR}" "${GIT_NAMESPACE_DIR}" & + GIT_NAMESPACE_PID=$! + + echo "Starting git daemon (sha256)..." + GIT_SHA256_DIR=`mktemp -d ${TMPDIR}/git_sha256.XXXXXXXX` + cp -R "${SOURCE_DIR}/tests/resources/testrepo_256.git" "${GIT_SHA256_DIR}/testrepo_256.git" + git daemon --listen=localhost --port=9420 --export-all --enable=receive-pack --base-path="${GIT_SHA256_DIR}" "${GIT_SHA256_DIR}" & + GIT_SHA256_PID=$! +fi + +if [ -z "$SKIP_PROXY_TESTS" ]; then + curl --location --silent --show-error https://github.com/ethomson/poxyproxy/releases/download/v0.7.0/poxyproxy-0.7.0.jar >poxyproxy.jar + + echo "Starting HTTP proxy (Basic)..." + java -jar poxyproxy.jar --address 127.0.0.1 --port 8080 --credentials foo:bar --auth-type basic --quiet & + PROXY_BASIC_PID=$! + + echo "Starting HTTP proxy (NTLM)..." + java -jar poxyproxy.jar --address 127.0.0.1 --port 8090 --credentials foo:bar --auth-type ntlm --quiet & + PROXY_NTLM_PID=$! +fi + +if [ -z "$SKIP_NTLM_TESTS" -o -z "$SKIP_ONLINE_TESTS" ]; then + curl --location --silent --show-error https://github.com/ethomson/poxygit/releases/download/v0.6.0/poxygit-0.6.0.jar >poxygit.jar + + echo "Starting HTTP server..." + HTTP_DIR=`mktemp -d ${TMPDIR}/http.XXXXXXXX` + git init --bare "${HTTP_DIR}/test.git" + java -jar poxygit.jar --address 127.0.0.1 --port 9000 --credentials foo:baz --quiet "${HTTP_DIR}" & + HTTP_PID=$! +fi + +if [ -z "$SKIP_SSH_TESTS" ]; then + echo "Starting SSH server..." + SSHD_DIR=`mktemp -d ${TMPDIR}/sshd.XXXXXXXX` + git init --bare "${SSHD_DIR}/test.git" >/dev/null + cat >"${SSHD_DIR}/sshd_config" <<-EOF + Port 2222 + ListenAddress 0.0.0.0 + Protocol 2 + HostKey ${SSHD_DIR}/id_rsa + PidFile ${SSHD_DIR}/pid + AuthorizedKeysFile ${HOME}/.ssh/authorized_keys + LogLevel DEBUG + RSAAuthentication yes + PasswordAuthentication yes + PubkeyAuthentication yes + ChallengeResponseAuthentication no + StrictModes no + # Required here as sshd will simply close connection otherwise + UsePAM no + EOF + ssh-keygen -t rsa -f "${SSHD_DIR}/id_rsa" -N "" -q + /usr/sbin/sshd -f "${SSHD_DIR}/sshd_config" -E "${SSHD_DIR}/log" + + # Set up keys + mkdir "${HOME}/.ssh" + ssh-keygen -t rsa -f "${HOME}/.ssh/id_rsa" -N "" -q + cat "${HOME}/.ssh/id_rsa.pub" >>"${HOME}/.ssh/authorized_keys" + while read algorithm key comment; do + echo "[localhost]:2222 $algorithm $key" >>"${HOME}/.ssh/known_hosts" + done <"${SSHD_DIR}/id_rsa.pub" + + # Append the github.com keys for the tests that don't override checks. + # We ask for ssh-rsa to test that the selection based off of known_hosts + # is working. + ssh-keyscan -t ssh-rsa github.com >>"${HOME}/.ssh/known_hosts" + + # Get the fingerprint for localhost and remove the colons so we can + # parse it as a hex number. Older versions have a different output + # format. + if [[ $(ssh -V 2>&1) == OpenSSH_6* ]]; then + SSH_FINGERPRINT=$(ssh-keygen -F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':') + else + SSH_FINGERPRINT=$(ssh-keygen -E md5 -F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 3 | cut -d : -f2- | tr -d :) + fi +fi + +# Run the tests that do not require network connectivity. + +if [ -z "$SKIP_OFFLINE_TESTS" ]; then + echo "" + echo "##############################################################################" + echo "## Running core tests" + echo "##############################################################################" + + echo "" + echo "Running libgit2 integration (offline) tests" + echo "" + run_test offline + + echo "" + echo "Running utility tests" + echo "" + run_test util +fi + +if [ -n "$RUN_INVASIVE_TESTS" ]; then + echo "" + echo "Running invasive tests" + echo "" + + export GITTEST_INVASIVE_FS_SIZE=1 + export GITTEST_INVASIVE_MEMORY=1 + export GITTEST_INVASIVE_SPEED=1 + run_test invasive + unset GITTEST_INVASIVE_FS_SIZE + unset GITTEST_INVASIVE_MEMORY + unset GITTEST_INVASIVE_SPEED +fi + +if [ -z "$SKIP_ONLINE_TESTS" ]; then + # Run the online tests. The "online" test suite only includes the + # default online tests that do not require additional configuration. + # The "proxy" and "ssh" test suites require further setup. + + echo "" + echo "##############################################################################" + echo "## Running networking (online) tests" + echo "##############################################################################" + + export GITTEST_REMOTE_REDIRECT_INITIAL="http://localhost:9000/initial-redirect/libgit2/TestGitRepository" + export GITTEST_REMOTE_REDIRECT_SUBSEQUENT="http://localhost:9000/subsequent-redirect/libgit2/TestGitRepository" + export GITTEST_REMOTE_SPEED_SLOW="http://localhost:9000/speed-9600/test.git" + export GITTEST_REMOTE_SPEED_TIMESOUT="http://localhost:9000/speed-0.5/test.git" + run_test online + unset GITTEST_REMOTE_REDIRECT_INITIAL + unset GITTEST_REMOTE_REDIRECT_SUBSEQUENT + unset GITTEST_REMOTE_SPEED_SLOW + unset GITTEST_REMOTE_SPEED_TIMESOUT + + # Run the online tests that immutably change global state separately + # to avoid polluting the test environment. + echo "" + echo "Running custom certificate (online_customcert) tests" + echo "" + + run_test online_customcert +fi + +if [ -z "$SKIP_GITDAEMON_TESTS" ]; then + echo "" + echo "Running gitdaemon (standard) tests" + echo "" + + export GITTEST_REMOTE_URL="git://localhost/test.git" + run_test gitdaemon + unset GITTEST_REMOTE_URL + + echo "" + echo "Running gitdaemon (namespace) tests" + echo "" + + export GITTEST_REMOTE_URL="git://localhost:9419/namespace.git" + export GITTEST_REMOTE_BRANCH="four" + run_test gitdaemon_namespace + unset GITTEST_REMOTE_URL + unset GITTEST_REMOTE_BRANCH + + echo "" + echo "Running gitdaemon (sha256) tests" + echo "" + + export GITTEST_REMOTE_URL="git://localhost:9420/testrepo_256.git" + run_test gitdaemon_sha256 + unset GITTEST_REMOTE_URL +fi + +if [ -z "$SKIP_PROXY_TESTS" ]; then + echo "" + echo "Running proxy tests (Basic authentication)" + echo "" + + export GITTEST_REMOTE_PROXY_HOST="localhost:8080" + export GITTEST_REMOTE_PROXY_USER="foo" + export GITTEST_REMOTE_PROXY_PASS="bar" + run_test proxy + unset GITTEST_REMOTE_PROXY_HOST + unset GITTEST_REMOTE_PROXY_USER + unset GITTEST_REMOTE_PROXY_PASS + + echo "" + echo "Running proxy tests (NTLM authentication)" + echo "" + + export GITTEST_REMOTE_PROXY_HOST="localhost:8090" + export GITTEST_REMOTE_PROXY_USER="foo" + export GITTEST_REMOTE_PROXY_PASS="bar" + run_test proxy + unset GITTEST_REMOTE_PROXY_HOST + unset GITTEST_REMOTE_PROXY_USER + unset GITTEST_REMOTE_PROXY_PASS +fi + +if [ -z "$SKIP_NTLM_TESTS" ]; then + echo "" + echo "Running NTLM tests (IIS emulation)" + echo "" + + export GITTEST_REMOTE_URL="http://localhost:9000/ntlm/test.git" + export GITTEST_REMOTE_USER="foo" + export GITTEST_REMOTE_PASS="baz" + run_test auth_clone_and_push + unset GITTEST_REMOTE_URL + unset GITTEST_REMOTE_USER + unset GITTEST_REMOTE_PASS + + echo "" + echo "Running NTLM tests (Apache emulation)" + echo "" + + export GITTEST_REMOTE_URL="http://localhost:9000/broken-ntlm/test.git" + export GITTEST_REMOTE_USER="foo" + export GITTEST_REMOTE_PASS="baz" + run_test auth_clone_and_push + unset GITTEST_REMOTE_URL + unset GITTEST_REMOTE_USER + unset GITTEST_REMOTE_PASS +fi + +if [ -z "$SKIP_NEGOTIATE_TESTS" -a -n "$GITTEST_NEGOTIATE_PASSWORD" ]; then + echo "" + echo "Running SPNEGO tests" + echo "" + + if [ "$(uname -s)" = "Darwin" ]; then + KINIT_FLAGS="--password-file=STDIN" + fi + + echo $GITTEST_NEGOTIATE_PASSWORD | kinit $KINIT_FLAGS test@LIBGIT2.ORG + klist -5f + + export GITTEST_REMOTE_URL="https://test.libgit2.org/kerberos/empty.git" + export GITTEST_REMOTE_DEFAULT="true" + run_test auth_clone + unset GITTEST_REMOTE_URL + unset GITTEST_REMOTE_DEFAULT + + echo "" + echo "Running SPNEGO tests (expect/continue)" + echo "" + + export GITTEST_REMOTE_URL="https://test.libgit2.org/kerberos/empty.git" + export GITTEST_REMOTE_DEFAULT="true" + export GITTEST_REMOTE_EXPECTCONTINUE="true" + run_test auth_clone + unset GITTEST_REMOTE_URL + unset GITTEST_REMOTE_DEFAULT + unset GITTEST_REMOTE_EXPECTCONTINUE + + kdestroy -A +fi + +if [ -z "$SKIP_SSH_TESTS" ]; then + export GITTEST_REMOTE_USER=$USER + export GITTEST_REMOTE_SSH_KEY="${HOME}/.ssh/id_rsa" + export GITTEST_REMOTE_SSH_PUBKEY="${HOME}/.ssh/id_rsa.pub" + export GITTEST_REMOTE_SSH_PASSPHRASE="" + export GITTEST_REMOTE_SSH_FINGERPRINT="${SSH_FINGERPRINT}" + + echo "" + echo "Running ssh tests" + echo "" + + export GITTEST_REMOTE_URL="ssh://localhost:2222/$SSHD_DIR/test.git" + run_test ssh + unset GITTEST_REMOTE_URL + + echo "" + echo "Running ssh tests (scp-style paths)" + echo "" + + export GITTEST_REMOTE_URL="[localhost:2222]:$SSHD_DIR/test.git" + run_test ssh + unset GITTEST_REMOTE_URL + + unset GITTEST_REMOTE_USER + unset GITTEST_REMOTE_SSH_KEY + unset GITTEST_REMOTE_SSH_PUBKEY + unset GITTEST_REMOTE_SSH_PASSPHRASE + unset GITTEST_REMOTE_SSH_FINGERPRINT +fi + +if [ -z "$SKIP_FUZZERS" ]; then + echo "" + echo "##############################################################################" + echo "## Running fuzzers" + echo "##############################################################################" + + env PATH="${BUILD_PATH}" "${CTEST}" -V -R 'fuzzer' +fi + +cleanup + +if [ "$SUCCESS" -ne 1 ]; then + echo "Some tests failed." + exit 1 +fi + +echo "Success." +exit 0 |