Skip to content

Commit a39fb3d

Browse files
authored
Gradle workflow for plugin build and test (#32)
Contains integration test of plugin for mapping service currently tests build on jdk17 and jdk23 and test on mapping service 1.0.5 and latest respectively. Only tests with thermofisher data, may be extendend. The tests do NOT guarantee full compatibility with the mapping service. (see !33)
1 parent dabd607 commit a39fb3d

File tree

11 files changed

+545
-32
lines changed

11 files changed

+545
-32
lines changed
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Build and use plugin
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
jobs:
8+
build:
9+
runs-on: ${{ matrix.operating-system }}
10+
environment:
11+
name: ${{ github.ref_name }}
12+
strategy:
13+
matrix:
14+
operating-system: [ubuntu-latest]
15+
# Use both LTS releases and latest one for tests
16+
versions: [ { jdk: 17, mapping-service: v1.0.5 }, { jdk: 23, mapping-service: latest } ]
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Extract branch name
23+
shell: bash
24+
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
25+
id: extract_branch
26+
27+
- name: Set up JDK
28+
uses: actions/setup-java@v4
29+
with:
30+
distribution: 'zulu'
31+
java-version: ${{ matrix.versions.jdk }}
32+
33+
- name: Build with Gradle
34+
run: |
35+
JAR_VERSION=$(./mappingservice-plugin/gradlew printVersion -q -p ./mappingservice-plugin/)
36+
JAR_VERSION=${JAR_VERSION##*$'\n'}
37+
./mappingservice-plugin/gradlew clean jar -p ./mappingservice-plugin/
38+
ls -ll ./mappingservice-plugin/build/libs/
39+
echo "JAR_VERSION=${JAR_VERSION}"
40+
mv -v ./mappingservice-plugin/build/libs/SEMImagePlugin-$JAR_VERSION-plain.jar ./mappingservice-plugin/build/libs/SEMplugin.jar
41+
env:
42+
CI_BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}
43+
44+
- name: Upload job artifact
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: jar-jdk${{ matrix.versions.jdk }}
48+
path: ./mappingservice-plugin/build/libs/SEMplugin.jar
49+
50+
test:
51+
runs-on: ${{ matrix.operating-system }}
52+
environment:
53+
name: ${{ github.ref_name }}
54+
strategy:
55+
fail-fast: false #We want to test independent of each other - success on a stable version is more important than on the latest version
56+
matrix:
57+
operating-system: [ubuntu-latest]
58+
# Use both LTS releases and latest one for tests
59+
versions: [ { jdk: 17, mapping-service: v1.0.5 }, { jdk: 23, mapping-service: latest } ]
60+
needs: build
61+
steps:
62+
- name: Checkout repository
63+
uses: actions/checkout@v4
64+
- name: Extract branch name
65+
shell: bash
66+
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
67+
id: extract_branch
68+
- name: Download built jar
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: jar-jdk${{ matrix.versions.jdk }}
72+
path: ./plugins
73+
74+
- name: Run Docker Container # and wait for mapping service to be healthy before proceeding to tests
75+
run: |
76+
docker run -d -p 8095:8095 -e PIP_BREAK_SYSTEM_PACKAGES=1 -v ./plugins/SEMplugin.jar:/spring/mapping-service/plugins/SEMplugin.jar --name mapping4docker ghcr.io/kit-data-manager/mapping-service:${{ matrix.versions.mapping-service }}
77+
echo "Wait for mapping service to be healthy before proceeding to tests"
78+
while true; do
79+
if ! docker ps | grep -q mapping4docker; then
80+
echo "Docker container stopped unexpectedly. Aborting."
81+
exit 1
82+
fi
83+
if curl -f http://localhost:8095/actuator/info; then
84+
echo "Service is running."
85+
break
86+
fi
87+
echo "Waiting for the service to be ready..."
88+
docker logs --tail 20 mapping4docker
89+
sleep 5
90+
done
91+
- name: Run Tests with Hurl
92+
run: |
93+
curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/6.0.0/hurl_6.0.0_amd64.deb
94+
sudo dpkg -i hurl_6.0.0_amd64.deb
95+
sudo apt install -y dos2unix
96+
unix2dos -n ./mappingservice-plugin/integrationtests/basic.hurl ./mappingservice-plugin/integrationtests/basic_crlf.hurl
97+
hurl --variable host=http://localhost:8095 --test ./mappingservice-plugin/integrationtests/basic_crlf.hurl --verbose --file-root .
98+
env:
99+
CI_BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}
100+
- name: Stop Docker Container
101+
run: docker stop mapping4docker

mappingservice-plugin/build.gradle

+10-12
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ dependencies {
3535
implementation files("src/main/lib/mapping-service-plain.jar")
3636
}
3737

38-
//Reading in version info from general version.txt in project root
39-
def rootDir = new File(projectDir, '../')
40-
def versionFile = new File(rootDir, 'version.txt')
41-
def version = versionFile.text.trim()
42-
43-
allprojects {
44-
project.version = version
38+
if (System.getenv('CI_BRANCH_NAME')) {
39+
project.version = System.getenv('CI_BRANCH_NAME')
40+
} else {
41+
def rDir = new File(projectDir, '../')
42+
def versionFile = new File(rDir, 'version.txt')
43+
project.version = versionFile.text.trim()
4544
}
4645

4746
tasks.register('printVersion') {
@@ -52,16 +51,15 @@ tasks.register('printVersion') {
5251
def versionTask = tasks.register("generateVersionProps", WriteProperties) { t ->
5352
def generatedResourcesDir = project.layout.buildDirectory.dir(["resources", "main"].join(File.separator))
5453
def outputFile = generatedResourcesDir.map {it -> it.file("sempluginversion.properties") }
55-
5654
t.outputFile(outputFile)
5755
t.property("version", project.version)
5856
}
5957

60-
processResources {
61-
from versionTask
62-
}
63-
6458
jar {
6559
dependsOn(generateVersionProps)
6660
archiveFileName
61+
}
62+
63+
bootJar {
64+
enabled = false
6765
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)