Skip to content

Commit

Permalink
Merge branch 'master' into platform/kalish/15766-azure-event-item-sent
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalish authored Sep 25, 2024
2 parents 997fd43 + db9921c commit e6909dc
Show file tree
Hide file tree
Showing 21 changed files with 232 additions and 74 deletions.
70 changes: 70 additions & 0 deletions .github/actions/build-auth/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# action.yml
name: "Build Auth"
description: "Build Auth microservice"
inputs:
version:
description: "Version tag"
required: true
upload-build:
default: true
run-integration-tests:
default: false
run-qc:
default: false
github-token:
default: false
sp-creds:
description: "Azure Service Principal creds"

runs:
using: "composite"
steps:
# These are for CI and not credentials of any system
- name: Set Environment Variables
working-directory: prime-router
shell: bash
run: |
echo >> $GITHUB_ENV DB_USER='prime'
echo >> $GITHUB_ENV DB_PASSWORD='changeIT!'
- name: Remove unnecessary software
shell: bash
run: |
sudo rm -rf /usr/local/lib/android
- name: Set up JDK 17
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88
with:
java-version: "17"
distribution: "temurin"
cache: "gradle"

- uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808

- name: Lint
if: inputs.run-integration-tests == 'true'
run: ./gradlew :auth:ktlintCheck
shell: bash

- name: Spin up build containers
working-directory: prime-router
shell: bash
run: docker compose -f docker-compose.postgres.yml up -d

- name: Build auth Package
uses: ./.github/actions/retry
with:
timeout_minutes: 10
max_attempts: 2
retry_wait_seconds: 30
command: |
./gradlew :auth:build -x test
shell: bash

- name: Cleanup Gradle Cache
if: inputs.run-integration-tests == 'true'
working-directory: prime-router
run: |
rm -f .gradle/caches/modules-2/modules-2.lock
rm -f .gradle/caches/modules-2/gc.properties
shell: bash
6 changes: 3 additions & 3 deletions .github/actions/sonarcloud/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ runs:
args: >
-Dsonar.coverage.exclusions=prime-router/src/test/**,prime-router/src/testIntegration/**,prime-router/src/main/kotlin/cli/tests/**,frontend-react/**/__mocks__/**,frontend-react/**/mocks/**,frontend-react/**/*.test.*,submissions/src/test/**
-Dsonar.cpd.exclusions=frontend-react/**/*.test.*,prime-router/src/test/**,prime-router/src/testIntegration/**,prime-router/src/main/kotlin/cli/tests/**,submissions/src/test/**
-Dsonar.sources=frontend-react/src,prime-router/src,submissions/src,shared/src
-Dsonar.sources=frontend-react/src,prime-router/src,submissions/src,auth/src,shared/src
-Dsonar.projectKey=CDCgov_prime-data-hub
-Dsonar.organization=cdcgov
-Dsonar.java.binaries=prime-router/build/classes/java/main,prime-router/build/classes/kotlin/main,submissions/build/classes/kotlin/main,shared/build/classes/kotlin/main
-Dsonar.java.libraries=prime-router/build/libs/*.jar,prime-router/build/**/*.jar,submissions/build/**/*.jar,shared/build/**/*.jar
-Dsonar.java.binaries=prime-router/build/classes/java/main,prime-router/build/classes/kotlin/main,submissions/build/classes/kotlin/main,auth/build/classes/kotlin/main,shared/build/classes/kotlin/main
-Dsonar.java.libraries=prime-router/build/libs/*.jar,prime-router/build/**/*.jar,submissions/build/**/*.jar,auth/build/**/*.jar,shared/build/**/*.jar
-Dsonar.coverage.jacoco.xmlReportPaths=prime-router/build/reports/jacoco/test/jacocoTestReport.xml
-Dsonar.javascript.lcov.reportPaths=frontend-react/coverage/lcov.info
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- "prime-router/**"
- "submissions/**"
- "shared/**"
- "auth/**"

jobs:
pre_job:
Expand All @@ -30,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
folder: [prime-router, submissions, shared]
folder: [prime-router, submissions, auth, shared]
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: snyk/actions/setup@b98d498629f1c368650224d6d212bf7dfa89e4bf
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ jobs:
if: steps.changed-files-yaml.outputs.backend_any_changed == 'true' || steps.branch-name.outputs.is_default == 'true'
uses: ./.github/actions/build-submissions

- name: Build Auth Package
if: steps.changed-files-yaml.outputs.backend_any_changed == 'true' || steps.branch-name.outputs.is_default == 'true'
uses: ./.github/actions/build-auth

