Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cgendreau committed Dec 10, 2020
2 parents e617b92 + 1d9f126 commit 618b43e
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 349 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Java CI

on: [push]

jobs:
build:
name: Test, validate and build Java application
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn verify
- name: Run Checkstyle
run: mvn checkstyle:check
- name: Run SpotBugs
run: mvn com.github.spotbugs:spotbugs-maven-plugin:check
- name: Run OWASP dependency-check (only on dev)
run: mvn org.owasp:dependency-check-maven:check
if: ${{ github.ref == 'refs/heads/dev' }}

- name: Extract Version
if: ${{ github.ref == 'refs/heads/master' }}
run: |
mvn help:evaluate -Dexpression=project.version -q -DforceStdout > version.txt
- name: Store artifacts
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: |
version.txt
target/seqdb.api-*.jar
Dockerfile
push:
name: Build Docker Image and Push to DockerHub
needs: [build]
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}

steps:
- name: Download artifacts from build job
uses: actions/download-artifact@v2
with:
name: build-artifacts

- name: Set VERSION_TAG ENV variable
run: |
echo "VERSION_TAG=$(cat version.txt)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build Image and Push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: aafcbicoe/seqdb-api:${{ env.VERSION_TAG }}
31 changes: 0 additions & 31 deletions .github/workflows/maven.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
/target/
.vscode
.factorypath
*.env
*.env
docker-compose.yml
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM maven:3.6.3-jdk-11-slim
FROM openjdk:11-jre-slim

