git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: git@vger.kernel.org
Subject: Use docker for _some_ testing?
Date: Wed, 22 Jun 2016 21:01:55 +0200	[thread overview]
Message-ID: <20160622190154.GA17442@duynguyen> (raw)

The story started with my problem on Debian, which I didn't have and
didn't want to install a Debian VM just for that problem. So I made a
docker image with the following script.

Which makes me think, could we use something like this to make sure
people (on Linux) can test more obscure cases? Sometimes there are
featues that require some dependencies that are not always present on
the developer's machine (http server is a big one, locales come close
second, then there will be lmdb and watchman in future...). With this,
said developer can do a final test run in docker covering as much as
possible.

Of course it can't cover everything. Different compiler versions are
out. OS-specific changes are out (but wine would be still good to test
some aspect of Windows port, or at least make sure it builds)

Comments?

-- 8< --
diff --git a/contrib/docker/locale.gen b/contrib/docker/locale.gen
new file mode 100644
index 0000000..ef08e00
--- /dev/null
+++ b/contrib/docker/locale.gen
@@ -0,0 +1,2 @@
+is_IS.UTF-8 UTF-8
+is_IS ISO-8859-1
\ No newline at end of file
diff --git a/contrib/docker/run.sh b/contrib/docker/run.sh
new file mode 100755
index 0000000..83e5679
--- /dev/null
+++ b/contrib/docker/run.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+die() {
+	echo "$@" >&2
+	exit 1
+}
+
+build_debian() {
+	cat >Dockerfile <<-EOF
+	FROM debian:latest
+	RUN apt-get update && \
+		apt-get install -y libcurl4-gnutls-dev libexpat1-dev \
+		gettext libz-dev libssl-dev build-essential
+	RUN apt-get install -y locales
+	COPY locale.gen /etc/locale.gen
+	RUN locale-gen
+	RUN groupadd -r $(id -gn) -g $(id -g) && \
+		useradd -u $(id -u) -r -d "$HOME" -g $(id -g) -s /sbin/nologin $(id -un)
+	USER $(id -un)
+	EOF
+	docker build -t $IMAGE .  || die "failed to build docker image"
+}
+
+DISTRO=debian
+IMAGE=git-$DISTRO-$(id -un)
+ROOT="$(realpath $(git rev-parse --show-cdup))"
+
+test "$(docker images --format='{{.Repository}}' $IMAGE)" = $IMAGE || \
+	build_$DISTRO
+docker run -it --rm -v "$ROOT":"$ROOT" -w "$(pwd)" $IMAGE bash
-- 8< --
--
Duy

             reply	other threads:[~2016-06-22 19:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-22 19:01 Duy Nguyen [this message]
2016-06-22 19:33 ` Use docker for _some_ testing? Junio C Hamano
2016-06-22 19:59 ` Jeff King
2016-06-23  4:14   ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160622190154.GA17442@duynguyen \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).