- name: Perform Java CodeQL Analysis
if: steps.changed-files-yaml.outputs.backend_any_changed == 'true' || steps.branch-name.outputs.is_default == 'true'
uses: github/codeql-action/analyze@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ test.describe("Organization Edit Page", {
const rowCount = await organizationEditPage.page.locator("#orgsendersettings .usa-table tbody tr").count();
expect(rowCount).toBeGreaterThanOrEqual(1);
});

test("can edit an organization sender", async ({ organizationEditPage }) => {
const firstOrgSender = await organizationEditPage.page.locator("#orgsendersettings").nth(0).locator("td").nth(0).innerText();
await organizationEditPage.page.locator('#orgsendersettings').getByRole('link', { name: 'Edit' }).nth(0).click();
await expect(organizationEditPage.page).toHaveURL(`/admin/orgsendersettings/org/ignore/sender/${firstOrgSender}/action/edit`);
await expect(organizationEditPage.page.getByText(`Org name: ignore`)).toBeVisible();
await expect(organizationEditPage.page.getByText(`Sender name: ${firstOrgSender}`)).toBeVisible();

await expect(organizationEditPage.page.getByTestId("name")).not.toBeEmpty();
await expect(organizationEditPage.page.getByTestId("format")).not.toBeEmpty();
await expect(organizationEditPage.page.getByTestId("topic")).not.toBeEmpty();
await expect(organizationEditPage.page.getByTestId("customerStatus")).not.toBeEmpty();
await expect(organizationEditPage.page.getByTestId("processingType")).not.toBeEmpty();
});
});

