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

Specify events when pulling fields from REDCap #69

Merged
merged 20 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 36 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Continuous integration, including test and integration test
name: CI

# Run in main and dev branches and in all pull requests to those branches
on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master, dev ]

jobs:
# Build and test the code
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# Compile the code
- name: Compile code
run: ./gradlew assemble

# Gradle check
- name: Check
run: ./gradlew check
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM openjdk:14 as builder
FROM openjdk:17 as builder

RUN mkdir /code
WORKDIR /code
Expand Down
222 changes: 101 additions & 121 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,176 +5,167 @@ plugins {
id 'checkstyle'
id 'jacoco'
id 'application'
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'org.jetbrains.kotlin.jvm' version '1.5.21'
}

group 'org.radarbase'
version '1.0.2-SNAPSHOT'
group = 'org.radarbase'
version = '1.0.5-SNAPSHOT'

mainClassName = 'org.radarbase.redcap.webapp.GrizzlyServer'

targetCompatibility = '11'
sourceCompatibility = '11'
application {
mainClass = 'org.radarbase.redcap.webapp.GrizzlyServer'
}

configurations {
codacy
provided
compile.extendsFrom provided
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}

repositories {
mavenCentral()
}

sourceSets {
main.kotlin.srcDirs += 'src/main/kotlin'
main.java.srcDirs += 'src/main/kotlin'

test.kotlin.srcDirs += 'src/test/kotlin'
test.java.srcDirs += 'src/test/kotlin'

main {
java {
srcDirs += 'src/main/kotlin'
}
kotlin {
srcDirs += 'src/main/kotlin'
}
}
test {
java {
srcDirs += 'src/test/kotlin'
}
kotlin {
srcDirs += 'src/test/kotlin'
}
}
integrationTest {
java {
compileClasspath += main.output + test.output + test.compileClasspath
runtimeClasspath += main.output + test.output + test.compileClasspath + test.runtimeClasspath + main.runtimeClasspath
srcDir file('src/integration-test/kotlin')
srcDirs += 'src/integration-test/kotlin'
compileClasspath += sourceSets.main.output + sourceSets.test.output + configurations.testRuntimeClasspath
runtimeClasspath += output + compileClasspath + configurations.testRuntimeClasspath
}
resources {
srcDirs += 'src/integration-test/resources'
}
resources.srcDir file('src/integration-test/resources')
}
}

configurations {
codacy
provided
compileClasspath {
extendsFrom(provided)
}
}

ext.apacheCommonsIoVersion = '2.5'
ext.apacheCommonsLangVersion = '3.6'
ext.jerseyVersion = '2.30.1'
ext.jerseymediaVersion = '2.30.1'
ext.junitVersion = '4.12'
ext.logbackVersion = '1.2.3'
ext.okhttp3Version = '3.8.1'
ext.radarOauthClientVersion = '0.8.0'
ext.grizzlyVersion = '2.4.4'
ext.jacksonVersion = '2.11.2'
ext {
apacheCommonsIoVersion = '2.5'
apacheCommonsLangVersion = '3.6'
jerseyVersion = '2.30.1'
jerseymediaVersion = '2.30.1'
junitVersion = '4.12'
logbackVersion = '1.2.3'
okhttp3Version = '4.9.3'
radarOauthClientVersion = '0.8.0'
grizzlyVersion = '2.4.4'
jacksonVersion = '2.11.2'
}

dependencies {
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackVersion
runtimeOnly group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: jerseymediaVersion

implementation group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet', version: jerseyVersion
implementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: jerseyVersion

implementation group: 'org.glassfish.grizzly', name: 'grizzly-http-server', version: grizzlyVersion
implementation group: 'org.glassfish.jersey.containers', name: 'jersey-container-grizzly2-http', version: jerseyVersion

implementation group: 'org.radarbase', name: 'oauth-client-util', version: radarOauthClientVersion

implementation group: 'commons-io', name: 'commons-io', version: apacheCommonsIoVersion
implementation group: 'org.apache.commons', name: 'commons-lang3', version: apacheCommonsLangVersion

implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: okhttp3Version

implementation "ch.qos.logback:logback-classic:$logbackVersion"
runtimeOnly "org.glassfish.jersey.media:jersey-media-json-jackson:$jerseymediaVersion"
implementation "org.glassfish.jersey.containers:jersey-container-servlet:$jerseyVersion"
implementation "org.glassfish.jersey.inject:jersey-hk2:$jerseyVersion"
implementation "org.glassfish.grizzly:grizzly-http-server:$grizzlyVersion"
implementation "org.glassfish.jersey.containers:jersey-container-grizzly2-http:$jerseyVersion"
implementation "org.radarbase:oauth-client-util:$radarOauthClientVersion"
implementation "commons-io:commons-io:$apacheCommonsIoVersion"
implementation "org.apache.commons:commons-lang3:$apacheCommonsLangVersion"
implementation "com.squareup.okhttp3:okhttp:$okhttp3Version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-reflect"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:${jacksonVersion}"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonVersion}"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$jacksonVersion"
implementation "org.json:json:20170516"

testImplementation group: 'junit', name: 'junit', version: junitVersion
testImplementation "junit:junit:$junitVersion"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
}

