Skip to content

Commit 540227d

Browse files
authored
Add Concourse pipeline (#341)
- Creates ci image - Builds pull requests - Builds main
1 parent eb558f5 commit 540227d

15 files changed

+536
-5
lines changed

README.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ Please refer to the link:CONTRIBUTING.adoc[] for more details.
7171
== License
7272

7373
https://www.apache.org/licenses/LICENSE-2.0[Apache License v2.0]
74+

ci/images/ci-image/Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM ubuntu:focal-20220801
2+
#
3+
#VOLUME /var/run/docker.sock
4+
#
5+
###########################################################
6+
# JAVA
7+
###########################################################
8+
9+
ADD ./setup.sh /setup.sh
10+
ADD ./get-jdk-url.sh /get-jdk-url.sh
11+
ADD ./get-docker-url.sh /get-docker-url.sh
12+
RUN ./setup.sh java17
13+
14+
ENV JAVA_HOME /opt/openjdk
15+
ENV PATH $PATH:$JAVA_HOME/bin
16+
ENV MAVEN_HOME /usr/share/maven
17+
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
18+
19+
#
20+
21+
22+
23+
#ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"]
24+
#ENTRYPOINT ["sh"]
25+
ENTRYPOINT [ "switch", "shell=/bin/bash", "--", "codep", "/bin/docker daemon" ]

ci/images/ci-image/entrypoint.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2021 - 2022 the original author or authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
set -e
19+
20+
mvn --version
21+
22+
exec "$@"

ci/images/ci-image/get-docker-url.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2021 - 2022 the original author or authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
set -e
18+
19+
version="20.10.17"
20+
echo "https://download.docker.com/linux/static/stable/x86_64/docker-$version.tgz";

ci/images/ci-image/get-jdk-url.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
case "$1" in
5+
java17)
6+
echo "https://github.com/bell-sw/Liberica/releases/download/17.0.4+8/bellsoft-jdk17.0.4+8-linux-amd64.tar.gz"
7+
# echo "https://github.com/bell-sw/Liberica/releases/download/17.0.4+8/bellsoft-jdk17.0.4+8-linux-aarch64.tar.gz"
8+
9+
;;
10+
java18)
11+
echo "https://github.com/bell-sw/Liberica/releases/download/18.0.2+10/bellsoft-jdk18.0.2+10-linux-amd64.tar.gz"
12+
;;
13+
*)
14+
echo $"Unknown java version"
15+
exit 1
16+
esac

