Skip to content

Commit

Permalink
Run tests on multiple Bash and Git versions
Browse files Browse the repository at this point in the history
Now Elegant Git is tested on 2 Git and 3 Bash versions (6 environments
in total). All testing happens within Docker containers that work in
parallel. The overall workflow is the following:
1. `workflows` runs a given command
2. the command starts a needed number of containers in parallel, waits
   until they are exited, and reports the status

Such a running scheme allows to run more tests and total duration is
equal to the duration of the longest test execution.

From the technical side, the worker containers don't package the
appropriate workflows scripts, they just configure them by default. This
allows making script changes without rebuilding the images. Also, as
usual, all workers bind the source files in the container's volume and
use them for the execution.
  • Loading branch information
extsoft committed Jun 22, 2020
1 parent 1a01665 commit 6f67027
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 109 deletions.
61 changes: 53 additions & 8 deletions .workflows/bats/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,60 @@
ARG bashversion=3.2.57
FROM alpine:3.12.0 as git
RUN apk add --no-cache \
zlib-dev \
openssl-dev \
curl-dev \
curl \
expat-dev \
perl-dev \
python3-dev \
pcre2-dev \
asciidoc \
xmlto \
perl-error \
tcl \
tk \
make \
gcc \
g++
WORKDIR /src
ARG gitversion=2.26.2
RUN curl --output git-${gitversion}.tar.gz \
https://mirrors.edge.kernel.org/pub/software/scm/git/git-${gitversion}.tar.gz && \
tar -xvzf git-${gitversion}.tar.gz
RUN export TO=/git && \
mkdir -p ${TO} && \
cd git-${gitversion} && \
make prefix=/usr DESTDIR=${TO} NO_GETTEXT=YesPlease NO_REGEX=YesPlease ICONV_OMITS_BOM=Yes && \
make prefix=/usr DESTDIR=${TO} NO_GETTEXT=YesPlease NO_REGEX=YesPlease ICONV_OMITS_BOM=Yes strip && \
make prefix=/usr DESTDIR=${TO} NO_GETTEXT=YesPlease NO_REGEX=YesPlease ICONV_OMITS_BOM=Yes install && \
# remove files that aren't part of standard package
rm /git/usr/libexec/git-core/git-cvs* && \
rm /git/usr/libexec/git-core/git-daemon && \
rm /git/usr/libexec/git-core/git-fast-import && \
rm /git/usr/libexec/git-core/git-http-backend && \
rm /git/usr/libexec/git-core/git-instaweb && \
rm /git/usr/libexec/git-core/git-remote-testsvn && \
rm /git/usr/libexec/git-core/git-shell && \
rm /git/usr/libexec/git-core/git-svn && \
rm /git/usr/libexec/git-core/*p4* && \
rm /git/usr/libexec/git-core/mergetools/*p4* && \
rm /git/usr/libexec/git-core/*email* && \
rm /git/usr/libexec/git-core/*imap*

FROM bash:${bashversion}
ARG batsversion=v1.2.0
LABEL maintainer="Dmytro Serdiuk <[email protected]>" \
description="The image serves the environment for the testing of Elegant Git."
VOLUME /elegant-git
description="The image serves the environment for the testing of Elegant Git." \
bashversion=${bashversion} \
gitversion=${gitversion} \
batsversion=${batsversion}
WORKDIR /elegant-git
VOLUME /elegant-git
ENV EG_ENABLE_TESTING true
ARG gitversion=2.26.2
RUN apk add --no-cache git~=${gitversion}
ARG batsversion=v1.2.0
RUN git clone --branch ${batsversion} --single-branch --depth 1 https://github.com/bats-core/bats-core.git; \
COPY --from=git /git/usr/ /usr/
RUN apk add --no-cache curl-dev && \
git clone --branch ${batsversion} --single-branch --depth 1 https://github.com/bats-core/bats-core.git && \
cd bats-core && ./install.sh /usr/local && cd - && rm -r bats-core
COPY bats-workflows.bash /bats-workflows.bash
ENTRYPOINT [ "/bats-workflows.bash" ]
ENTRYPOINT [ ".workflows/bats/bats-workflows.bash" ]
CMD ["help"]
1 change: 0 additions & 1 deletion .workflows/bats/bats-workflows.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ MESSAGE

main() {
case ${1} in
all_tests) all_tests ;;
some_tests) shift; some_tests "${@}" ;;
help) usage ;;
*) "${@}" ;;
Expand Down
15 changes: 7 additions & 8 deletions .workflows/docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
ARG pythonversion=3.8.3
FROM python:${pythonversion}-alpine
FROM python:3.8.3-alpine
LABEL maintainer="Dmytro Serdiuk <[email protected]>" \
description="The image serves the environment for docs development of Elegant Git."
ARG bashversion=5.0.17
ARG gitversion=2.26.2
RUN apk add --no-cache bash=~${bashversion} git=~${gitversion}
VOLUME /elegant-git
WORKDIR /elegant-git
ENV EG_ENABLE_TESTING true
EXPOSE 80
ENTRYPOINT [ "/docs-workflows.bash" ]
ENTRYPOINT [ ".workflows/docs/docs-workflows.bash" ]
CMD ["help"]
COPY docs/requirements.txt .
RUN python -m pip install --upgrade pip && \
python -m pip install -r requirements.txt
ARG bashversion=5.0.17
RUN apk add --no-cache bash~=${bashversion}
COPY .workflows/docs/docs-workflows.bash /
RUN python -m pip install --no-cache-dir --upgrade pip && \
python -m pip install --no-cache-dir -r requirements.txt
23 changes: 19 additions & 4 deletions .workflows/docs/docs-workflows.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@
set -e

generate() {
exec python .workflows/docs/docs.py
python .workflows/docs/docs.py
}

build() {
local site_directory=/tmp/elegnat-git-docs
if test -z "${EG_ENABLE_TESTING}"; then
site_directory=$(pwd)/elegnat-git-docs
fi
exec python -m mkdocs build --clean --strict --site-dir ${site_directory}
python -m mkdocs build --clean --strict --site-dir ${site_directory}
}

preview() {
exec python -m mkdocs serve --dev-addr 0.0.0.0:80
}

help() {
check() {
echo "Checking if there are uncommitted docs files ..."
git update-index --really-refresh
git diff-index --quiet HEAD docs
}

usage() {
cat <<MESSAGE
usage: ${BASH_SOURCE[0]} <command>
Expand All @@ -26,8 +32,17 @@ Available commands:
generate generates fresh commands documentation
build builds the static documentation site
preview previews the documentation site
check shows whether 'docs' directory is committed or not
MESSAGE
}

${1}
main() {
case ${1} in
help) usage ;;
ci) generate && check ;;
*) "${@}" ;;
esac
}

main "${@}"
12 changes: 12 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ picture-in-picture" allowfullscreen></iframe></center>
> _Looks interesting? Go to [getting started](getting-started.md) guide or take a look for
available [commands](commands.md)._

Elegant Git has a rich test suit that executes on several Git and Bash versions. Please refer to
the table below to see the coverage matrix.

`bash --version`|`git --version`|`git elegant --version`
---|---|---
5.0.17|2.26.2|up to the latest
4.4.23|2.26.2|up to the latest
3.2.57|2.26.2|up to the latest
5.0.17|2.13.7|up to the latest
4.4.23|2.13.7|up to the latest
3.2.57|2.13.7|up to the latest

# Workflows
While developing something, it may be required to format code prior to committing modifications or
to open several URLs to report release notes after a new release. All these and similar actions,
Expand Down
Loading

0 comments on commit 6f67027

Please sign in to comment.