# [PATCH 0/4] Add a CI for unsigned char system

9 messages from 2023-03-03 to 2023-03-09. Participants: Đoàn Trần Công Danh, Jeff King, Chris Torek.
Thread: https://gitlist.dev/t/59335

## Đoàn Trần Công Danh, 2023-03-03 13:46

Subject: [PATCH 0/4] Add a CI for unsigned char system
Message-ID: <cover.1677850517.git.congdanhqx@gmail.com>
URL: https://gitlist.dev/e/cover.1677850517.git.congdanhqx%40gmail.com

```
Recently, we have a brokeness on system with unsigned char because most of
people are working with x86_64 which has signed char.

This series tries to add a CI system for a widely used system with signed
char, which is arm64 via circle-ci.

In order to register for git to participate in Circle CI, you need to:
- Create an account and login into Circle CI, (I tried login with GitHub OAuth);
- Register a project with Circle CI, and choose which config.yml we would like
  to be used for Circle CI

Circle CI seems to allow 40000 (Forty thousand credits per month), in my
testing, with resource_class: 'arm.medium', (which costs 10 credits per minute),
it take 12m15s to finish, so that will be about 3000 run per month. I believe
arm.large, which is also available to free accounts and cost 20 credits per
minute, doesn't cost effective but I haven't checked out.

Sample run:
- Without the fix for unsigned char:
  https://app.circleci.com/pipelines/gh/sgn/git/12/workflows/9b39391d-0d03-4669-86e6-2796fd671c43/jobs/10
- Normal run:
  https://app.circleci.com/pipelines/gh/sgn/git/14/workflows/b8745f8e-8a57-4215-847e-2af66c1dd3c7/jobs/12

I'm not really sure if we want the 'store_test_results', which will upload the
test report in the 'TESTS' tab:
https://app.circleci.com/pipelines/gh/sgn/git/14/workflows/b8745f8e-8a57-4215-847e-2af66c1dd3c7/jobs/12/tests
and provides a test insights like this:
https://app.circleci.com/insights/gh/sgn/git/workflows/workflow/tests?branch=circle-ci

Đoàn Trần Công Danh (4):
  ci/lib.sh: remove an useless break
  ci/install-dependencies: libify p4 and git-lfs installation
  ci/install-dependencies: install git-lfs for arm64 build
  ci: add arm64 CI environment via CircleCI

 .circleci/config.yml       | 17 +++++++++++++++
 ci/install-dependencies.sh | 42 ++++++++++++++++++++++++++++++--------
 ci/lib.sh                  | 30 ++++++++++++++++++++++-----
 3 files changed, 75 insertions(+), 14 deletions(-)
 create mode 100644 .circleci/config.yml

-- 
2.40.0.rc1.2.gd15644fe02


```

## Đoàn Trần Công Danh, 2023-03-03 13:46

Subject: [PATCH 1/4] ci/lib.sh: remove an useless break
Message-ID: <c7312724f8a7ec9ccf63fb0621a996ebad3c6128.1677850518.git.congdanhqx@gmail.com>
URL: https://gitlist.dev/e/c7312724f8a7ec9ccf63fb0621a996ebad3c6128.1677850518.git.congdanhqx%40gmail.com
In-Reply-To: <cover.1677850517.git.congdanhqx@gmail.com>

```
This statement was silently skipped for a long time.

> ci/lib.sh: line 232: break: only meaningful in a `for', `while', or `until' loop

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 ci/lib.sh | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/ci/lib.sh b/ci/lib.sh
index db7105e8a8..661076e70b 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -227,11 +227,6 @@ export SKIP_DASHED_BUILT_INS=YesPlease
 
 case "$runs_on_pool" in
 ubuntu-*)
-	if test "$jobname" = "linux-gcc-default"
-	then
-		break
-	fi
-
 	PYTHON_PACKAGE=python2
 	if test "$jobname" = linux-gcc
 	then
-- 
2.40.0.rc1.2.gd15644fe02


```

## Đoàn Trần Công Danh, 2023-03-03 13:46

Subject: [PATCH 2/4] ci/install-dependencies: libify p4 and git-lfs installation
Message-ID: <13137839f39bdcbc56eae9e96894b5ebe4072374.1677850518.git.congdanhqx@gmail.com>
URL: https://gitlist.dev/e/13137839f39bdcbc56eae9e96894b5ebe4072374.1677850518.git.congdanhqx%40gmail.com
In-Reply-To: <cover.1677850517.git.congdanhqx@gmail.com>

