Skip to content

Commit c6c4880

Browse files
jainadc9jainadc9
andauthored
Created main.yml for github actions to migrate from travis.yml (#307)
* Created main.yml * Updated Dockerfile-Jenkins to install goovy via jenkins-plugin-cli * Updated env.bash from bitnami jenkins image to jenkins-lts * Update CommonSteps.java * Delete .travis.yml Co-authored-by: jainadc9 <jainad.chinta@ericsson.com>
1 parent 9a9f2f1 commit c6c4880

File tree

5 files changed

+168
-81
lines changed

5 files changed

+168
-81
lines changed

.github/workflows/main.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the master branch
8+
push:
9+
branches: [ master ]
10+
pull_request:
11+
branches: [ master ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
unitAndFunctionalTests:
20+
if: github.repository == 'eiffel-community/eiffel-intelligence-frontend'
21+
# The type of runner that the job will run on
22+
runs-on: ubuntu-18.04
23+
env:
24+
EI_BACKEND_PORT: 8099
25+
JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64
26+
M2_HOME: /opt/apache-maven-3.6.3
27+
MAVEN_HOME: /opt/apache-maven-3.6.3
28+
29+
# Steps represent a sequence of tasks that will be executed as part of the job
30+
steps:
31+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
32+
- uses: actions/checkout@v3
33+
34+
# Runs a set of commands using the runners shell
35+
# Run before every job
36+
- name: Install Java
37+
run: |
38+
sudo apt-get update
39+
sudo apt-get install -y openjdk-8-jdk
40+
java -version
41+
uname -a
42+
chmod +x pom.xml
43+
44+
- name: Install Maven
45+
shell: bash
46+
run: |
47+
wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp
48+
tar xf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt
49+
echo "${M2_HOME}/bin" >> $GITHUB_PATH
50+
51+
- name: Run unit and functional tests
52+
run: |
53+
mvn test -B
54+
55+
56+
integrationTests:
57+
if: github.repository == 'eiffel-community/eiffel-intelligence-frontend'
58+
# The type of runner that the job will run on
59+
runs-on: ubuntu-18.04
60+
env:
61+
EI_BACKEND_PORT: 8099
62+
JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64
63+
M2_HOME: /opt/apache-maven-3.6.3
64+
MAVEN_HOME: /opt/apache-maven-3.6.3
65+
66+
# Steps represent a sequence of tasks that will be executed as part of the job
67+
steps:
68+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
69+
- uses: actions/checkout@v3
70+
71+
# Runs a set of commands using the runners shell
72+
# Run before every job
73+
- name: Install Java
74+
run: |
75+
sudo apt-get update
76+
sudo apt-get install -y openjdk-8-jdk
77+
java -version
78+
uname -a
79+
chmod +x pom.xml
80+
mvn --version
81+
82+
- name: Install Maven
83+
shell: bash
84+
run: |
85+
wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp
86+
tar xf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt
87+
ln -s /opt/apache-maven-3.6.3 /opt/maven
88+
echo "${M2_HOME}/bin" >> $GITHUB_PATH
89+
90+
# To ensure docker containers are fully up and running we sleep 60s
91+
- name: Before script
92+
run: |
93+
source src/main/docker/env.bash
94+
docker-compose -f src/main/docker/docker-compose.yml up -d eiffel-er mongodb rabbitmq jenkins mail-server ldap ldap-seed ldap2 ldap2-seed
95+
echo 'Sleeping till Jenkins is up.'
96+
timeout 90 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST:$JENKINS_PORT/login)" != "200" ]]; do sleep 5; done' || false
97+
git clone --depth=50 --branch=master https://github.com/eiffel-community/eiffel-intelligence.git
98+
cd eiffel-intelligence
99+
chmod +x pom.xml
100+
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
101+
export EIFFEL_WAR=$(ls target/*.war)
102+
java -Dspring.config.additional-location=file:../src/integrationtest/resources/integration-test.properties -Dserver.port=${EI_BACKEND_PORT} -jar ${EIFFEL_WAR} &
103+
cd ..
104+
echo 'Sleeping till EI is up.'
105+
timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST:$EI_BACKEND_PORT/status)" != "200" ]]; do sleep 5; done' || false
106+
107+
- name: Run Integration tests
108+
run: |
109+
mvn --version
110+
mvn verify -P integrationTest -DskipUTs -Dei.backend.instances.list.json.content="[{ 'contextPath': '', 'port': '${EI_BACKEND_PORT}', 'name': 'EI-Backend-1', 'host': 'localhost', 'https': false, 'defaultBackend': true}]" -B
111+
112+
- name: After script
113+
run: |
114+
docker-compose -f src/main/docker/docker-compose.yml down || true
115+
fuser -k ${EI_BACKEND_PORT}/tcp
116+
117+
reportCoverage:
118+
if: github.repository == 'eiffel-community/eiffel-intelligence-frontend' && github.event_name == 'push'
119+
# The type of runner that the job will run on
120+
runs-on: ubuntu-18.04
121+
env:
122+
EI_BACKEND_PORT: 8099
123+
JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64
124+
M2_HOME: /opt/apache-maven-3.6.3
125+
MAVEN_HOME: /opt/apache-maven-3.6.3
126+
127+
# Steps represent a sequence of tasks that will be executed as part of the job
128+
steps:
129+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
130+
- uses: actions/checkout@v3
131+
132+
# Runs a set of commands using the runners shell
133+
# Run before every job
134+
- name: Install Java
135+
run: |
136+
sudo apt-get update
137+
sudo apt-get install -y openjdk-8-jdk
138+
java -version
139+
uname -a
140+
chmod +x pom.xml
141+
mvn --version
142+
143+
- name: Install Maven
144+
shell: bash
145+
run: |
146+
wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp
147+
tar xf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt
148+
echo "${M2_HOME}/bin" >> $GITHUB_PATH
149+
150+
- name: Run cobertura
151+
shell: bash
152+
run: |
153+
mvn cobertura:cobertura -Dcobertura.report.format=xml -B
154+
155+
# Generating test coverage report and publishing to Codacy
156+
- name: Run report coverage
157+
uses: codacy/codacy-coverage-reporter-action@v1
158+
with:
159+
project-token: 4f71427f28dc44a7b762bb14f21094ea
160+
coverage-reports: target/site/cobertura/coverage.xml

.travis.yml

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/integrationtest/java/com/ericsson/ei/frontend/CommonSteps.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
@Ignore
4242
@RunWith(SpringRunner.class)
43-
@SpringBootTest(classes = EIFrontendApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
43+
@SpringBootTest(classes = EIFrontendApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = "spring.main.allow-bean-definition-overriding=true")
4444
@ContextConfiguration(classes = EIFrontendApplication.class, loader = SpringBootContextLoader.class)
4545
@TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class, CommonSteps.class })
4646
public class CommonSteps extends AbstractTestExecutionListener {

src/main/docker/Dockerfile-Jenkins

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
ARG JENKINS_IMAGE
22
FROM ${JENKINS_IMAGE}
33

4-
RUN /install-plugins.sh groovy:2.1
4+
RUN jenkins-plugin-cli --plugins groovy:2.1
5+
6+
7+
8+
9+

src/main/docker/env.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export EIFFEL_ER_IMAGE="eiffelericsson/eiffel-er:0.0.67"
1313
export MAILSERVER_IMAGE="mailhog/mailhog"
1414
export REMREM_GENERATE_IMAGE="eiffelericsson/eiffel-remrem-generate:2.0.4"
1515
export REMREM_PUBLISH_IMAGE="eiffelericsson/eiffel-remrem-publish:2.0.2"
16-
export JENKINS_IMAGE="bitnami/jenkins:2.319.3"
16+
export JENKINS_IMAGE="jenkins/jenkins:2.332.2-lts"
1717
export LDAP_IMAGE="osixia/openldap:1.2.4"
1818

1919
export EI_BACKEND_IMAGE="eiffelericsson/eiffel-intelligence-backend:3.0.0"

0 commit comments

Comments
 (0)