Skip to content

Commit

Permalink
Merge pull request #12 from simpledotorg/igbanam/package-the-test-tool
Browse files Browse the repository at this point in the history
[sc-13646] Create Release Strategy
  • Loading branch information
ademarcqrtsl authored Oct 10, 2024
2 parents 33ef9d7 + adaffc6 commit ff1fcab
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

name: Build and publish docker image
name: Build Artefacts

on:
push:
branches:
- '**' # matches every branch
- '**'

jobs:
build:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/publish-dhis2-verifier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release DHIS2 Verifier
on:
push:
tags:
- v*
jobs:
release-dhis2-verifier:
defaults:
run:
working-directory: CommonUtils/Dhis2CucumberTestTool
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
server-id: github
settings-path: ${{ github.workspace }}
- name: Set the version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
mvn versions:set -DnewVersion=${{ env.RELEASE_VERSION }}
- name: Build with Maven
run: mvn -B package --file pom.xml -DskipTests=true
- name: Create a release with the artefacts # Note: this would create a new release…
uses: ncipollo/[email protected]
with:
artifacts: "target/Dhis2CucumberTestTool-${{ env.RELEASE_VERSION }}-release.zip"
token: ${{ github.token }}
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish built artefacts
name: Publish Docs
on:
push:
branches:
Expand Down
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Contributing to RTSL Utils

## …for code changes

We communicate in RTSL through concrete artefacts. What this means in the Github world is issues, and pull requests. If you have ideas on how any of our utils could be better, or you can help with an already open issue, please raise a pull request with the following guidelines

- commits should follow the [conventional commits](https://www.conventionalcommits.org) guidelines
- ensure the pull request description properly details the problem and the solution
- link the issue being treated, if available

If you want to contribute an entirely new feature, do raise an issue so we can discuss it beforehand. This helps smoothen the pull request review process.

## …for bugs

1. Search for the bug through our Github issues
1. If the bug exists, add your scenario to the thread so we know this bug is affecting more people
1. If the bug is new, please create a new Github issue ensuring you have the following detail in it
1. a clear title and description
1. the specific util you found the bug in
1. steps we can take to see what you see

We're looking forward to collaborating with you and everyone in the community :rocket:
36 changes: 36 additions & 0 deletions CommonUtils/Dhis2CucumberTestTool/assemblers/release.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>release</id>
<includeBaseDirectory>true</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/release-artefacts</directory>
<outputDirectory></outputDirectory>
<filtered>true</filtered>
<includes>
<include>exec.sh</include>
</includes>
<fileMode>0744</fileMode>
</fileSet>
<fileSet>
<directory>${project.basedir}/release-artefacts</directory>
<outputDirectory></outputDirectory>
<filtered>true</filtered>
<includes>
<include>log-config.xml</include>
<include>input.properties</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>Dhis2CucumberTestTool*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
20 changes: 18 additions & 2 deletions CommonUtils/Dhis2CucumberTestTool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>3.2.4</version>
<configuration>
<filters>
Expand Down Expand Up @@ -61,15 +61,31 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>3.10.0</version>
<configuration>
<show>public</show>
<outputDirectory>${project.basedir}</outputDirectory>
<excludePackageNames>org.rtsl.dhis2.cucumber.factories:org.rtsl.dhis2.cucumber.utils</excludePackageNames>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assemblers/release.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down
12 changes: 12 additions & 0 deletions CommonUtils/Dhis2CucumberTestTool/release-artefacts/exec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

PROPERTIES_FILE="input.properties"
SCENARIOS=""

while IFS='=' read -r key value; do
if [[ $key == scenarios ]]; then
SCENARIOS=$value
fi
done < "$PROPERTIES_FILE"

java -Dorg.rtsl.dhis2.testtool.properties=input.properties -Dlogback.configurationFile=log-config.xml -Dfile.ending=UTF8 -jar Dhis2CucumberTestTool-*.jar --object-factory io.cucumber.spring.SpringFactory --plugin html:./test_reports.html --plugin json:./test_reports.json --plugin pretty --glue "org.rtsl.dhis2.cucumber.definitions" --glue "io.cucumber.spring" --threads 1 $SCENARIOS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dhis2.api.url=http://localhost:8080/
dhis2.api.username=admin
dhis2.api.password=district
scenarios=<path-to-features[-folder]>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<configuration>
<root level="off">
<appender-ref ref="unitTestLogs"/>
</root>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ public String doPutWithTemplate(String relativeUrl, String templateName, Object
try (CloseableHttpResponse response = httpClient.execute(request)) {
return handleResponse(response);
}

}

}
public String doPutWithBody(String relativeUrl, String body) throws Exception {

public String doPutWithBody(String relativeUrl, String body) throws Exception {
LOGGER.info("Doing PUT call on url <{}> with body <{}>", dhis2RootUrl + relativeUrl, body);
// Makes the call
try (CloseableHttpClient httpClient = HttpClients.createDefault();) {
Expand All @@ -73,9 +71,7 @@ public String doPutWithBody(String relativeUrl, String body) throws Exception {
try (CloseableHttpResponse response = httpClient.execute(request)) {
return handleResponse(response);
}

}

}

public String doPost(String relativeUrl, String templateName, Object templateContext) throws Exception { // TODO : factorize, possibly make a class ...
Expand All @@ -95,9 +91,7 @@ public String doPost(String relativeUrl, String templateName, Object templateCon
try (CloseableHttpResponse response = httpClient.execute(request)) {
return handleResponse(response);
}

}

}

public String doPost(String relativeUrl) throws Exception{
Expand All @@ -108,7 +102,6 @@ public String doPost(String relativeUrl) throws Exception{
try (CloseableHttpResponse response = httpClient.execute(request)) {
return handleResponse(response);
}

}
}

Expand All @@ -129,7 +122,6 @@ public String doPatch(String relativeUrl, String templateName, Object templateCo
try (CloseableHttpResponse response = httpClient.execute(request)) {
return handleResponse(response);
}

}
}

Expand All @@ -144,7 +136,6 @@ public String doGet(String relativeUrl) throws Exception {
try (CloseableHttpResponse response = httpClient.execute(request)) {
return handleResponse(response);
}

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<configuration>

<appender name="unitTestLogs" class="ch.qos.logback.core.FileAppender">
<file>${TARGET_DIR}/cucumber-reports/test_reports.log</file>
<append>true</append>
Expand All @@ -14,7 +13,4 @@
<root level="trace">
<appender-ref ref="unitTestLogs"/>
</root>



</configuration>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
dhis2.api.url=http://localhost:8080/
dhis2.api.username=admin
dhis2.api.password=district



__encrypted__.dhis2.api.password=true
__encrypted__.database.jdbc.password=true
__encrypted__.database.jdbc.username=true
__hidden__.jdbc.host=true

0 comments on commit ff1fcab

Please sign in to comment.