```
In a later change, we will install git-lfs for CircleCI test
environment. Let move those installations out in order to reuse them.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 ci/install-dependencies.sh | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh
index 4f407530d3..9a32af8968 100755
--- a/ci/install-dependencies.sh
+++ b/ci/install-dependencies.sh
@@ -6,16 +6,12 @@
 . ${0%/*}/lib.sh
 
 P4WHENCE=https://cdist2.perforce.com/perforce/r21.2
-LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION
+LFSWHENCE=https://github.com/github/git-lfs/releases/download
 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"
 
-case "$runs_on_pool" in
-ubuntu-*)
-	sudo apt-get -q update
-	sudo apt-get -q -y install language-pack-is libsvn-perl apache2 \
-		$UBUNTU_COMMON_PKGS $CC_PACKAGE $PYTHON_PACKAGE
+_install_linux_p4() {
 	mkdir --parents "$P4_PATH"
 	pushd "$P4_PATH"
 		wget --quiet "$P4WHENCE/bin.linux26x86_64/p4d"
@@ -23,12 +19,36 @@ ubuntu-*)
 		chmod u+x p4d
 		chmod u+x p4
 	popd
+}
+
+_install_linux_git_lfs() {
+	local whence fname
+	whence="$1"
+	fname="$2"
 	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 .
+		wget --quiet "$whence/$fname"
+		tar --extract --gunzip --strip-components=1 --file "$fname"
 	popd
+}
+
+case "$runs_on_pool" in
+ubuntu-*)
+	sudo apt-get -q update
+	sudo apt-get -q -y install language-pack-is libsvn-perl apache2 \
+		$UBUNTU_COMMON_PKGS $CC_PACKAGE $PYTHON_PACKAGE
+
+	case "$(uname -m)" in
+	x86_64)
+		_install_linux_p4
+		_install_linux_git_lfs "$LFSWHENCE/v${LINUX_GIT_LFS_VERSION}" \
+			"git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
+		;;
+	*)
+		echo "Not supported architecture" >&2
+		exit 1
+		;;
+	esac
 	;;
 macos-*)
 	export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1
-- 
2.40.0.rc1.2.gd15644fe02


```

## Đoàn Trần Công Danh, 2023-03-03 13:46

Subject: [PATCH 3/4] ci/install-dependencies: install git-lfs for arm64 build
Message-ID: <f8663249619f519157a19a2fa8f386dbbe23faba.1677850518.git.congdanhqx@gmail.com>
URL: https://gitlist.dev/e/f8663249619f519157a19a2fa8f386dbbe23faba.1677850518.git.congdanhqx%40gmail.com
In-Reply-To: <cover.1677850517.git.congdanhqx@gmail.com>

```
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 ci/install-dependencies.sh | 4 ++++
 ci/lib.sh                  | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh
index 9a32af8968..6d587ffc54 100755
--- a/ci/install-dependencies.sh
+++ b/ci/install-dependencies.sh
@@ -44,6 +44,10 @@ ubuntu-*)
 		_install_linux_git_lfs "$LFSWHENCE/v${LINUX_GIT_LFS_VERSION}" \
 			"git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
 		;;
+	aarch64)
+		_install_linux_git_lfs "$LFSWHENCE/v${LINUX_GIT_LFS_VERSION}" \
+			"git-lfs-linux-arm64-v$LINUX_GIT_LFS_VERSION.tar.gz"
+		;;
 	*)
 		echo "Not supported architecture" >&2
 		exit 1
diff --git a/ci/lib.sh b/ci/lib.sh
index 661076e70b..3c19267a56 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -242,6 +242,12 @@ ubuntu-*)
 	# image.
 	# Keep that in mind when you encounter a broken OS X build!
 	export LINUX_GIT_LFS_VERSION="1.5.2"
+	# The Linux arm64 build installs yet another recent version, since
+	# above version doesn't ship prebuilt binaries for arm64.
+	if test "$(uname -m)" = aarch64
+	then
+		LINUX_GIT_LFS_VERSION="3.3.0"
+	fi
 
 	P4_PATH="$HOME/custom/p4"
 	GIT_LFS_PATH="$HOME/custom/git-lfs"
-- 
2.40.0.rc1.2.gd15644fe02


```

## Đoàn Trần Công Danh, 2023-03-03 13:46

Subject: [PATCH 4/4] ci: add arm64 CI environment via CircleCI
Message-ID: <db5c58fb3ee114b56f110dcd20f938e77d8b476f.1677850518.git.congdanhqx@gmail.com>
URL: https://gitlist.dev/e/db5c58fb3ee114b56f110dcd20f938e77d8b476f.1677850518.git.congdanhqx%40gmail.com
In-Reply-To: <cover.1677850517.git.congdanhqx@gmail.com>

