Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVA-3491: Add schema for submission tables #8

Merged
merged 6 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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;
apriltuesday marked this conversation as resolved.
Show resolved Hide resolved
Loading