1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-09 13:46:08 +02:00

Merge branch 'ps/ci-test-with-jgit' into seen

Tests to ensure interoperability between reftable written by jgit
and our code have been added and enabled in CI.

* ps/ci-test-with-jgit:
  t0612: add tests to exercise Git/JGit reftable compatibility
  t0610: fix non-portable variable assignment
  t06xx: always execute backend-specific tests
  ci: install JGit dependency
  ci: make Perforce binaries executable for all users
  ci: merge scripts which install dependencies
  ci: fix setup of custom path for GitLab CI
  ci: merge custom PATH directories
  ci: convert "install-dependencies.sh" to use "/bin/sh"
  ci: drop duplicate package installation for "linux-gcc-default"
  ci: skip sudo when we are already root
  ci: expose distro name in dockerized GitHub jobs
  ci: rename "runs_on_pool" to "distro"
This commit is contained in:
Junio C Hamano 2024-04-26 09:28:40 -07:00
commit 40d7122f50
9 changed files with 228 additions and 109 deletions

View File

@ -303,7 +303,7 @@ jobs:
CC: ${{matrix.vector.cc}}
CC_PACKAGE: ${{matrix.vector.cc_package}}
jobname: ${{matrix.vector.jobname}}
runs_on_pool: ${{matrix.vector.pool}}
distro: ${{matrix.vector.pool}}
runs-on: ${{matrix.vector.pool}}
steps:
- uses: actions/checkout@v4
@ -342,12 +342,16 @@ jobs:
vector:
- jobname: linux-musl
image: alpine
distro: alpine-latest
- jobname: linux32
image: daald/ubuntu32:xenial
distro: ubuntu32-16.04
- jobname: pedantic
image: fedora
distro: fedora-latest
env:
jobname: ${{matrix.vector.jobname}}
distro: ${{matrix.vector.distro}}
runs-on: ubuntu-latest
container: ${{matrix.vector.image}}
steps:
@ -355,7 +359,7 @@ jobs:
if: matrix.vector.jobname != 'linux32'
- uses: actions/checkout@v1 # cannot be upgraded because Node.js Actions aren't supported in this container
if: matrix.vector.jobname == 'linux32'
- run: ci/install-docker-dependencies.sh
- run: ci/install-dependencies.sh
- run: ci/run-build-and-tests.sh
- name: print test failures
if: failure() && env.FAILED_TEST_ARTIFACTS != ''

View File

@ -9,8 +9,10 @@ workflow:
test:linux:
image: $image
variables:
CUSTOM_PATH: "/custom"
before_script:
- ./ci/install-docker-dependencies.sh
- ./ci/install-dependencies.sh
script:
- useradd builder --create-home
- chown -R builder "${CI_PROJECT_DIR}"
@ -98,7 +100,7 @@ static-analysis:
variables:
jobname: StaticAnalysis
before_script:
- ./ci/install-docker-dependencies.sh
- ./ci/install-dependencies.sh
script:
- ./ci/run-static-analysis.sh
- ./ci/check-directional-formatting.bash

View File