```
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 .circleci/config.yml | 17 +++++++++++++++++
 ci/lib.sh            | 19 +++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 .circleci/config.yml

diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000000..2f5e0966b7
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,17 @@
+# .circleci/config.yml
+jobs:
+  build:
+    machine:
+      image: ubuntu-2004:2022.04.1
+    resource_class: arm.medium
+    environment:
+      jobname: linux-gcc
+      runs_on_pool: ubuntu-arm64
+    steps:
+    - checkout
+    - run: ci/install-dependencies.sh
+    - run:
+        name: Build and Tests
+        command: ci/run-build-and-tests.sh
+    - store_test_results:
+        path: t/out
diff --git a/ci/lib.sh b/ci/lib.sh
index 3c19267a56..8b0c727950 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -201,6 +201,25 @@ then
 	MAKEFLAGS="$MAKEFLAGS --jobs=10"
 	test windows != "$CI_OS_NAME" ||
 	GIT_TEST_OPTS="--no-chain-lint --no-bin-wrappers $GIT_TEST_OPTS"
+elif test "$CIRCLECI" = true
+then
+	CI_TYPE=circleci
+	CI_BRANCH="$CIRCLE_BRANCH"
+	CI_COMMIT="$CIRCLE_SHA1"
+	CI_JOB_ID="$CIRCLE_WORKFLOW_JOB_ID"
+	CI_JOB_NUMBER="$CIRCLE_BUILD_NUM"
+	CI_OS_NAME="$(echo "$AGENT_OS" | tr A-Z a-z)"
+	test darwin != "$CI_OS_NAME" || CI_OS_NAME=osx
+	CI_REPO_SLUG="$(expr "$CIRCLE_REPOSITORY_URL" : '.*:\([^/]*/[^/]*\)\.git$')"
+	CC="${CC:-gcc}"
+
+	# use a subdirectory of the cache dir (because the file share is shared
+	# among *all* phases)
+	cache_dir="$HOME/none"
+
+	export GIT_PROVE_OPTS="--timer --jobs 10"
+	export GIT_TEST_OPTS="--verbose-log -x --write-junit-xml"
+	MAKEFLAGS="$MAKEFLAGS --jobs=10"
 else
 	echo "Could not identify CI type" >&2
 	env >&2
-- 
2.40.0.rc1.2.gd15644fe02


```

## Đoàn Trần Công Danh, 2023-03-03 13:54

Subject: Re: [PATCH 4/4] ci: add arm64 CI environment via CircleCI
Message-ID: <ZAH8McPd56NSAzOx@danh.dev>
URL: https://gitlist.dev/e/ZAH8McPd56NSAzOx%40danh.dev
In-Reply-To: <db5c58fb3ee114b56f110dcd20f938e77d8b476f.1677850518.git.congdanhqx@gmail.com>

```
On 2023-03-03 20:46:06+0700, Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:
> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
> ---
>  .circleci/config.yml | 17 +++++++++++++++++
>  ci/lib.sh            | 19 +++++++++++++++++++
>  2 files changed, 36 insertions(+)
>  create mode 100644 .circleci/config.yml
> 
> diff --git a/.circleci/config.yml b/.circleci/config.yml
> new file mode 100644
> index 0000000000..2f5e0966b7
> --- /dev/null
> +++ b/.circleci/config.yml
> @@ -0,0 +1,17 @@
> +# .circleci/config.yml
> +jobs:
> +  build:
> +    machine:
> +      image: ubuntu-2004:2022.04.1
> +    resource_class: arm.medium
> +    environment:
> +      jobname: linux-gcc
> +      runs_on_pool: ubuntu-arm64
> +    steps:
> +    - checkout
> +    - run: ci/install-dependencies.sh
> +    - run:
> +        name: Build and Tests
> +        command: ci/run-build-and-tests.sh
> +    - store_test_results:
> +        path: t/out
> diff --git a/ci/lib.sh b/ci/lib.sh
> index 3c19267a56..8b0c727950 100755
> --- a/ci/lib.sh
> +++ b/ci/lib.sh
> @@ -201,6 +201,25 @@ then
>  	MAKEFLAGS="$MAKEFLAGS --jobs=10"
>  	test windows != "$CI_OS_NAME" ||
>  	GIT_TEST_OPTS="--no-chain-lint --no-bin-wrappers $GIT_TEST_OPTS"
> +elif test "$CIRCLECI" = true
> +then
> +	CI_TYPE=circleci
> +	CI_BRANCH="$CIRCLE_BRANCH"
> +	CI_COMMIT="$CIRCLE_SHA1"
> +	CI_JOB_ID="$CIRCLE_WORKFLOW_JOB_ID"
> +	CI_JOB_NUMBER="$CIRCLE_BUILD_NUM"
> +	CI_OS_NAME="$(echo "$AGENT_OS" | tr A-Z a-z)"

Oops, this is wrong, it should be:

	CI_OS_NAME="$(uname -s)-$(uname -m)"

> +	test darwin != "$CI_OS_NAME" || CI_OS_NAME=osx
> +	CI_REPO_SLUG="$(expr "$CIRCLE_REPOSITORY_URL" : '.*:\([^/]*/[^/]*\)\.git$')"
> +	CC="${CC:-gcc}"
> +
> +	# use a subdirectory of the cache dir (because the file share is shared
> +	# among *all* phases)
> +	cache_dir="$HOME/none"
> +
> +	export GIT_PROVE_OPTS="--timer --jobs 10"
> +	export GIT_TEST_OPTS="--verbose-log -x --write-junit-xml"
> +	MAKEFLAGS="$MAKEFLAGS --jobs=10"
>  else
>  	echo "Could not identify CI type" >&2
>  	env >&2
> -- 
> 2.40.0.rc1.2.gd15644fe02
> 

-- 
Danh

```

