Skip to content

Commit

Permalink
ALFREDAPI-518 fix ci logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hechmi-dammak-xenit authored and todorinskiz committed Apr 26, 2023
1 parent 0f46294 commit f63f8e3
Show file tree
Hide file tree
Showing 24 changed files with 218 additions and 103 deletions.
79 changes: 50 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
name: 'Continuous Integration'
on:
push:
branches:
- 'master*'
- 'release*'
pull_request:
workflow_dispatch:
env:
XENIT_ARTIFACTORY_USERNAME: ${{ secrets.XENIT_ARTIFACTORY_USERNAME }}
XENIT_ARTIFACTORY_PASSWORD: ${{ secrets.XENIT_ARTIFACTORY_PASSWORD }}
jobs:
BuildAndPublish:
test:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
- name: Build interface
uses: gradle/gradle-build-action@v2.3.0
with:
arguments: :apix-interface:build :apix-interface:javadoc
- name: Unit test REST API
uses: gradle/gradle-build-action@v2.3.0
with:
arguments: --info :apix-rest-v1:test
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v3
with:
name: test-result
path: /home/runner/work/**/build/reports
retention-days: 2
integration-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
alfresco_version: [ 62, 70, 71, 72, 73 ]
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
Expand All @@ -26,25 +51,8 @@ jobs:
registry: private.docker.xenit.eu
username: ${{ secrets.CLOUDSMITH_USER }}
password: ${{ secrets.CLOUDSMITH_APIKEY }}
- name: Build interface # Execute before integration testing to catch errors early
uses: gradle/gradle-build-action@v2.3.0
env:
XENIT_ARTIFACTORY_USERNAME: ${{ secrets.XENIT_ARTIFACTORY_USERNAME }}
XENIT_ARTIFACTORY_PASSWORD: ${{ secrets.XENIT_ARTIFACTORY_PASSWORD }}
with:
arguments: :apix-interface:build :apix-interface:javadoc
- name: Unit test REST API
- name: Integration test and apix impl test
uses: gradle/gradle-build-action@v2.3.0
env:
XENIT_ARTIFACTORY_USERNAME: ${{ secrets.XENIT_ARTIFACTORY_USERNAME }}
XENIT_ARTIFACTORY_PASSWORD: ${{ secrets.XENIT_ARTIFACTORY_PASSWORD }}
with:
arguments: --info :apix-rest-v1:test
- name: Build and test
uses: gradle/gradle-build-action@v2.3.0
env:
XENIT_ARTIFACTORY_USERNAME: ${{ secrets.XENIT_ARTIFACTORY_USERNAME }}
XENIT_ARTIFACTORY_PASSWORD: ${{ secrets.XENIT_ARTIFACTORY_PASSWORD }}
with:
arguments: >-
--info
Expand All @@ -54,15 +62,28 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: test-result
name: test-result-${{ matrix.alfresco_version }}
path: /home/runner/work/**/build/reports
retention-days: 2
publish:
needs: [ test, integration-test ]
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/release') }}
strategy:
fail-fast: false
matrix:
alfresco_version: [ 62, 70, 71, 72, 73 ]
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
- name: Publish
if: ${{ startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/release') }}"
uses: gradle/gradle-build-action@v2.3.0
env:
XENIT_ARTIFACTORY_USERNAME: ${{ secrets.XENIT_ARTIFACTORY_USERNAME }}
XENIT_ARTIFACTORY_PASSWORD: ${{ secrets.XENIT_ARTIFACTORY_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_CENTRAL_GPG_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }}
ORG_GRADLE_PROJECT_sonatype_username: ${{ secrets.SONATYPE_S01_USERNAME }}
Expand All @@ -71,4 +92,4 @@ jobs:
arguments: >-
--info -PsigningKeyId=DF8285F0
:apix-interface:publish
:alfresco:${{ matrix.alfresco_version }}:publish
:apix-impl:apix-impl-${{ matrix.alfresco_version }}:publish
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testGetAllNodeInfoOfMultipleNodes() throws IOException, JSONExceptio

@Test
public void testGetAllNodeInfoWithNoNodesListed() throws IOException {
String jsonString = json("{}");
String jsonString = json("");

final CloseableHttpClient httpclient = HttpClients.createDefault();
final String url = makeAlfrescoBaseurl("admin", "admin") + "/apix/v1/nodes/nodeInfo";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package eu.xenit.apix.rest.v1.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import com.fasterxml.jackson.databind.ObjectMapper;
import eu.xenit.apix.alfresco.ApixToAlfrescoConversion;
import eu.xenit.apix.data.NodeRef;
import eu.xenit.apix.versionhistory.Version;
import eu.xenit.apix.versionhistory.VersionHistory;
import java.io.IOException;
import java.util.HashMap;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.version.VersionBaseModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeService;
Expand All @@ -22,6 +15,7 @@
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
Expand All @@ -36,10 +30,17 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.io.IOException;
import java.util.HashMap;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;


public class VersionHistoryTest extends RestV1BaseTest {

private final static Logger logger = LoggerFactory.getLogger(VersionHistoryTest.class);
private static final Logger logger = LoggerFactory.getLogger(VersionHistoryTest.class);
@Autowired
@Qualifier("TransactionService")
TransactionService transactionService;
Expand Down Expand Up @@ -119,12 +120,10 @@ public void testSetVersionHistoryWithoutBody() throws IOException {
return null;
}, true, true);

int statusCode = Request.Put(versionHistoryUrl)
HttpResponse response = Request.Put(versionHistoryUrl)
.execute()
.returnResponse()
.getStatusLine()
.getStatusCode();
assertEquals(200, statusCode);
.returnResponse();
assertEquals(200, response.getStatusLine().getStatusCode());

transactionService.getRetryingTransactionHelper()
.doInTransaction(() -> {
Expand Down Expand Up @@ -170,12 +169,11 @@ public void testSetVersionHistoryWithoutBody() throws IOException {

HttpPut httpPut = new HttpPut(versionHistoryUrl2);
httpPut.setEntity(new StringEntity(json(requestBody), ContentType.APPLICATION_JSON));
int statusCode2 = HttpClients.createDefault()
.execute(httpPut)
CloseableHttpResponse httpResponse = HttpClients.createDefault()
.execute(httpPut);
assertEquals(200, httpResponse
.getStatusLine()
.getStatusCode();

assertEquals(200, statusCode2);
.getStatusCode());

transactionService.getRetryingTransactionHelper()
.doInTransaction(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testGetAllNodeInfoOfMultipleNodes() throws IOException, JSONExceptio

@Test
public void testGetAllNodeInfoWithNoNodesListed() throws IOException {
String jsonString = json("{}");
String jsonString = json("");

final CloseableHttpClient httpclient = HttpClients.createDefault();
final String url = makeAlfrescoBaseurl("admin", "admin") + "/apix/v2/nodes/nodeInfo";
Expand Down
5 changes: 4 additions & 1 deletion apix-interface/src/main/java/eu/xenit/apix/data/NodeRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.io.Serializable;

/**
Expand All @@ -14,9 +15,11 @@ public class NodeRef implements Serializable {

private static final String FORWARD_SLASH = "/";
private static final String SPACESTORE_DIVIDER = "://";

private String value;

public NodeRef() {
}

@JsonCreator
public NodeRef(String s) {
value = s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Map;

public class WorkflowOrTaskChanges {
Expand All @@ -13,6 +14,9 @@ public WorkflowOrTaskChanges(@JsonProperty("propertiesToSet") Map<String, String
this.propertiesToSet = propertiesToSet;
}

public WorkflowOrTaskChanges() {
}

public Map<String, String> getPropertiesToSet() {
return propertiesToSet;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package eu.xenit.apix.rest.staging.workflow;

public class WorkflowClaimsBody {
private String id;
private String userName;

public WorkflowClaimsBody(String id, String userName) {
this.id = id;
this.userName = userName;
}

public WorkflowClaimsBody() {
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package eu.xenit.apix.rest.staging.workflow;

public class WorkflowReleaseBody {
private String id;

public WorkflowReleaseBody() {
}

public WorkflowReleaseBody(String id) {
this.id = id;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

@Override
public String toString() {
return "WorkflowReleaseBody{" +
"id='" + id + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
import eu.xenit.apix.workflow.search.TaskOrWorkflowSearchResult;
import eu.xenit.apix.workflow.search.TaskSearchQuery;
import eu.xenit.apix.workflow.search.WorkflowSearchQuery;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.apache.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -29,6 +24,12 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

@RestController
public class WorkflowWebscript {
private static final Logger logger = LoggerFactory.getLogger(WorkflowWebscript.class);
Expand Down Expand Up @@ -93,7 +94,7 @@ public ResponseEntity<Void> task(@PathVariable final String id) {

@PutMapping(value = "/workflows/{id}")
public ResponseEntity<Workflow> updateWorkflow(@PathVariable final String id,
@RequestBody final WorkflowOrTaskChanges changes) {
@RequestBody final WorkflowOrTaskChanges changes) {
return responseFrom(workflowService.updateWorkflow(id, changes));
}

Expand All @@ -104,8 +105,8 @@ public ResponseEntity<Void> cancelWorkflow(@PathVariable final String id) {
}

@PutMapping(value = "/tasks/{id}")
public ResponseEntity<Task> updateTask(@PathVariable final String id,
@RequestBody final WorkflowOrTaskChanges changes) {
public ResponseEntity<Task> updateTask(@PathVariable final String id,
@RequestBody final WorkflowOrTaskChanges changes) {
try {
return responseFrom(workflowService.updateTask(id, changes));
} catch (Error ex) {
Expand All @@ -114,27 +115,22 @@ public ResponseEntity<Task> updateTask(@PathVariable final String id,
}

@PostMapping(value = "/staging/tasks/claim")
public ResponseEntity<Task> claimTask(@RequestBody final Map<String, String> body) {
logger.debug("Input: {}", body);
String id = body.get("id");
String userName = body.get("userName");

public ResponseEntity<Task> claimTask(@RequestBody final WorkflowClaimsBody workflowClaimsBody) {
Task wfTask;
if (userName != null) {
logger.debug("Setting owner of task with id {} to {}", id, userName);
wfTask = workflowService.claimWorkflowTask(id, userName);
if (workflowClaimsBody.getUserName() != null) {
logger.debug("Setting owner of task with id {} to {}", workflowClaimsBody.getId(), workflowClaimsBody.getUserName());
wfTask = workflowService.claimWorkflowTask(workflowClaimsBody.getId(), workflowClaimsBody.getUserName());
} else {
logger.debug("Setting owner of task with id ");
wfTask = workflowService.claimWorkflowTask(id);
wfTask = workflowService.claimWorkflowTask(workflowClaimsBody.getId());
}
return responseFrom(wfTask);
}

@PostMapping(value = "/staging/tasks/release")
public ResponseEntity<Task> releaseTask(@RequestBody final Map<String, String> body) {
logger.debug("Setting owner of task {}", body);
String id = body.get("id");
Task wfTask = workflowService.releaseWorkflowTask(id);
public ResponseEntity<Task> releaseTask(@RequestBody final WorkflowReleaseBody workflowReleaseBody) {
logger.debug("Setting owner of task {}", workflowReleaseBody);
Task wfTask = workflowService.releaseWorkflowTask(workflowReleaseBody.getId());
return responseFrom(wfTask);
}

Expand Down
Loading

0 comments on commit f63f8e3

Please sign in to comment.