@ -1,34 +1,69 @@
#!/usr/bin/env bash
#!/bin/sh
#
# Install dependencies required to build and test Git on Linux and macOS
#
. ${0%/*}/lib.sh
begin_group "Install dependencies"
P4WHENCE=https://cdist2.perforce.com/perforce/r21.2
LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION
UBUNTU_COMMON_PKGS="make libssl-dev libcurl4-openssl-dev libexpat-dev
tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl
libemail-valid-perl libio-socket-ssl-perl libnet-smtp-ssl-perl"
JGITWHENCE=https://repo.eclipse.org/content/groups/releases//org/eclipse/jgit/org.eclipse.jgit.pgm/6.8.0.202311291450-r/org.eclipse.jgit.pgm-6.8.0.202311291450-r.sh
case "$runs_on_pool" in
# Make sudo a no-op and execute the command directly when running as root.
# While using sudo would be fine on most platforms when we are root already,
# some platforms like e.g. Alpine Linux do not have sudo available by default
# and would thus break.
if test "$(id -u)" -eq 0
then
sudo () {
"$@"
}
fi
case "$distro" in
alpine-*)
apk add --update shadow sudo build-base curl-dev openssl-dev expat-dev gettext \
pcre2-dev python3 musl-libintl perl-utils ncurses \
apache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \
bash cvs gnupg perl-cgi perl-dbd-sqlite >/dev/null
;;
fedora-*)
dnf -yq update >/dev/null &&
dnf -yq install make gcc findutils diffutils perl python3 gettext zlib-devel expat-devel openssl-devel curl-devel pcre2-devel >/dev/null
;;
ubuntu-*)
# Required so that apt doesn't wait for user input on certain packages.
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -q update
sudo apt-get -q -y install language-pack-is libsvn-perl apache2 \
$UBUNTU_COMMON_PKGS $CC_PACKAGE $PYTHON_PACKAGE
mkdir --parents "$P4_PATH"
pushd "$P4_PATH"
wget --quiet "$P4WHENCE/bin.linux26x86_64/p4d"
wget --quiet "$P4WHENCE/bin.linux26x86_64/p4"
chmod u+x p4d
chmod u+x p4
popd
mkdir --parents "$GIT_LFS_PATH"
pushd "$GIT_LFS_PATH"
wget --quiet "$LFSWHENCE/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
tar --extract --gunzip --file "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
cp git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs .
popd
sudo apt-get -q -y install \
language-pack-is libsvn-perl apache2 cvs cvsps git gnupg subversion \
make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \
tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl \
libemail-valid-perl libio-socket-ssl-perl libnet-smtp-ssl-perl libdbd-sqlite3-perl libcgi-pm-perl \
${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE
mkdir --parents "$CUSTOM_PATH"
wget --quiet --directory-prefix="$CUSTOM_PATH" \
"$P4WHENCE/bin.linux26x86_64/p4d" "$P4WHENCE/bin.linux26x86_64/p4"
chmod a+x "$CUSTOM_PATH/p4d" "$CUSTOM_PATH/p4"
wget --quiet "$LFSWHENCE/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
tar -xzf "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" \
-C "$CUSTOM_PATH" --strip-components=1 "git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs"
rm "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
wget --quiet "$JGITWHENCE" --output-document="$CUSTOM_PATH/jgit"
chmod a+x "$CUSTOM_PATH/jgit"
;;
ubuntu32-*)
sudo linux32 --32bit i386 sh -c '
apt update >/dev/null &&
apt install -y build-essential libcurl4-openssl-dev \
libssl-dev libexpat-dev gettext python >/dev/null
'
;;
macos-*)
export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1
@ -38,12 +73,11 @@ macos-*)
brew install $BREW_INSTALL_PACKAGES
brew link --force gettext
mkdir -p "$P4_PATH"
pushd "$P4_PATH"
wget -q "$P4WHENCE/bin.macosx1015x86_64/helix-core-server.tgz" &&
tar -xf helix-core-server.tgz &&
sudo xattr -d com.apple.quarantine p4 p4d 2>/dev/null || true
popd
mkdir -p "$CUSTOM_PATH"
wget -q "$P4WHENCE/bin.macosx1015x86_64/helix-core-server.tgz" &&
tar -xf helix-core-server.tgz -C "$CUSTOM_PATH" p4 p4d &&
sudo xattr -d com.apple.quarantine "$CUSTOM_PATH/p4" "$CUSTOM_PATH/p4d" 2>/dev/null || true
rm helix-core-server.tgz
if test -n "$CC_PACKAGE"
then
@ -72,10 +106,6 @@ Documentation)
test -n "$ALREADY_HAVE_ASCIIDOCTOR" ||
sudo gem install --version 1.5.8 asciidoctor
;;
linux-gcc-default)
sudo apt-get -q update
sudo apt-get -q -y install $UBUNTU_COMMON_PKGS
;;
esac
if type p4d >/dev/null 2>&1 && type p4 >/dev/null 2>&1
@ -87,6 +117,7 @@ then
else
echo >&2 "WARNING: perforce wasn't installed, see above for clues why"
fi
if type git-lfs >/dev/null 2>&1
then
echo "$(tput setaf 6)Git-LFS Version$(tput sgr0)"
@ -94,3 +125,13 @@ then
else
echo >&2 "WARNING: git-lfs wasn't installed, see above for clues why"
fi
if type jgit >/dev/null 2>&1
then
echo "$(tput setaf 6)JGit Version$(tput sgr0)"
jgit version
else
echo >&2 "WARNING: JGit wasn't installed, see above for clues why"
fi
end_group "Install dependencies"

View File

@ -1,46 +0,0 @@
#!/bin/sh
#
# Install dependencies required to build and test Git inside container
#
. ${0%/*}/lib.sh
begin_group "Install dependencies"
case "$jobname" in
linux32)
linux32 --32bit i386 sh -c '
apt update >/dev/null &&
apt install -y build-essential libcurl4-openssl-dev \
libssl-dev libexpat-dev gettext python >/dev/null
'
;;
linux-musl)
apk add --update shadow sudo build-base curl-dev openssl-dev expat-dev gettext \
pcre2-dev python3 musl-libintl perl-utils ncurses \
apache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \
bash cvs gnupg perl-cgi perl-dbd-sqlite >/dev/null
;;
linux-*|StaticAnalysis)
# Required so that apt doesn't wait for user input on certain packages.
export DEBIAN_FRONTEND=noninteractive
apt update -q &&
apt install -q -y sudo git make language-pack-is libsvn-perl apache2 libssl-dev \
libcurl4-openssl-dev libexpat-dev tcl tk gettext zlib1g-dev \
perl-modules liberror-perl libauthen-sasl-perl libemail-valid-perl \
libdbd-sqlite3-perl libio-socket-ssl-perl libnet-smtp-ssl-perl ${CC_PACKAGE:-${CC:-gcc}} \
apache2 cvs cvsps gnupg libcgi-pm-perl subversion
if test "$jobname" = StaticAnalysis
then
apt install -q -y coccinelle
fi
;;
pedantic)
dnf -yq update >/dev/null &&
dnf -yq install make gcc findutils diffutils perl python3 gettext zlib-devel expat-devel openssl-devel curl-devel pcre2-devel >/dev/null
;;
esac
end_group "Install dependencies"

View File

@ -279,7 +279,7 @@ then
cache_dir="$HOME/none"
runs_on_pool=$(echo "$CI_JOB_IMAGE" | tr : -)
distro=$(echo "$CI_JOB_IMAGE" | tr : -)
JOBS=$(nproc)
else
echo "Could not identify CI type" >&2
@ -318,7 +318,7 @@ export DEFAULT_TEST_TARGET=prove
export GIT_TEST_CLONE_2GB=true
export SKIP_DASHED_BUILT_INS=YesPlease
case "$runs_on_pool" in
case "$distro" in
ubuntu-*)
if test "$jobname" = "linux-gcc-default"
then
@ -340,10 +340,6 @@ ubuntu-*)
# image.
# Keep that in mind when you encounter a broken OS X build!
export LINUX_GIT_LFS_VERSION="1.5.2"
P4_PATH="$HOME/custom/p4"
GIT_LFS_PATH="$HOME/custom/git-lfs"
export PATH="$GIT_LFS_PATH:$P4_PATH:$PATH"
;;
macos-*)
MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=$(which python3)"
@ -351,12 +347,12 @@ macos-*)
then
MAKEFLAGS="$MAKEFLAGS APPLE_COMMON_CRYPTO_SHA1=Yes"
fi
P4_PATH="$HOME/custom/p4"
export PATH="$P4_PATH:$PATH"
;;
esac
CUSTOM_PATH="${CUSTOM_PATH:-$HOME/path}"
export PATH="$CUSTOM_PATH:$PATH"
case "$jobname" in
linux32)
CC=gcc

View File

@ -4,16 +4,12 @@ test_description='Test reffiles backend'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
GIT_TEST_DEFAULT_REF_FORMAT=files
export GIT_TEST_DEFAULT_REF_FORMAT
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
if ! test_have_prereq REFFILES
then
skip_all='skipping reffiles specific tests'
test_done
fi
test_expect_success 'setup' '
git commit --allow-empty -m Initial &&
C=$(git rev-parse HEAD) &&

View File

@ -9,18 +9,15 @@ test_description='git pack-refs should not change the branch semantic
This test runs git pack-refs and git show-ref and checks that the branch
semantic is still the same.
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
GIT_TEST_DEFAULT_REF_FORMAT=files
export GIT_TEST_DEFAULT_REF_FORMAT
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
if ! test_have_prereq REFFILES
then
skip_all='skipping reffiles specific tests'
test_done
fi
test_expect_success 'enable reflogs' '
git config core.logallrefupdates true
'

View File

@ -4,17 +4,14 @@
#
test_description='reftable basics'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
GIT_TEST_DEFAULT_REF_FORMAT=reftable
export GIT_TEST_DEFAULT_REF_FORMAT
. ./test-lib.sh
if ! test_have_prereq REFTABLE
then
skip_all='skipping reftable tests; set GIT_TEST_DEFAULT_REF_FORMAT=reftable'
test_done
fi
INVALID_OID=$(test_oid 001)
test_expect_success 'init: creates basic reftable structures' '
@ -81,8 +78,8 @@ test_expect_success 'init: reinitializing reftable with files backend fails' '
'
test_expect_perms () {
local perms="$1"
local file="$2"
local perms="$1" &&
local file="$2" &&
local actual="$(ls -l "$file")" &&
case "$actual" in

View File

@ -0,0 +1,132 @@
#!/bin/sh
test_description='reftables are compatible with JGit'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
GIT_TEST_DEFAULT_REF_FORMAT=reftable
export GIT_TEST_DEFAULT_REF_FORMAT
# JGit does not support the 'link' DIRC extension.
GIT_TEST_SPLIT_INDEX=0
export GIT_TEST_SPLIT_INDEX
. ./test-lib.sh
if ! test_have_prereq JGIT
then
skip_all='skipping reftable JGit tests; JGit is not present in PATH'
test_done
fi
if ! test_have_prereq SHA1
then
skip_all='skipping reftable JGit tests; JGit does not support SHA256 reftables'
test_done
fi
test_commit_jgit () {
touch "$1" &&
jgit add "$1" &&
jgit commit -m "$1"
}
test_same_refs () {
git show-ref --head >cgit.actual &&
jgit show-ref >jgit-tabs.actual &&
tr "\t" " " <jgit-tabs.actual >jgit.actual &&
test_cmp cgit.actual jgit.actual
}
test_same_ref () {
git rev-parse "$1" >cgit.actual &&
jgit rev-parse "$1" >jgit.actual &&
test_cmp cgit.actual jgit.actual
}
test_same_reflog () {
git reflog "$*" >cgit.actual &&
jgit reflog "$*" >jgit-newline.actual &&
sed '/^$/d' <jgit-newline.actual >jgit.actual &&
test_cmp cgit.actual jgit.actual
}
test_expect_success 'CGit repository can be read by JGit' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
cd repo &&
test_commit A &&
test_same_refs &&
test_same_ref HEAD &&
test_same_reflog HEAD
)
'
test_expect_success 'JGit repository can be read by CGit' '
test_when_finished "rm -rf repo" &&
jgit init repo &&
(
cd repo &&
touch file &&
jgit add file &&
jgit commit -m "initial commit" &&
# Note that we must convert the ref storage after we have
# written the default branch. Otherwise JGit will end up with
# no HEAD at all.
jgit convert-ref-storage --format=reftable &&
test_same_refs &&
test_same_ref HEAD &&
# Interestingly, JGit cannot read its own reflog here. CGit can
# though.
printf "%s HEAD@{0}: commit (initial): initial commit" "$(git rev-parse --short HEAD)" >expect &&
git reflog HEAD >actual &&
test_cmp expect actual
)
'
test_expect_success 'mixed writes from JGit and CGit' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
cd repo &&
test_commit A &&
test_commit_jgit B &&
test_commit C &&
test_commit_jgit D &&
test_same_refs &&
test_same_ref HEAD &&
test_same_reflog HEAD
)
'
test_expect_success 'JGit can read multi-level index' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
cd repo &&
test_commit A &&
awk "
BEGIN {
print \"start\";
for (i = 0; i < 10000; i++)
printf \"create refs/heads/branch-%d HEAD\n\", i;
print \"commit\";
}
" >input &&
git update-ref --stdin <input &&
test_same_refs &&
test_same_ref refs/heads/branch-1 &&
test_same_ref refs/heads/branch-5738 &&
test_same_ref refs/heads/branch-9999
)
'
test_done