## Jeff King, 2023-03-09 09:53

Subject: Re: [PATCH 0/4] Add a CI for unsigned char system
Message-ID: <ZAmsikbYncUbNjD2@coredump.intra.peff.net>
URL: https://gitlist.dev/e/ZAmsikbYncUbNjD2%40coredump.intra.peff.net
In-Reply-To: <cover.1677850517.git.congdanhqx@gmail.com>

```
On Fri, Mar 03, 2023 at 08:46:02PM +0700, Đoàn Trần Công Danh wrote:

> Recently, we have a brokeness on system with unsigned char because most of
> people are working with x86_64 which has signed char.
> 
> This series tries to add a CI system for a widely used system with signed
> char, which is arm64 via circle-ci.

I like the overall goal, but I'm not wild about having another CI
provider. That requires people logging in there, and then dealing with
possible credit overages, etc.

I wonder what the timeline is for GitHub Actions getting arm64 support.
It looks like there are images for linux/arm64, but no runners yet,
according to:

  https://github.com/actions/runner-images/issues/5631

You can point it at your own runners, and some people in that thread
mentioned a third-party service which provides arm machines. That
doesn't get out of the "oops, credits" handling, but it would at least
keep the CI results all together.

I dunno. Another option I saw suggested is using qemu within a regular
GitHub runner. I have no idea if that would be painfully slow or what,
but it looks like people have even written actions to handle it:

  https://github.com/docker/setup-qemu-action

-Peff

```

## Chris Torek, 2023-03-09 10:26

Subject: Re: [PATCH 0/4] Add a CI for unsigned char system
Message-ID: <CAPx1GveS2=8-rh6PVFsOXLvJ4iZGzeo9uUdG=wcbophxiDam0g@mail.gmail.com>
URL: https://gitlist.dev/e/CAPx1GveS2%3D8-rh6PVFsOXLvJ4iZGzeo9uUdG%3DwcbophxiDam0g%40mail.gmail.com
In-Reply-To: <ZAmsikbYncUbNjD2@coredump.intra.peff.net>

```
On Thu, Mar 9, 2023 at 1:54 AM Jeff King <peff@peff.net> wrote:
> I like the overall goal, but I'm not wild about having another CI
> provider.

So, why not do an x86 build with `-funsigned-char`? Seems to work with
both gcc and clang.

Chris

```

## Jeff King, 2023-03-09 10:57

Subject: Re: [PATCH 0/4] Add a CI for unsigned char system
Message-ID: <ZAm7mpf36IOCqgN4@coredump.intra.peff.net>
URL: https://gitlist.dev/e/ZAm7mpf36IOCqgN4%40coredump.intra.peff.net
In-Reply-To: <CAPx1GveS2=8-rh6PVFsOXLvJ4iZGzeo9uUdG=wcbophxiDam0g@mail.gmail.com>

```
On Thu, Mar 09, 2023 at 02:26:34AM -0800, Chris Torek wrote:

> On Thu, Mar 9, 2023 at 1:54 AM Jeff King <peff@peff.net> wrote:
> > I like the overall goal, but I'm not wild about having another CI
> > provider.
> 
> So, why not do an x86 build with `-funsigned-char`? Seems to work with
> both gcc and clang.

Yeah, that would be even simpler. Though IMHO "unsigned char" is only
one interesting difference to be checking. Another would be having a
platform where unaligned access isn't tolerated. It would be nice to
have a big-endian platform, too, but I'm not sure if arm is a good fit
there (my impression is that it can be run in either mode?).

On the other hand, I think Ævar does periodically run on the gcc build
machines, which includes examples of each (including aarch64). And this
particular bug was found pretty quickly (within a week of it hitting
next, and only a day after hitting master). So while it might be nice to
have more immediate CI feedback, it does seem like the old "if the
platform matters, somebody will try it and report the problem" strategy
still works, too.

-Peff

```
