Skip to content

Commit 5565cce

Browse files
committed
Add CI pipeline
1 parent 811bb76 commit 5565cce

19 files changed

+722
-0
lines changed

ci/README.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
== Concourse pipeline
2+
3+
Ensure that you've setup the asciidoctor-spring-backends target and can login
4+
5+
[source]
6+
----
7+
$ fly -t asciidoctor-spring-backends login -n asciidoctor-spring-backends -c https://ci.spring.io
8+
----
9+
10+
The pipeline can be deployed using the following command:
11+
12+
[source]
13+
----
14+
$ fly -t asciidoctor-spring-backends set-pipeline -p asciidoctor-spring-backends -c ci/pipeline.yml -l ci/parameters.yml
15+
----
16+
17+
NOTE: This assumes that you have credhub integration configured with the appropriate secrets.

ci/images/README.adoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
== CI Images
2+
3+
These images are used by CI to run the actual builds.
4+
5+
To build the image locally run the following from this directory:
6+
7+
----
8+
$ docker build --no-cache -f <image-folder>/Dockerfile .
9+
----
10+
11+
For example
12+
13+
----
14+
$ docker build --no-cache -f ci-image/Dockerfile .
15+
----
16+
17+
To test run:
18+
19+
----
20+
$ docker run -it --entrypoint /bin/bash <SHA> ✈
21+
----

ci/images/ci-image/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM ubuntu:focal-20210119
2+
3+
ADD setup.sh /setup.sh
4+
ADD get-jdk-url.sh /get-jdk-url.sh
5+
ADD get-docker-url.sh /get-docker-url.sh
6+
RUN ./setup.sh java8
7+
8+
ENV JAVA_HOME /opt/openjdk
9+
ENV PATH $JAVA_HOME/bin:$PATH
10+
ADD docker-lib.sh /docker-lib.sh

ci/images/docker-lib.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Based on: https://github.com/concourse/docker-image-resource/blob/master/assets/common.sh
2+
3+
DOCKER_LOG_FILE=${DOCKER_LOG_FILE:-/tmp/docker.log}
4+
SKIP_PRIVILEGED=${SKIP_PRIVILEGED:-false}
5+
STARTUP_TIMEOUT=${STARTUP_TIMEOUT:-120}
6+
7+
sanitize_cgroups() {
8+
mkdir -p /sys/fs/cgroup
9+
mountpoint -q /sys/fs/cgroup || \
10+
mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
11+
12+
mount -o remount,rw /sys/fs/cgroup
13+
14+
sed -e 1d /proc/cgroups | while read sys hierarchy num enabled; do
15+
if [ "$enabled" != "1" ]; then
16+
# subsystem disabled; skip
17+
continue
18+
fi
19+
20+
grouping="$(cat /proc/self/cgroup | cut -d: -f2 | grep "\\<$sys\\>")" || true
21+
if [ -z "$grouping" ]; then
22+
# subsystem not mounted anywhere; mount it on its own
23+
grouping="$sys"
24+
fi
25+
26+
mountpoint="/sys/fs/cgroup/$grouping"
27+
28+
mkdir -p "$mountpoint"
29+
30+
# clear out existing mount to make sure new one is read-write
31+
if mountpoint -q "$mountpoint"; then
32+
umount "$mountpoint"
33+
fi
34+
35+
mount -n -t cgroup -o "$grouping" cgroup "$mountpoint"
36+
37+
if [ "$grouping" != "$sys" ]; then
38+
if [ -L "/sys/fs/cgroup/$sys" ]; then
39+
rm "/sys/fs/cgroup/$sys"
40+
fi
41+
42+
ln -s "$mountpoint" "/sys/fs/cgroup/$sys"
43+
fi
44+
done
45+
46+
if ! test -e /sys/fs/cgroup/systemd ; then
47+
mkdir /sys/fs/cgroup/systemd
48+
mount -t cgroup -o none,name=systemd none /sys/fs/cgroup/systemd
49+
fi
50+
}
51+
52+
start_docker() {
53+
mkdir -p /var/log
54+
mkdir -p /var/run
55+
56+
if [ "$SKIP_PRIVILEGED" = "false" ]; then
57+
sanitize_cgroups
58+
59+
# check for /proc/sys being mounted readonly, as systemd does
60+
if grep '/proc/sys\s\+\w\+\s\+ro,' /proc/mounts >/dev/null; then
61+
mount -o remount,rw /proc/sys
62+
fi
63+
fi
64+
65+
local mtu=$(cat /sys/class/net/$(ip route get 8.8.8.8|awk '{ print $5 }')/mtu)
66+
local server_args="--mtu ${mtu}"
67+
local registry=""
68+
69+
server_args="${server_args}"
70+
71+
for registry in $3; do
72+
server_args="${server_args} --insecure-registry ${registry}"
73+
done
74+
75+
if [ -n "$4" ]; then
76+
server_args="${server_args} --registry-mirror $4"
77+
fi
78+
79+
try_start() {
80+
dockerd --data-root /scratch/docker ${server_args} >$DOCKER_LOG_FILE 2>&1 &
81+
echo $! > /tmp/docker.pid
82+
83+
sleep 1
84+
85+
echo waiting for docker to come up...
86+
until docker info >/dev/null 2>&1; do
87+
sleep 1
88+
if ! kill -0 "$(cat /tmp/docker.pid)" 2>/dev/null; then
89+
return 1
90+
fi
91+
done
92+
}
93+
94+
export server_args DOCKER_LOG_FILE
95+
declare -fx try_start
96+
97+
if ! timeout ${STARTUP_TIMEOUT} bash -ce 'while true; do try_start && break; done'; then
98+
echo Docker failed to start within ${STARTUP_TIMEOUT} seconds.
99+
return 1
100+
fi
101+
}