ci/images/ci-image/setup.sh

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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 git curl jq tzdata ca-certificates net-tools libxml2-utils git curl libudev1 libxml2-utils iptables iproute2 jq gnupg lsb-release software-properties-common python3-pip
11+
apt-get update
12+
ln -fs /usr/share/zoneinfo/UTC /etc/localtime
13+
dpkg-reconfigure --frontend noninteractive tzdata
14+
rm -rf /var/lib/apt/lists/*
15+
16+
# curl https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.4/concourse-java.sh > /opt/concourse-java.sh
17+
18+
19+
###########################################################
20+
# JAVA
21+
###########################################################
22+
JDK_URL=$( ./get-jdk-url.sh $1 )
23+
24+
mkdir -p /opt/openjdk
25+
cd /opt/openjdk
26+
curl -L ${JDK_URL} | tar zx --strip-components=1
27+
test -f /opt/openjdk/bin/java
28+
test -f /opt/openjdk/bin/javac
29+
30+
if [[ $# -eq 2 ]]; then
31+
cd /
32+
TOOLCHAIN_JDK_URL=$( ./get-jdk-url.sh $2 )
33+
34+
mkdir -p /opt/openjdk-toolchain
35+
cd /opt/openjdk-toolchain
36+
curl -L ${TOOLCHAIN_JDK_URL} | tar zx --strip-components=1
37+
test -f /opt/openjdk-toolchain/bin/java
38+
test -f /opt/openjdk-toolchain/bin/javac
39+
fi
40+
41+
############################################################
42+
## MAVEN
43+
############################################################
44+
45+
#INSTALL MAVEN
46+
MAVEN_VERSION=3.6.3
47+
48+
# 2- Define a constant with the working directory
49+
USER_HOME_DIR="/root"
50+
51+
# 4- Define the URL where maven can be downloaded from
52+
BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
53+
54+
# 5- Create the directories, download maven, validate the download, install it, remove downloaded file and set links
55+
mkdir -p /usr/share/maven /usr/share/maven/ref \
56+
&& echo "Downlaoding maven" \
57+
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
58+
\
59+
&& echo "Unziping maven" \
60+
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
61+
\
62+
&& echo "Cleaning and setting links" \
63+
&& rm -f /tmp/apache-maven.tar.gz \
64+
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
65+
66+
# 6- Define environmental variables required by Maven, like Maven_Home directory and where the maven repo is located
67+
68+
69+
###########################################################
70+
# DOCKER
71+
###########################################################
72+
#mkdir -p /etc/apt/keyrings
73+
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
74+
#echo \
75+
# "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
76+
# $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
77+
#sudo apt-get update
78+
#sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
79+
#
80+
#
81+
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
82+
#APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
83+
#apt-key fingerprint 0EBFCD88
84+
#add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
85+
#apt-get update
86+
#apt-cache policy docker-ce
87+
#apt-get -y install docker-ce
88+
#usermod -aG docker root
89+
90+
91+
######
92+
93+
cd /
94+
DOCKER_URL=$( ./get-docker-url.sh )
95+
curl -L ${DOCKER_URL} | tar zx
96+
mv /docker/* /bin/
97+
chmod +x /bin/docker*
98+
99+
export ENTRYKIT_VERSION=0.4.0
100+
curl -L https://github.com/progrium/entrykit/releases/download/v${ENTRYKIT_VERSION}/entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz | tar zx
101+
chmod +x entrykit && \
102+
mv entrykit /bin/entrykit && \
103+
entrykit --symlink
104+
105+
# Docker Compose
106+
pip3 install docker-compose

ci/pipeline.yml

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
---
2+
anchors:
3+
git-repo-resource-source: &git-repo-resource-source
4+
uri: ((github-repo-uri)) # https://github.com/spring-projects-experimental/spring-boot-migrator
5+
username: ((github-repo-user)) # fabapp2
6+
password: ((github-ci-release-token))
7+
branch: ((branch))
8+
registry-image-resource-source: &registry-image-resource-source
9+
username: ((docker-hub-username))
10+
password: ((docker-hub-password))
11+
tag: ((milestone))
12+
registry_mirror:
13+
host: ((docker-hub-mirror))
14+
username: ((docker-hub-mirror-username))
15+
password: ((docker-hub-mirror-password))
16+
docker-hub-mirror-vars: &docker-hub-mirror-vars
17+
docker-hub-mirror: ((docker-hub-mirror))
18+
docker-hub-mirror-username: ((docker-hub-mirror-username))
19+
docker-hub-mirror-password: ((docker-hub-mirror-password))
20+
21+
resource_types:
22+
- name: registry-image
23+
type: registry-image
24+
source:
25+
repository: concourse/registry-image-resource
26+
tag: 1.5.0
27+
- name: git-pull-request
28+
type: docker-image
29+
source:
30+
repository: ((github-repo-name))
31+
- name: pull-request
32+
type: registry-image
33+
source:
34+
repository: teliaoss/github-pr-resource
35+
tag: v0.23.0
36+
37+
38+
resources:
39+
# The ci dir in the repo, used to trigger an image build on change
40+
- name: ci-images-git-repo
41+
type: git
42+
icon: github
43+
source:
44+
uri: ((github-repo-uri))
45+
branch: ((branch))
46+
paths: ["ci/images/*"]
47+
# The git repo
48+
- name: git-repo
49+
type: git
50+
icon: github
51+
source:
52+
<<: *git-repo-resource-source
53+
# The image used to run the build
54+
- name: ci-image
55+
type: registry-image
56+
icon: docker
57+
source:
58+
<<: *registry-image-resource-source
59+
repository: fkrueger096/spring-boot-migrator-ci
60+
tag: latest
61+
# branches for multi-branch pipeline
62+
# - name: branches
63+
# type: git-branches
64+
# source:
65+
# uri: ((github-repo-uri))
66+
# branch_regex: '.*'
67+
68+
69+
# git PR
70+
- name: git-pull-request
71+
type: pull-request
72+
icon: source-pull
73+
source:
74+
access_token: ((github-ci-pull-request-token))
75+
repository: ((github-repo-name))
76+
base_branch: main
77+
ignore_paths: [ "ci/*" ]
78+
79+
image_resource:
80+
type: registry-image
81+
source:
82+
repository: concourse/oci-build-task
83+
tag: 0.10.0
84+
registry_mirror:
85+
host: ((docker-hub-mirror))
86+
username: ((docker-hub-mirror-username))
87+
password: ((docker-hub-mirror-password))
88+
89+
jobs:
90+
# Build and push CI image when ci-images-git-repo changed
91+
- name: build-ci-images
92+
plan:
93+
- get: ci-images-git-repo
94+
trigger: true
95+
- get: git-repo
96+
- in_parallel:
97+
- task: build-ci-image
98+
privileged: true
99+
file: git-repo/ci/tasks/build-ci-image.yml
100+
output_mapping:
101+
image: ci-image
102+
vars:
103+
ci-image-name: ci-image
104+
<<: *docker-hub-mirror-vars
105+
- in_parallel:
106+
- put: ci-image
107+
params:
108+
image: ci-image/image.tar
109+
110+
# Build application
111+
- name: build
112+
public: true
113+
plan:
114+
- in_parallel:
115+
- get: ci-image
116+
- get: git-repo
117+
trigger: true
118+
- task: compile
119+
image: ci-image
120+
file: git-repo/ci/tasks/maven-build.yml
121+
# - in_parallel:
122+
# fail_fast: true
123+
# steps:
124+
# - task: run-unit-tests
125+
# image: ci-image
126+
# file: git-repo/ci/tasks/maven-unit-test.yml
127+
# - task: run-integration-tests
128+
# image: ci-image
129+
# file: git-repo/ci/tasks/maven-integration-test.yml
130+
131+
# - name: set-feature-pipelines
132+
# plan:
133+
# - in_parallel:
134+
# - get: feature-branches
135+
# trigger: true
136+
# - get: git-repo
137+
# - load_var: branches
138+
# file: feature-branches/branches.json
139+
# - across:
140+
# - var: branch
141+
# values: ((.:branches))
142+
# set_pipeline: dev
143+
# file: examples/pipelines/multi-branch/template.yml
144+
# instance_vars: {feature: ((.:branch.groups.feature))}
145+
# vars: {branch: ((.:branch.name))}
146+
147+
# Build every new PR
148+
- name: build-pull-requests
149+
serial: true
150+
public: true
151+
plan:
152+
- get: ci-image
153+
- get: git-repo
154+
resource: git-pull-request
155+
trigger: true
156+
version: every
157+
- do:
158+
- put: git-pull-request
159+
params:
160+
path: git-repo
161+
status: pending
162+
- task: build-project
163+
image: ci-image
164+
file: git-repo/ci/tasks/build-pr-project.yml
165+
# timeout: 30m # ((task-timeout))
166+
on_success:
167+
put: git-pull-request
168+
params:
169+
path: git-repo
170+
status: success
171+
on_failure:
172+
put: git-pull-request
173+
params:
174+
path: git-repo
175+
status: failure
176+
177+
groups:
178+
- name: "builds"
179+
jobs: ["build"]
180+
# - name: "releases"
181+
# jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "create-github-release", "publish-gradle-plugin", "publish-to-sdkman", "update-homebrew-tap"]
182+
# - name: "system-tests"
183+
# jobs: ["run-system-tests", "jdk18-run-system-tests"]
184+
- name: "ci-images"
185+
jobs: ["build-ci-images"]
186+
- name: "pull-requests"
187+
jobs: ["build-pull-requests"]

0 commit comments

Comments
 (0)