Skip to content

Commit

Permalink
Merge pull request #8 from apriltuesday/EVA-3491
Browse files Browse the repository at this point in the history
EVA-3491: Add schema for submission tables
  • Loading branch information
apriltuesday authored Feb 9, 2024
2 parents a55d6cf + cd11a3a commit 8b70144
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Run tests

on:
push:
branches: [ master ]
pull_request:
branches: [ main ]

jobs:
build:
Expand Down
126 changes: 126 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
stages:
- test
- package
- deploy

variables:
WS_ARTIFACT_PATH: target/eva-submission-ws-$ENVIRONMENT_NAME.war
MAVEN_SETTINGS: maven-settings.xml
URL_MAVEN_SETTINGS: https://api.github.com/repos/EBIvariation/configuration/contents/eva-maven-settings.xml
MEDIA_TYPE: application/vnd.github.raw

test:
stage: test
image: maven:3.6.1-jdk-8-alpine
script:
- mvn test
environment:
name: test-env
only:
- master
- tags

# Not executed, parent job definition for package
.package:
stage: package
image: maven:3.6.1-jdk-8-alpine
environment:
name: $ENVIRONMENT_NAME
before_script:
- DATETIME=$(date +%Y-%m-%dT%H-%M-%S)
- apk add --update curl
- curl -u $GITHUB_USER:$GITHUB_TOKEN -H "Accept:$MEDIA_TYPE" $URL_MAVEN_SETTINGS > $MAVEN_SETTINGS
script:
- mvn package --settings $MAVEN_SETTINGS -P $MAVEN_PROFILE -DskipTests
- cp target/eva-submission-ws*.war.original $WS_ARTIFACT_PATH
after_script:
- rm $MAVEN_SETTINGS
artifacts:
paths:
- $WS_ARTIFACT_PATH

package-internal:
extends: .package
variables:
ENVIRONMENT_NAME: internal
MAVEN_PROFILE: internal
only:
- master

package-development:
extends: .package
variables:
ENVIRONMENT_NAME: development
MAVEN_PROFILE: development
only:
- master

package-production:
extends: .package
variables:
ENVIRONMENT_NAME: production
# Use production_processing to use production rather than public database
MAVEN_PROFILE: production_processing
only:
- tags

# Not executed, parent job definition for deployments
.deploy-tomcat:
stage: deploy
image: alpine:3.9.5
environment:
name: $ENVIRONMENT_NAME
script:
- DATETIME=$(date +%Y-%m-%dT%H-%M-%S)
- apk add --update curl
- curl -u $TOMCAT_USER:$TOMCAT_PASSWORD -T "$WS_ARTIFACT_PATH" "http://$TOMCAT_HOST/manager/text/deploy?update=true&path=/eva/webservices/submission-ws&version=$DATETIME" | grep "OK - Deployed application"

deploy-tomcat-internal:
extends: .deploy-tomcat
variables:
ENVIRONMENT_NAME: internal
TOMCAT_USER: $TOMCAT_INTERNAL_USER
TOMCAT_PASSWORD: $TOMCAT_INTERNAL_PASSWORD
TOMCAT_HOST: $TOMCAT_INTERNAL_HOST
dependencies:
- package-internal
only:
- master

deploy-tomcat-development:
extends: .deploy-tomcat
variables:
ENVIRONMENT_NAME: development
TOMCAT_USER: $TOMCAT_DEVELOPMENT_USER
TOMCAT_PASSWORD: $TOMCAT_DEVELOPMENT_PASSWORD
TOMCAT_HOST: $TOMCAT_DEVELOPMENT_HOST
dependencies:
- package-development
only:
- master

deploy-tomcat-production:
extends: .deploy-tomcat
when: manual
variables:
ENVIRONMENT_NAME: production
TOMCAT_USER: $TOMCAT_PRODUCTION_USER
TOMCAT_PASSWORD: $TOMCAT_PRODUCTION_PASSWORD
TOMCAT_HOST: $TOMCAT_PRODUCTION_HOST
dependencies:
- package-production
only:
- tags

deploy-tomcat-production-fallback:
extends: .deploy-tomcat
when: manual
variables:
ENVIRONMENT_NAME: production
TOMCAT_USER: $TOMCAT_PRODUCTION_FALLBACK_USER
TOMCAT_PASSWORD: $TOMCAT_PRODUCTION_FALLBACK_PASSWORD
TOMCAT_HOST: $TOMCAT_PRODUCTION_FALLBACK_HOST
dependencies:
- package-production
only:
- tags
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Objects;

@Entity
@Table(name = "submission")
@Table(schema = "eva_submissions", name = "submission")
public class Submission {

public Submission() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
import java.util.List;

@Entity
@Table(name = "submission_account", uniqueConstraints = {@UniqueConstraint(columnNames = {"user_id", "login_type"})})
@Table(schema = "eva_submissions", name = "submission_account", uniqueConstraints = {@UniqueConstraint(columnNames =
{"user_id", "login_type"})})
public class SubmissionAccount {

@Id
private String id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import javax.persistence.Table;

@Entity
@Table(name = "submission_details")
@Table(schema = "eva_submissions", name = "submission_details")
public class SubmissionDetails {

@Id
@Column(name = "submission_id")
private String submissionId;
Expand All @@ -28,7 +29,7 @@ public SubmissionDetails() {

}

public SubmissionDetails(Submission submission){
public SubmissionDetails(Submission submission) {
this.submission = submission;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ spring.datasource.url=|eva.evapro.jdbc.url|
spring.datasource.username=|eva.evapro.user|
spring.datasource.password=|eva.evapro.password|
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.default_schema=eva_submissions
spring.jmx.default-domain=eva.ebi.ac.uk.submission-ws.|timestamp|

globus.clientId=|globus.client-id|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public class SubmissionWSIntegrationTest {
private GlobusDirectoryProvisioner globusDirectoryProvisioner;

@Container
static PostgreSQLContainer<?> postgreSQLContainer = new PostgreSQLContainer<>("postgres:9.6");
static PostgreSQLContainer<?> postgreSQLContainer = new PostgreSQLContainer<>("postgres:9.6")
.withInitScript("init.sql");

@DynamicPropertySource
static void dataSourceProperties(DynamicPropertyRegistry registry) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
spring.jpa.properties.hibernate.default_schema=eva_submissions

globus.clientId=
globus.clientSecret=
globus.refreshToken=
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE SCHEMA IF NOT EXISTS eva_submissions;

0 comments on commit 8b70144

Please sign in to comment.