ci/images/get-docker-url.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
4+
version="19.03.14"
5+
echo "https://download.docker.com/linux/static/stable/x86_64/docker-$version.tgz";

ci/images/get-jdk-url.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
case "$1" in
5+
java8)
6+
echo "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u282-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u282b08.tar.gz"
7+
;;
8+
*)
9+
echo $"Unknown java version"
10+
exit 1
11+
esac

ci/images/setup.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
###########################################################
5+
# UTILS
6+
###########################################################
7+
8+
export DEBIAN_FRONTEND=noninteractive
9+
apt-get update
10+
apt-get install --no-install-recommends -y tzdata ca-certificates net-tools libxml2-utils git curl libudev1 libxml2-utils iptables iproute2 jq
11+
ln -fs /usr/share/zoneinfo/UTC /etc/localtime
12+
dpkg-reconfigure --frontend noninteractive tzdata
13+
rm -rf /var/lib/apt/lists/*
14+
15+
curl https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.3/concourse-java.sh > /opt/concourse-java.sh
16+
17+
18+
###########################################################
19+
# JAVA
20+
###########################################################
21+
JDK_URL=$( ./get-jdk-url.sh $1 )
22+
23+
mkdir -p /opt/openjdk
24+
cd /opt/openjdk
25+
curl -L ${JDK_URL} | tar zx --strip-components=1
26+
test -f /opt/openjdk/bin/java
27+
test -f /opt/openjdk/bin/javac
28+
29+
30+
###########################################################
31+
# DOCKER
32+
###########################################################
33+
cd /
34+
DOCKER_URL=$( ./get-docker-url.sh )
35+
curl -L ${DOCKER_URL} | tar zx
36+
mv /docker/* /bin/
37+
chmod +x /bin/docker*
38+
39+
export ENTRYKIT_VERSION=0.4.0
40+
curl -L https://github.com/progrium/entrykit/releases/download/v${ENTRYKIT_VERSION}/entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz | tar zx
41+
chmod +x entrykit && \
42+
mv entrykit /bin/entrykit && \
43+
entrykit --symlink
44+
45+
46+
###########################################################
47+
# GRADLE ENTERPRISE
48+
###########################################################
49+
mkdir ~/.gradle
50+
echo 'systemProp.user.name=concourse' > ~/.gradle/gradle.properties

ci/parameters.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
github-repo: "https://github.com/spring-io/asciidoctor-spring-backends.git"
2+
github-repo-name: "spring-io/asciidoctor-spring-backends"
3+
github-project-name: "asciidoctor-spring-backends"
4+
docker-hub-organization: "springci"
5+
artifactory-server: "https://repo.spring.io"
6+
branch: "main"
7+
build-name: "asciidoctor-spring-backends"
8+
ci-image-name: "asciidoctor-spring-backends-ci"
9+
task-timeout: 1h00m

0 commit comments

Comments
 (0)