//---------------------------------------------------------------------------//
// Style checking //
//---------------------------------------------------------------------------//
checkstyle {
// codacy version
toolVersion '6.16'
ignoreFailures false

// ignore tests
toolVersion = '8.46'
ignoreFailures = false
sourceSets = [sourceSets.main, sourceSets.test, sourceSets.integrationTest]
}

pmd {
// pmd version
toolVersion = '6.0.0'
toolVersion = '6.44.0'
ignoreFailures = false

sourceSets = [sourceSets.main, sourceSets.test, sourceSets.integrationTest]

consoleOutput = true

ruleSets = []
ruleSetFiles = files("config/pmd/ruleset.xml")
}

pmdTest {
tasks.named('pmdTest') {
ruleSetFiles = files("config/pmd/test_ruleset.xml")
}


//---------------------------------------------------------------------------//
// Build system metadata //
//---------------------------------------------------------------------------//
idea {
module {
downloadSources = true
}
}

gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
tasks.withType(JavaCompile) {
options.compilerArgs.addAll(['-Xlint:unchecked', '-Xlint:deprecation'])
}

wrapper {
gradleVersion = '6.4'
tasks.named('wrapper') {
gradleVersion = '7.4'
}

tasks.withType(Tar) {
compression = Compression.GZIP
extension("tar")
extension = "tar"
}

//---------------------------------------------------------------------------//
// Testing //
//---------------------------------------------------------------------------//

test {
testLogging {
// Show that tests are run in the command-line output
events "skipped", "failed"
events("skipped", "failed")
}
}

task downloadApplicationDependencies {
description "Pre-downloads application dependencies"
configurations.compileClasspath.files
configurations.runtimeClasspath.files
tasks.register('downloadApplicationDependencies') {
description = "Pre-downloads application dependencies"
doLast {
configurations.compileClasspath.getFiles()
configurations.runtimeClasspath.getFiles()
}
}

task integrationTest(type: Test, dependsOn: ['installMP', 'copyConf']) {
tasks.register('integrationTest', Test) {
description = "Run integration tests (located in src/integrationTest/...)."

dependsOn('installMP', 'copyConf')
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath

// Don't run specific test classes as they will be run by the Test Suite
exclude '**/*IntegratorTest*'
exclude '**/*MpClientTest*'
exclude '**/*EntryPointTest*'
// This is not needed, but I like to see which tests have run
exclude("**/*IntegratorTest*", "**/*MpClientTest*", "**/*EntryPointTest*")
testLogging {
events "skipped", "failed", "passed", "STANDARD_OUT", "STANDARD_ERROR"
events("skipped", "failed", "passed", "STANDARD_OUT", "STANDARD_ERROR")
}
}

integrationTest.finalizedBy 'removeLock'
tasks.named('integrationTest') {
finalizedBy('removeLock')
}

ext.sudoLinux = System.properties['os.name'].toLowerCase().contains('linux') ? ['sudo'] : []
ext.lock = 'src/integration-test/.RUNNING_INSTANCE_LOCK'
def sudoLinux = System.properties['os.name'].toLowerCase().contains('linux') ? ['sudo'] : []
def lock = 'src/integration-test/.RUNNING_INSTANCE_LOCK'

task installMP(type: Exec) {
tasks.register('installMP', Exec) {
doFirst {
def lockFile = new File(lock)
if (lockFile.exists()) {
Expand All @@ -183,44 +174,33 @@ task installMP(type: Exec) {
lockFile.createNewFile()
}
}

workingDir 'src/integration-test/'
workingDir = file('src/integration-test/')
standardInput = System.in
commandLine sudoLinux + ['docker-compose', 'up', '-d', '--build', '--force-recreate']

commandLine = sudoLinux + ['docker-compose', 'up', '-d', '--build', '--force-recreate']
doLast {
// wait until the managementportal is ready
sleep(60_000)
Thread.sleep(60_000)
}
}

task removeLock(type: Exec) {

workingDir 'src/integration-test/'
commandLine sudoLinux + ['docker-compose', 'down']

tasks.register('removeLock', Exec) {
workingDir = file('src/integration-test/')
commandLine = sudoLinux + ['docker-compose', 'down']
doLast {
new File(lock).delete()
}
}

task copyConf(type: Copy) {
from "src/integration-test/resources/radar.yml"
into "/usr/local/etc/radar-redcap-int/"

tasks.register('copyConf', Copy) {
from = "src/integration-test/resources/radar.yml"
into = "/usr/local/etc/radar-redcap-int/"
filter { String line ->
line.replace(" base_url: http://managementportal-app:8090/",
" base_url: http://localhost:8090/")
" base_url: http://localhost:8090/")
}
}

compileKotlin {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
jvmTarget = "11"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EntryPointTest {
Assert.assertNotNull(response)
// This is because the the app fails to update redcap form as there is no actual redcap instance.
// So the request times out with an exception
Assert.assertEquals(500, response.code().toLong())
Assert.assertEquals(500, response.code)

// But we can verify if the corresponding subject creation in MP works fine.
val subject: Subject? =
Expand Down
Loading
Loading