RUN useradd -s /bin/bash user
USER user
COPY --chown=644 target/seqdb.api-*.jar /seqdb-api.jar
Expand Down
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ seqdb-api is an implementation of the Sequence Module for the [DINA project](htt
* Java 11
* Maven 3.2+
* PostgreSQL 10
* Docker

## Run

Expand All @@ -27,20 +28,28 @@ mvn clean compile

The single HTML page will be available at `target/generated-docs/index.html`

## Testing
## To Run

For testing purpose or local development a [Docker Compose](https://docs.docker.com/compose/) file is available in the `local` folder.
For testing purpose a [Docker Compose](https://docs.docker.com/compose/) example file is available in the `local` folder.

**Please Note** : when running a local postgres database you will want to map your ports to something other then 5432 inside your `Docker Compose`:
Create a new docker-compose.yml file and .env file from the example file in the local directory:

```
ports:
- "5431:5432"
cp local/docker-compose.yml.example docker-compose.yml
cp local/*.env .
```

And then you will want to update your `test-db-configuration` URLs to:
````
url: jdbc:postgresql://localhost:5431/seqdb_api_test?currentSchema=seqdb
````
Start the app (default port is 8084):

This example would map your containers 5432 port to your Host machines 5431 port and the updated spring source url would allow your tests to connect to the newly mapped port.
```
docker-compose up
```

Once the services have started you can access the endpoints at http://localhost:8084/api/

Cleanup:
```
docker-compose down
```

Automated tests are run using an embedded Docker container.
21 changes: 13 additions & 8 deletions local/docker-compose.yml.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
version: '3'
version: '3.7'
services:
db:
seqdb-db:
image: "postgres:10"
container_name: "seqdbapi_test_postgres"
environment:
POSTGRES_DB: seqdb_api_test
POSTGRES_PASSWORD: mypassword
env_file:
- ${BASE_PATH_TO_SEQDB:-.}/pg.env
volumes:
- ./src/test/resources/init-db.sql:/docker-entrypoint-initdb.d/1-init-schema.sql
- ${BASE_PATH_TO_SEQDB:-.}/src/test/resources/init-test-db.sql:/docker-entrypoint-initdb.d/1-init-schema.sql

seqdb-api:
build: ${BASE_PATH_TO_SEQDB:-.}
ports:
- "5432:5432"
- "8084:8080"
env_file:
- ${BASE_PATH_TO_SEQDB:-.}/seqdb-api.env
networks:
default:

2 changes: 2 additions & 0 deletions local/pg.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
POSTGRES_DB=seqdb_test
POSTGRES_PASSWORD= mypassword
6 changes: 6 additions & 0 deletions local/seqdb-api.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spring.datasource.url=jdbc:postgresql://seqdb-db/seqdb_test?currentSchema=seqdb
spring.datasource.username=web_user
spring.datasource.password=test
spring.liquibase.user=migration_user
spring.liquibase.password=test

68 changes: 4 additions & 64 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,29 @@

<groupId>ca.gc.aafc</groupId>
<artifactId>seqdb.api</artifactId>
<version>1.5</version>
<version>2.0.0</version>
<packaging>jar</packaging>

<name>seqdb.api</name>
<url>https://github.com/AAFC-BICoE/seqdb-api</url>

<properties>
<java.version>11</java.version>
<modelmapper.version>1.1.3</modelmapper.version>
<guava.version>24.1.1-jre</guava.version>
<javax.inject.version>1</javax.inject.version>
<!-- Different from SpringBoot javax-jaxb.version since they don't manage jaxb-core and jaxb-impl-->
<javax.interceptor-api>1.2.2</javax.interceptor-api>

<spotbugs-maven-plugin.version>4.1.3</spotbugs-maven-plugin.version>
<spotbugs.version>4.1.3</spotbugs.version>
<jcip-annotations.version>1.0</jcip-annotations.version>

<!-- Override SpringBoot version (3.6) to avoid NoClassDefFoundError: org/apache/maven/doxia/siterenderer/DocumentContent -->
<maven-site-plugin.version>3.7.1</maven-site-plugin.version>
<dependency-check-maven.version>6.0.2</dependency-check-maven.version>
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
<jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version>
<checkstyle.version>8.36</checkstyle.version>
<asciidoctor-maven-plugin.version>2.1.0</asciidoctor-maven-plugin.version>
<justify.version>0.17.0</justify.version>
<javax.json.version>1.1.3</javax.json.version>
<commons.beanutils.version>1.9.3</commons.beanutils.version>
<hibernate-types-52.version>2.9.5</hibernate-types-52.version>
<dina-base-api.version>0.42</dina-base-api.version>

Expand Down Expand Up @@ -74,9 +70,8 @@
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>

<!-- util -->
<dependency>
<!-- util -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
Expand All @@ -85,82 +80,27 @@
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</dependency>

<!-- Used by Spotbug annotation -->
<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
<version>${jcip-annotations.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>${spotbugs.version}</version>
<scope>provided</scope>
</dependency>

<!-- Required support for JAXB annotations as of the latest version of liquibase. Redmine Issue: #18647-->
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${commons.beanutils.version}</version>
</dependency>

<!-- TEST Scope -->
<dependency>
<groupId>ca.gc.aafc</groupId>
<artifactId>dina-test-support</artifactId>
<version>${dina-base-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured-all</artifactId>
<version>${rest-assured.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.leadpony.justify</groupId>
<artifactId>justify</artifactId>
<version>${justify.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>${javax.json.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public JpaDtoMapper dtoJpaMapper(BaseDAO baseDAO) {

// Map all DTOs to their related Entities.
Map<Class<?>, Class<?>> entitiesMap = ClassAnnotationHelper
.findAnnotatedClasses(ChainDto.class, RelatedEntity.class)
.findAnnotatedClasses(RegionDto.class, RelatedEntity.class)
.stream()
.collect(
Collectors.toMap(
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/ca/gc/aafc/seqdb/api/dto/PcrPrimerDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import java.time.OffsetDateTime;
import java.util.UUID;

import org.javers.core.metamodel.annotation.Id;
import org.javers.core.metamodel.annotation.PropertyName;
import org.javers.core.metamodel.annotation.ShallowReference;
import org.javers.core.metamodel.annotation.TypeName;

import ca.gc.aafc.dina.dto.RelatedEntity;
import ca.gc.aafc.seqdb.api.entities.PcrPrimer;
import ca.gc.aafc.seqdb.api.entities.PcrPrimer.PrimerType;
Expand All @@ -15,12 +20,17 @@
import lombok.Data;

@Data
@JsonApiResource(type = "pcrPrimer")
@JsonApiResource(type = PcrPrimerDto.TYPENAME)
@SuppressFBWarnings(value = "EI_EXPOSE_REP")
@RelatedEntity(PcrPrimer.class)
@TypeName(PcrPrimerDto.TYPENAME)
public class PcrPrimerDto {

public static final String TYPENAME = "pcrPrimer";

@JsonApiId
@Id
@PropertyName("id")
private UUID uuid;

private String createdBy;
Expand All @@ -32,6 +42,7 @@ public class PcrPrimerDto {

private String name;

@ShallowReference
private PrimerType type;

private String seq;
Expand Down Expand Up @@ -71,7 +82,7 @@ public class PcrPrimerDto {
private String stockConcentration;

// Optional relations

@ShallowReference
@JsonApiRelation
private RegionDto region;

Expand Down
Loading

0 comments on commit 618b43e

Please sign in to comment.