test.describe("'Organization Receiver Settings' section", () => {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Dfile.encoding=UTF8 -Xmx2048M
# Set Kotlin version for all peices of the build environment
systemProp.kotlinVersion=1.9.23
systemProp.kotlinVersion=1.9.25
96 changes: 62 additions & 34 deletions prime-router/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,27 @@ apply(from = rootProject.file("buildSrc/shared.gradle.kts"))
plugins {
val kotlinVersion by System.getProperties()
id("reportstream.project-conventions")
id("org.flywaydb.flyway") version "10.17.0"
id("org.flywaydb.flyway") version "10.18.0"
id("nu.studer.jooq") version "9.0"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.microsoft.azure.azurefunctions") version "1.16.1"
id("com.adarshr.test-logger") version "4.0.0"
id("jacoco")
id("org.jetbrains.dokka") version "1.8.20"
id("com.avast.gradle.docker-compose") version "0.17.7"
id("com.avast.gradle.docker-compose") version "0.17.8"
id("org.jetbrains.kotlin.plugin.serialization") version "$kotlinVersion"
id("com.nocwriter.runsql") version ("1.0.3")
id("io.swagger.core.v3.swagger-gradle-plugin") version "2.2.22"
id("io.swagger.core.v3.swagger-gradle-plugin") version "2.2.23"
}

// retrieve the current commit hash
val commitId by lazy {
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}
stdout.toString(StandardCharsets.UTF_8).trim()
}

group = "gov.cdc.prime.reportstream"
Expand All @@ -65,7 +75,7 @@ val javaVersion = when (appJvmTarget) {
}
val ktorVersion = "2.3.12"
val kotlinVersion by System.getProperties()
val jacksonVersion = "2.17.1"
val jacksonVersion = "2.17.2"
jacoco.toolVersion = "0.8.12"

// Local database information, first one wins:
Expand Down Expand Up @@ -261,6 +271,9 @@ sourceSets.create("testIntegration") {
runtimeClasspath += sourceSets["main"].output
}

// Add generated version object
sourceSets["main"].java.srcDir("$buildDir/generated-src/version")

val compileTestIntegrationKotlin: KotlinCompile by tasks
compileTestIntegrationKotlin.kotlinOptions.jvmTarget = appJvmTarget

Expand Down Expand Up @@ -340,6 +353,7 @@ tasks.withType<Test>().configureEach {
}

tasks.processResources {
dependsOn("generateVersionObject")
// Set the proper build values in the build.properties file
filesMatching("build.properties") {
val dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd")
Expand Down Expand Up @@ -500,18 +514,32 @@ tasks.azureFunctionsPackage {
finalizedBy("copyAzureScripts")
}

// TODO: remove after implementation of health check endpoint
tasks.register("generateVersionFile") {
doLast {
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}
val currentCommit = stdout.toString(StandardCharsets.UTF_8).trim()
File(buildDir, "$azureFunctionsDir/$azureAppName/version.json").writeText("{\"commitId\": \"$currentCommit\"}")
file("$buildDir/$azureFunctionsDir/$azureAppName/version.json").writeText("{\"commitId\": \"$commitId\"}")
}
}

tasks.register("generateVersionObject") {
val sourceDir = file("$buildDir/generated-src/version")
val sourceFile = file("$sourceDir/Version.kt")
sourceDir.mkdirs()
sourceFile.writeText(
"""
package gov.cdc.prime.router.version
/**
* Supplies information for the current build.
* This file is generated via Gradle task prior to compile time and should always contain the current commit hash.
*/
object Version {
const val commitId = "$commitId"
}
""".trimIndent()
)
}

val azureResourcesTmpDir = File(buildDir, "$azureFunctionsDir-resources/$azureAppName")
val azureResourcesFinalDir = File(buildDir, "$azureFunctionsDir/$azureAppName")
tasks.register<Copy>("gatherAzureResources") {
Expand Down Expand Up @@ -805,7 +833,7 @@ buildscript {
// will need to be removed once this issue is resolved in Maven.
classpath("net.minidev:json-smart:2.5.1")
// as per flyway v10 docs the postgres flyway module must be on the project buildpath
classpath("org.flywaydb:flyway-database-postgresql:10.17.0")
classpath("org.flywaydb:flyway-database-postgresql:10.18.0")
}
}

Expand All @@ -818,37 +846,37 @@ configurations {
}

dependencies {
jooqGenerator("org.postgresql:postgresql:42.7.3")
jooqGenerator("org.postgresql:postgresql:42.7.4")

implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
implementation("com.microsoft.azure.functions:azure-functions-java-library:3.1.0")
implementation("com.azure:azure-core:1.51.0")
implementation("com.azure:azure-core-http-netty:1.15.3")
implementation("com.azure:azure-core:1.52.0")
implementation("com.azure:azure-core-http-netty:1.15.4")
implementation("com.azure:azure-storage-blob:12.27.0") {
exclude(group = "com.azure", module = "azure-core")
}
implementation("com.azure:azure-storage-queue:12.22.0") {
exclude(group = "com.azure", module = "azure-core")
}
implementation("com.azure:azure-security-keyvault-secrets:4.8.5") {
implementation("com.azure:azure-security-keyvault-secrets:4.8.6") {
exclude(group = "com.azure", module = "azure-core")
exclude(group = "com.azure", module = "azure-core-http-netty")
}
implementation("com.azure:azure-identity:1.13.2") {
implementation("com.azure:azure-identity:1.13.3") {
exclude(group = "com.azure", module = "azure-core")
exclude(group = "com.azure", module = "azure-core-http-netty")
}
implementation("com.nimbusds:nimbus-jose-jwt:9.40")
implementation("org.apache.logging.log4j:log4j-api:2.23.1")
implementation("org.apache.logging.log4j:log4j-core:2.23.1")
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.23.1")
implementation("org.apache.logging.log4j:log4j-layout-template-json:2.23.1")
implementation("org.apache.logging.log4j:log4j-api-kotlin:1.4.0")
implementation("com.nimbusds:nimbus-jose-jwt:9.41.1")
implementation("org.apache.logging.log4j:log4j-api:2.24.0")
implementation("org.apache.logging.log4j:log4j-core:2.24.0")
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.24.0")
implementation("org.apache.logging.log4j:log4j-layout-template-json:2.24.0")
implementation("org.apache.logging.log4j:log4j-api-kotlin:1.5.0")
implementation("io.github.oshai:kotlin-logging-jvm:7.0.0")
implementation("com.github.doyaaaaaken:kotlin-csv-jvm:1.9.3")
implementation("com.github.doyaaaaaken:kotlin-csv-jvm:1.10.0")
implementation("tech.tablesaw:tablesaw-core:0.43.1")
implementation("com.github.ajalt.clikt:clikt-jvm:4.4.0")

Expand All @@ -857,7 +885,7 @@ dependencies {
implementation("com.github.javafaker:javafaker:1.0.2") {
exclude(group = "org.yaml", module = "snakeyaml")
}
implementation("org.yaml:snakeyaml:2.2")
implementation("org.yaml:snakeyaml:2.3")
implementation("io.github.linuxforhealth:hl7v2-fhir-converter") {
version {
branch = "master"
Expand All @@ -873,7 +901,7 @@ dependencies {
implementation("ca.uhn.hapi:hapi-base:2.5.1")
implementation("ca.uhn.hapi:hapi-structures-v251:2.5.1")
implementation("ca.uhn.hapi:hapi-structures-v27:2.5.1")
implementation("com.googlecode.libphonenumber:libphonenumber:8.13.42")
implementation("com.googlecode.libphonenumber:libphonenumber:8.13.46")
implementation("org.thymeleaf:thymeleaf:3.1.2.RELEASE")
implementation("com.sendgrid:sendgrid-java:4.10.2")
implementation("com.okta.jwt:okta-jwt-verifier:0.5.7")
Expand All @@ -887,12 +915,12 @@ dependencies {
implementation("org.apache.commons:commons-text:1.12.0")
implementation("commons-codec:commons-codec:1.17.1")
implementation("commons-io:commons-io:2.16.1")
implementation("org.postgresql:postgresql:42.7.3")
implementation("org.postgresql:postgresql:42.7.4")
implementation("com.zaxxer:HikariCP:5.1.0")
implementation("org.flywaydb:flyway-core:10.17.0")
implementation("org.flywaydb:flyway-database-postgresql:10.17.0")
implementation("org.flywaydb:flyway-core:10.18.0")
implementation("org.flywaydb:flyway-database-postgresql:10.18.0")
implementation("org.commonmark:commonmark:0.22.0")
implementation("com.google.guava:guava:33.2.1-jre")
implementation("com.google.guava:guava:33.3.0-jre")
implementation("com.helger.as2:as2-lib:5.1.2")
implementation("org.bouncycastle:bcprov-jdk15to18:1.78.1")
implementation("org.bouncycastle:bcprov-jdk18on:1.78.1")
Expand All @@ -915,14 +943,14 @@ dependencies {
implementation("it.skrape:skrapeit-http-fetcher:1.3.0-alpha.2")
implementation("org.apache.poi:poi:5.3.0")
implementation("org.apache.poi:poi-ooxml:5.3.0")
implementation("org.apache.commons:commons-compress:1.26.2")
implementation("org.apache.commons:commons-compress:1.27.1")
implementation("commons-io:commons-io:2.16.1")
implementation("com.anyascii:anyascii:0.3.2")
// force jsoup since [email protected]+ has not updated
implementation("org.jsoup:jsoup:1.18.1")
// https://mvnrepository.com/artifact/io.swagger/swagger-annotations
implementation("io.swagger:swagger-annotations:1.6.14")
implementation("io.swagger.core.v3:swagger-jaxrs2:2.2.22")
implementation("io.swagger.core.v3:swagger-jaxrs2:2.2.23")
// https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api
implementation("javax.ws.rs:javax.ws.rs-api:2.1.1")
// https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
Expand All @@ -948,7 +976,7 @@ dependencies {
implementation("io.konform:konform-jvm:0.4.0")

runtimeOnly("com.okta.jwt:okta-jwt-verifier-impl:0.5.7")
runtimeOnly("com.squareup.okio:okio:3.9.0")
runtimeOnly("com.squareup.okio:okio:3.9.1")
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.5")
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.5")

Expand Down
2 changes: 1 addition & 1 deletion prime-router/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This setting makes flyway fall back to session locks as concurrent index creation cannot be done
# within a transaction. This setting is needed as of flyway 9.19.4.
flyway.postgresql.transactional.lock=false
flyway.postgresql.transactional.lock=false
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ data class ReportEventData(
val blobUrl: String,
val pipelineStepName: TaskAction,
val timestamp: OffsetDateTime,
val commitId: String,
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import gov.cdc.prime.router.azure.DatabaseAccess
import gov.cdc.prime.router.azure.db.enums.TaskAction
import gov.cdc.prime.router.azure.db.tables.pojos.ReportFile
import gov.cdc.prime.router.report.ReportService
import gov.cdc.prime.router.version.Version
import java.time.OffsetDateTime
import java.util.UUID

Expand Down Expand Up @@ -412,7 +413,8 @@ class ReportStreamEventService(
topic,
childBodyUrl,
pipelineStepName,
OffsetDateTime.now()
OffsetDateTime.now(),
Version.commitId
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ elements:
condition: '%resource.code.exists()'
value: [ '%resource.system.getCodingSystemMapping()' ]
hl7Spec: [ '/PATIENT_RESULT/PATIENT/PID-10-3' ]

- name: mt-patient-county-codes
condition: 'Bundle.entry.resource.ofType(Patient).address.district.empty().not() and Bundle.entry.resource.ofType(Patient).address.state.empty().not()'
hl7Spec: [ '/PATIENT_RESULT/PATIENT/PID-11-9' ]
value: [ "FIPSCountyLookup(Bundle.entry.resource.ofType(Patient).address.district,Bundle.entry.resource.ofType(Patient).address.state)[0]" ]
Loading

0 comments on commit e6909dc

Please sign in to comment.