Skip to content

Commit 07cac1c

Browse files
authoredMar 19, 2021
INFRA-271: Added 'initializer' project type (#17)
1 parent fd8667a commit 07cac1c

File tree

9 files changed

+432
-17
lines changed

9 files changed

+432
-17
lines changed
 

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ gradle-app.setting
1919
# gradle/wrapper/gradle-wrapper.properties
2020
/.settings/
2121
/.idea/
22+
/data/
23+
!data/.gitkeep

‎.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: groovy
2-
2+
jdk:
3+
- openjdk8
34
sudo: required
45

56
services:

‎README.md

+2-14
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,9 @@ mkdir -p ~/repos && cd ~/repos && \
9292
./gradlew node-scripts:build
9393
```
9494

95-
**3** - Run the `openmrscd` container based on the `latest` tag:
95+
**3** - Run the `openmrscd` container:
9696
```bash
97-
docker run --name openmrscd -p 8080:8080 \
98-
-v ~/repos/openmrs-cd/node-scripts:/opt/node-scripts \
99-
-v ~/repos/openmrs-cd/jenkins/jenkins_home:/var/jenkins_home \
100-
-v ~/.m2:/var/jenkins_home/.m2 \
101-
-v ~/Documents/openmrs-cd/app_data:/var/lib/openmrs_cd/app_data \
102-
mekomsolutions/openmrscd:latest
103-
```
104-
The last two mounted volumes are 'nice to have', they ensure that the CD reuses your local .m2 and that the app data are extracted out of the container to some convenient location. In its most minimal form however the above Docker command becomes:
105-
```bash
106-
docker run --name openmrscd -p 8080:8080 \
107-
-v ~/repos/openmrs-cd/node-scripts:/opt/node-scripts \
108-
-v ~/repos/openmrs-cd/jenkins/jenkins_home:/var/jenkins_home \
109-
mekomsolutions/openmrscd:latest
97+
docker-compose up
11098
```
11199

112100
### The 'node-scripts' component

‎docker-compose.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3'
2+
3+
services:
4+
openmrscd:
5+
image: mekomsolutions/openmrscd:latest
6+
container_name: "openmrscd"
7+
ports:
8+
- "8080:8080"
9+
volumes:
10+
- ./node-scripts:/opt/node-scripts
11+
- ./jenkins/jenkins_home:/var/jenkins_home
12+
- ~/.m2:/var/jenkins_home/.m2
13+
- ./data/app_data:/var/lib/openmrs_cd/app_data

‎jenkins/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
!build.gradle
55

66
# Take Jenkins home folder and ignore its content except config.xml
7-
!jenkins_home
87
jenkins_home/*
98
!jenkins_home/config.xml
109

‎jenkins/jenkins_home/jobs/pipeline1/config.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ It takes as an input a bunch of 'commit metadata', i.e. all the inform
2222
<name>projectType</name>
2323
<description>The type of the code project
2424

25-
Supported values: &apos;openmrsmodule&apos;, &apos;bahmniapps&apos;, &apos;bahmnicore&apos;, &apos;bahmniconfig&apos;, &apos;openmrsconfig&apos;, &apos;openmrscore&apos;, &apos;distribution&apos;</description>
25+
Supported values: &apos;openmrsmodule&apos;, &apos;bahmniapps&apos;, &apos;bahmnicore&apos;, &apos;bahmniconfig&apos;, &apos;openmrsconfig&apos;, &apos;openmrscore&apos;, &apos;distribution&apos;, &apos;initializer&apos;</description>
2626
<defaultValue></defaultValue>
2727
<trim>false</trim>
2828
</hudson.model.StringParameterDefinition>

‎node-scripts/spec/pipeline1/pipeline1.spec.js

+36
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,42 @@ describe("Tests suite for pipeline1", function() {
436436
);
437437
});
438438

439+
it("should getArtifact, getBuildScript and getDeployScript for 'initializer'.", function() {
440+
// setup
441+
const projectType = "initializer";
442+
var pom = utils.getPom(
443+
"spec/" +
444+
config.getJobNameForPipeline1() +
445+
"/resources/" +
446+
projectType +
447+
"/pom.xml"
448+
);
449+
450+
// replay
451+
var projectBuild = require(folderInTest +
452+
"/impl/" +
453+
projectType).getInstance();
454+
var artifact = projectBuild.getArtifact({ pom: pom });
455+
var buildScript = projectBuild.getBuildScript();
456+
var deployScript = projectBuild.getDeployScript(artifact);
457+
458+
// verif
459+
expect(artifact.name).toEqual("initializer");
460+
expect(artifact.version).toEqual("2.1.0-SNAPSHOT");
461+
expect(artifact.extension).toEqual("omod");
462+
expect(artifact.filename).toEqual("initializer-2.1.0-SNAPSHOT.omod");
463+
expect(artifact.destFilename).toEqual(artifact.filename);
464+
expect(artifact.buildPath).toEqual("./omod/target");
465+
466+
expect(buildScript.type).toEqual("#!/bin/bash");
467+
expect(buildScript.body).toEqual("mvn clean package -P validator\n");
468+
469+
expect(deployScript.type).toEqual("#!/bin/bash");
470+
expect(deployScript.body.indexOf("mvn clean deploy -DskipTests") > -1).toBe(
471+
true
472+
);
473+
});
474+
439475
it("should getArtifact, getBuildScript and getDeployScript for 'bahmnicore'.", function() {
440476
// setup
441477
const projectType = "bahmnicore";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,329 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<parent>
5+
<groupId>org.openmrs.maven.parents</groupId>
6+
<artifactId>maven-parent-openmrs-module</artifactId>
7+
<version>1.1.1</version>
8+
</parent>
9+
10+
<groupId>org.openmrs.module</groupId>
11+
<artifactId>initializer</artifactId>
12+
<version>2.1.0-SNAPSHOT</version>
13+
<packaging>pom</packaging>
14+
<name>Initializer</name>
15+
<description>The OpenMRS Initializer module is an API-only module that processes the content of the configuration folder when it is found inside OpenMRS' application data directory.</description>
16+
17+
<developers>
18+
<developer>
19+
<name>Mekom Solutions</name>
20+
</developer>
21+
</developers>
22+
<organization>
23+
<name>Mekom Solutions</name>
24+
<url>http://www.mekomsolutions.com</url>
25+
</organization>
26+
27+
<scm>
28+
<connection>scm:git@github.com:mekomsolutions/openmrs-module-initializer.git</connection>
29+
<developerConnection>scm:git:git@github.com:mekomsolutions/openmrs-module-initializer.git</developerConnection>
30+
<url>https://github.com/mekomsolutions/openmrs-module-initializer</url>
31+
</scm>
32+
33+
<modules>
34+
<module>api</module>
35+
<module>api-2.2</module>
36+
<module>api-2.3</module>
37+
<module>omod</module>
38+
</modules>
39+
40+
<profiles>
41+
<profile>
42+
<id>validator</id>
43+
<modules>
44+
<module>validator-first-dependency</module>
45+
<module>validator</module>
46+
</modules>
47+
</profile>
48+
</profiles>
49+
50+
<properties>
51+
<openmrsVersion2.1>2.1.1</openmrsVersion2.1>
52+
<openmrsVersion2.2>2.2.0</openmrsVersion2.2>
53+
<openmrsVersion2.3>2.3.0</openmrsVersion2.3>
54+
55+
<openmrsPlatformVersion>${openmrsVersion2.1}</openmrsPlatformVersion>
56+
57+
<!-- Modules compatibility -->
58+
<appointmentsVersion>1.2.1</appointmentsVersion>
59+
<bahmniIeAppsVersion>1.1.0-SNAPSHOT</bahmniIeAppsVersion>
60+
<htmlformentryVersion>4.0.0-SNAPSHOT</htmlformentryVersion>
61+
<idgenVersion>4.6.0-SNAPSHOT</idgenVersion>
62+
<metadatasharingVersion>1.2.2</metadatasharingVersion>
63+
<metadatamappingVersion>1.3.4</metadatamappingVersion>
64+
65+
<!-- Modules compatibility > Core 2.3.0 -->
66+
<appframeworkVersion>2.14.0</appframeworkVersion>
67+
<datafilterVersion>1.0.0</datafilterVersion>
68+
69+
<!-- For Validator -->
70+
<reportingVersion>1.19.0</reportingVersion>
71+
<calculationVersion>1.2</calculationVersion>
72+
<serializationVersion>0.2.14</serializationVersion>
73+
74+
<!-- For tests -->
75+
<addresshierarchyVersion>2.11.0</addresshierarchyVersion>
76+
<exti18nVersion>1.0.0</exti18nVersion>
77+
</properties>
78+
79+
<dependencies>
80+
81+
<dependency>
82+
<groupId>org.openmrs.api</groupId>
83+
<artifactId>openmrs-api</artifactId>
84+
<version>${openmrsPlatformVersion}</version>
85+
<scope>provided</scope>
86+
<type>jar</type>
87+
</dependency>
88+
89+
<!-- JUnit, Powermock -->
90+
<dependency>
91+
<groupId>junit</groupId>
92+
<artifactId>junit</artifactId>
93+
<version>4.13.1</version>
94+
<scope>test</scope>
95+
</dependency>
96+
<dependency>
97+
<groupId>org.powermock</groupId>
98+
<artifactId>powermock-api-mockito</artifactId>
99+
<version>1.6.1</version>
100+
<scope>test</scope>
101+
</dependency>
102+
<dependency>
103+
<groupId>org.powermock</groupId>
104+
<artifactId>powermock-module-junit4</artifactId>
105+
<version>1.6.1</version>
106+
<scope>test</scope>
107+
</dependency>
108+
109+
<dependency>
110+
<groupId>org.openmrs.api</groupId>
111+
<artifactId>openmrs-api</artifactId>
112+
<type>test-jar</type>
113+
<version>${openmrsPlatformVersion}</version>
114+
<scope>test</scope>
115+
</dependency>
116+
117+
<dependency>
118+
<groupId>org.openmrs.api</groupId>
119+
<artifactId>openmrs-api</artifactId>
120+
<version>${openmrsPlatformVersion}</version>
121+
<classifier>tests</classifier>
122+
<scope>test</scope>
123+
</dependency>
124+
125+
<dependency>
126+
<groupId>org.openmrs.test</groupId>
127+
<artifactId>openmrs-test</artifactId>
128+
<type>pom</type>
129+
<version>${openmrsPlatformVersion}</version>
130+
<scope>test</scope>
131+
</dependency>
132+
133+
<!-- Supported aware-of module dependencies, sorted alphabetically -->
134+
135+
<dependency>
136+
<groupId>org.openmrs.module</groupId>
137+
<artifactId>addresshierarchy-api</artifactId>
138+
<version>${addresshierarchyVersion}</version>
139+
<scope>provided</scope>
140+
</dependency>
141+
142+
<dependency>
143+
<groupId>org.bahmni.module</groupId>
144+
<artifactId>appointments-api</artifactId>
145+
<version>${appointmentsVersion}</version>
146+
<scope>provided</scope>
147+
</dependency>
148+
149+
<dependency>
150+
<groupId>org.bahmni.module</groupId>
151+
<artifactId>bahmni.ie.apps-api</artifactId>
152+
<version>${bahmniIeAppsVersion}</version>
153+
<scope>provided</scope>
154+
</dependency>
155+
156+
<dependency>
157+
<groupId>org.openmrs.module</groupId>
158+
<artifactId>exti18n-api</artifactId>
159+
<version>${exti18nVersion}</version>
160+
<scope>provided</scope>
161+
</dependency>
162+
163+
<dependency>
164+
<groupId>org.openmrs.module</groupId>
165+
<artifactId>htmlformentry-api</artifactId>
166+
<version>${htmlformentryVersion}</version>
167+
<scope>provided</scope>
168+
</dependency>
169+
170+
<dependency>
171+
<groupId>org.openmrs.module</groupId>
172+
<artifactId>idgen-api</artifactId>
173+
<version>${idgenVersion}</version>
174+
<scope>provided</scope>
175+
</dependency>
176+
177+
<dependency>
178+
<groupId>org.openmrs.module</groupId>
179+
<artifactId>metadatamapping-api</artifactId>
180+
<version>${metadatamappingVersion}</version>
181+
<scope>provided</scope>
182+
</dependency>
183+
184+
<dependency>
185+
<groupId>org.openmrs.module</groupId>
186+
<artifactId>metadatasharing-api</artifactId>
187+
<version>${metadatasharingVersion}</version>
188+
<scope>provided</scope>
189+
</dependency>
190+
191+
<!-- For Validator -->
192+
<dependency>
193+
<groupId>org.openmrs.module</groupId>
194+
<artifactId>reporting-api</artifactId>
195+
<version>${reportingVersion}</version>
196+
<scope>test</scope>
197+
</dependency>
198+
199+
<dependency>
200+
<groupId>org.openmrs.module</groupId>
201+
<artifactId>reporting-api-2.0</artifactId>
202+
<version>${reportingVersion}</version>
203+
<scope>test</scope>
204+
</dependency>
205+
206+
<dependency>
207+
<groupId>org.openmrs.module</groupId>
208+
<artifactId>calculation-api</artifactId>
209+
<version>${calculationVersion}</version>
210+
<scope>test</scope>
211+
</dependency>
212+
213+
<dependency>
214+
<groupId>org.openmrs.module</groupId>
215+
<artifactId>serialization.xstream-api</artifactId>
216+
<version>${serializationVersion}</version>
217+
<scope>test</scope>
218+
</dependency>
219+
220+
<dependency>
221+
<groupId>org.openmrs.module</groupId>
222+
<artifactId>serialization.xstream-api-2.0</artifactId>
223+
<version>${serializationVersion}</version>
224+
<scope>test</scope>
225+
</dependency>
226+
227+
</dependencies>
228+
229+
<build>
230+
<plugins>
231+
<plugin>
232+
<groupId>org.apache.maven.plugins</groupId>
233+
<artifactId>maven-compiler-plugin</artifactId>
234+
<version>3.8.1</version>
235+
<configuration>
236+
<source>1.8</source>
237+
<target>1.8</target>
238+
</configuration>
239+
</plugin>
240+
<plugin>
241+
<groupId>net.revelc.code.formatter</groupId>
242+
<artifactId>formatter-maven-plugin</artifactId>
243+
<version>2.10.0</version>
244+
<executions>
245+
<execution>
246+
<phase>compile</phase>
247+
<goals>
248+
<goal>format</goal>
249+
</goals>
250+
<configuration>
251+
<directories>
252+
<directory>.</directory>
253+
</directories>
254+
<configFile>eclipse/OpenMRSFormatter.xml</configFile>
255+
<includes>
256+
<include>**/*.java</include>
257+
<include>**/*.json</include>
258+
</includes>
259+
</configuration>
260+
</execution>
261+
</executions>
262+
</plugin>
263+
</plugins>
264+
<pluginManagement>
265+
<plugins>
266+
<plugin>
267+
<groupId>net.revelc.code.formatter</groupId>
268+
<artifactId>formatter-maven-plugin</artifactId>
269+
<dependencies>
270+
<dependency>
271+
<groupId>org.openmrs.tools</groupId>
272+
<artifactId>openmrs-tools</artifactId>
273+
<version>${openmrsPlatformVersion}</version>
274+
</dependency>
275+
</dependencies>
276+
</plugin>
277+
</plugins>
278+
</pluginManagement>
279+
</build>
280+
281+
<repositories>
282+
<repository>
283+
<id>openmrs-repo</id>
284+
<name>OpenMRS Nexus Repository</name>
285+
<url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url>
286+
</repository>
287+
<repository>
288+
<id>central</id>
289+
<name>Maven Repository Switchboard</name>
290+
<layout>default</layout>
291+
<url>http://repo1.maven.org/maven2</url>
292+
</repository>
293+
<repository>
294+
<id>repo.mybahmni.org</id>
295+
<name>bahmni-artifactory-snapshots</name>
296+
<url>http://repo.mybahmni.org.s3.amazonaws.com/artifactory/snapshot</url>
297+
<snapshots>
298+
<updatePolicy>always</updatePolicy>
299+
</snapshots>
300+
</repository>
301+
<repository>
302+
<id>repo.mybahmni.org-release</id>
303+
<name>bahmni-artifactory-release</name>
304+
<url>http://repo.mybahmni.org.s3.amazonaws.com/artifactory/release</url>
305+
</repository>
306+
<repository>
307+
<id>bahmni-nexus</id>
308+
<name>Bahmni Nexus Repository</name>
309+
<url>https://oss.sonatype.org/content/groups/public</url>
310+
<snapshots>
311+
<enabled>true</enabled>
312+
</snapshots>
313+
</repository>
314+
</repositories>
315+
316+
<pluginRepositories>
317+
<pluginRepository>
318+
<id>openmrs-repo</id>
319+
<name>OpenMRS Nexus</name>
320+
<url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url>
321+
</pluginRepository>
322+
<pluginRepository>
323+
<id>openmrs-repo-snapshots</id>
324+
<name>OpenMRS Nexus Snapshots</name>
325+
<url>http://mavenrepo.openmrs.org/nexus/content/repositories/snapshots</url>
326+
</pluginRepository>
327+
</pluginRepositories>
328+
329+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"use strict";
2+
3+
const fs = require("fs");
4+
const path = require("path");
5+
6+
const model = require("../../utils/model");
7+
const utils = require("../../utils/utils");
8+
9+
const cmns = require("../commons");
10+
11+
const thisType = "initializer";
12+
const nexusType = "openmrsmodule";
13+
14+
module.exports = {
15+
getInstance: function() {
16+
var projectBuild = new model.ProjectBuild();
17+
18+
projectBuild.getBuildScript = function() {
19+
var script = cmns.getMavenProjectBuildScript(thisType);
20+
21+
script.body = "mvn clean package -P validator\n";
22+
23+
return script;
24+
};
25+
26+
projectBuild.getDeployScript = function(artifact) {
27+
return cmns.getMavenProjectDeployScript(
28+
thisType,
29+
"ARTIFACT_UPLOAD_URL_" + nexusType
30+
);
31+
};
32+
33+
projectBuild.getArtifact = function(args) {
34+
return cmns.getMavenProjectArtifact(args.pom, "./omod/target", "omod");
35+
};
36+
37+
projectBuild.postBuildActions = function(args) {
38+
cmns.mavenPostBuildActions(
39+
args.pom.groupId,
40+
args.artifactsIds,
41+
args.pom.version
42+
);
43+
};
44+
45+
return projectBuild;
46+
}
47+
};

0 commit comments

Comments
 (0)
Please sign in to comment.