Skip to content

Commit

Permalink
Merge branch 'master' into josiahsiegel/update/ignore-caught-exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahSiegel authored Aug 30, 2024
2 parents 3ba67c5 + eee3ae9 commit 5b37652
Show file tree
Hide file tree
Showing 54 changed files with 3,054 additions and 473 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-backend/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ runs:
distribution: "temurin"
cache: "gradle"

- uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582
- uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707

- name: Lint
if: inputs.run-integration-tests == 'true'
Expand Down
70 changes: 70 additions & 0 deletions .github/actions/build-submissions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# action.yml
name: "Build Submissions"
description: "Build submissions 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@6a0805fcefea3d4657a47ac4c165951e33482018
with:
java-version: "17"
distribution: "temurin"
cache: "gradle"

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

- name: Lint
if: inputs.run-integration-tests == 'true'
run: ./gradlew :submissions: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 Submissions Package
uses: ./.github/actions/retry
with:
timeout_minutes: 10
max_attempts: 2
retry_wait_seconds: 30
command: |
./gradlew :submissions: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
10 changes: 5 additions & 5 deletions .github/actions/sonarcloud/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ runs:
SONAR_TOKEN: ${{ inputs.sonar-token }}
with:
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.*
-Dsonar.cpd.exclusions=frontend-react/**/*.test.*,prime-router/src/test/**,prime-router/src/testIntegration/**,prime-router/src/main/kotlin/cli/tests/**
-Dsonar.sources=frontend-react/src,prime-router/src
-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.projectKey=CDCgov_prime-data-hub
-Dsonar.organization=cdcgov
-Dsonar.java.binaries=prime-router/build/classes/java/main,prime-router/build/classes/kotlin/main
-Dsonar.java.libraries=prime-router/build/libs/*.jar,prime-router/build/**/*.jar
-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.coverage.jacoco.xmlReportPaths=prime-router/build/reports/jacoco/test/jacocoTestReport.xml
-Dsonar.javascript.lcov.reportPaths=frontend-react/coverage/lcov.info
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
java-version: "17"
distribution: "temurin"
cache: "gradle"
- uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582
- uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707
- name: Snyk Monitor
working-directory: ${{ matrix.folder }}
run: snyk monitor --org=prime-reportstream
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:

- name: Gradle setup
if: steps.changed-files-yaml.outputs.backend_any_changed == 'true' || steps.branch-name.outputs.is_default == 'true'
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582
uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707

- name: Spin up build containers
if: steps.changed-files-yaml.outputs.backend_any_changed == 'true' || steps.branch-name.outputs.is_default == 'true'
Expand All @@ -93,6 +93,10 @@ jobs:
command: ./gradlew -Dorg.gradle.jvmargs="-Xmx6g" :prime-router:package -x fatjar
shell: bash

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

- 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
2 changes: 1 addition & 1 deletion .github/workflows/validate_terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Run Checkov action
uses: bridgecrewio/checkov-action@4fa90328619ebe2a5396c7f16308c17a7a4b5dc3
uses: bridgecrewio/checkov-action@1b813e8f72afe2b6263a6ea10c873707e21ebe44
with:
directory: operations/app/terraform
skip_check: CKV_AZURE_139,CKV_AZURE_137,CKV_AZURE_103,CKV_AZURE_104,CKV_AZURE_102,CKV_AZURE_130,CKV_AZURE_121,CKV_AZURE_67,CKV_AZURE_56,CKV_AZURE_17,CKV_AZURE_63,CKV_AZURE_18,CKV_AZURE_88,CKV_AZURE_65,CKV_AZURE_13,CKV_AZURE_66,CKV_AZURE_33,CKV_AZURE_35,CKV_AZURE_36,CKV_AZURE_98,CKV2_AZURE_1,CKV2_AZURE_15,CKV2_AZURE_21,CKV_AZURE_213,CKV_AZURE_59,CKV2_AZURE_33,CKV2_AZURE_32,CKV2_AZURE_28,CKV_AZURE_206,CKV_AZURE_42,CKV_AZURE_110,CKV_AZURE_109,CKV_AZURE_166,CKV2_AZURE_38,CKV2_AZURE_40,CKV2_AZURE_41,CKV_AZURE_235
23 changes: 23 additions & 0 deletions frontend-react/e2e/helpers/internal-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,26 @@ export const gettingStartedSideNav = [
path: "/getting-started/receiving-data",
},
];

export const developerResourcesApiSideNav = [
{
name: "ReportStream API",
path: "/developer-resources/api",
},
{
name: "Getting started",
path: "/developer-resources/api/getting-started",
},
{
name: "Documentation",
path: "/developer-resources/api/documentation",
},
{
name: "Responses from ReportStream",
path: "/developer-resources/api/documentation/responses-from-reportstream",
},
{
name: "Sample payloads and output",
path: "/developer-resources/api/documentation/sample-payloads-and-output",
},
];
8 changes: 4 additions & 4 deletions frontend-react/e2e/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export async function tableColumnDateTimeInRange(
columnNumber: number,
fromDate: string,
toDate: string,
startTime: string,
endTime: string,
startTime?: string,
endTime?: string,
) {
let datesInRange = true;
const rowCount = await tableRows(page).count();
Expand All @@ -106,7 +106,7 @@ export async function tableColumnDateTimeInRange(
return datesInRange;
}

export function fromDateWithTime(date: string, time: string) {
export function fromDateWithTime(date: string, time?: string) {
const fromDateTime = new Date(date);

if (time) {
Expand All @@ -123,7 +123,7 @@ export function fromDateWithTime(date: string, time: string) {
return fromDateTime;
}

export function toDateWithTime(date: string, time: string) {
export function toDateWithTime(date: string, time?: string) {
const toDateTime = new Date(date);

if (time) {
Expand Down
93 changes: 72 additions & 21 deletions frontend-react/e2e/pages/authenticated/submission-history.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,86 @@
import { expect, Page } from "@playwright/test";
import { TEST_ORG_IGNORE } from "../../helpers/utils";
import { MOCK_GET_SUBMISSION_HISTORY } from "../../mocks/submissionHistory";
import { MOCK_GET_SUBMISSIONS } from "../../mocks/submissions";
import { BasePage, BasePageTestArgs, type RouteHandlerFulfillEntry } from "../BasePage";

export const URL_SUBMISSION_HISTORY = "/submissions";
export const API_GET_REPORT_HISTORY = `**/api/waters/report/**`;
export const id = "73e3cbc8-9920-4ab7-871f-843a1db4c074";

export async function goto(page: Page) {
await page.goto(URL_SUBMISSION_HISTORY, {
waitUntil: "domcontentloaded",
});
}
export class SubmissionHistoryPage extends BasePage {
static readonly URL_SUBMISSION_HISTORY = "/submissions";

export async function gotoDetails(page: Page, id: string) {
await page.goto(`${URL_SUBMISSION_HISTORY}/${id}`, {
waitUntil: "domcontentloaded",
});
}
constructor(testArgs: BasePageTestArgs) {
super(
{
url: SubmissionHistoryPage.URL_SUBMISSION_HISTORY,
title: "ReportStream - CDC's free, interoperable data transfer platform",
heading: testArgs.page.getByRole("heading", {
name: "Submission history",
}),
},
testArgs,
);

this.addMockRouteHandlers([
// Ignore Org
this.createMockSubmissionsForOrgHandler(TEST_ORG_IGNORE, MOCK_GET_SUBMISSIONS),
this.createMockSubmissionHistoryHandler(),
]);
}

createMockSubmissionsForOrgHandler(
organization: string,
mockFileName: any,
responseStatus = 200,
): RouteHandlerFulfillEntry {
return [
`**/api/waters/org/${organization}/submissions?*`,
() => {
return {
json: mockFileName,
status: responseStatus,
};
},
];
}

export function getOrgSubmissionsAPI(org: string) {
return `**/api/waters/org/${org}/submissions?*`;
createMockSubmissionHistoryHandler(responseStatus = 200): RouteHandlerFulfillEntry {
return [
API_GET_REPORT_HISTORY,
() => {
return {
json: MOCK_GET_SUBMISSION_HISTORY,
status: responseStatus,
};
},
];
}

get filterButton() {
return this.page.getByRole("button", {
name: "Filter",
});
}

get clearButton() {
return this.page.getByRole("button", {
name: "Clear",
});
}

/**
* Error expected additionally if user context isn't admin
*/
get isPageLoadExpected() {
return super.isPageLoadExpected && this.testArgs.storageState === this.testArgs.adminLogin.path;
}
}

export async function mockGetSubmissionsResponse(page: Page, org: string, responseStatus = 200) {
const submissionsApi = getOrgSubmissionsAPI(org);
await page.route(submissionsApi, async (route) => {
const json = MOCK_GET_SUBMISSIONS;
await route.fulfill({ json, status: responseStatus });
export async function goto(page: Page) {
await page.goto(URL_SUBMISSION_HISTORY, {
waitUntil: "domcontentloaded",
});
}

Expand All @@ -41,10 +96,6 @@ export async function openReportIdDetailPage(page: Page, id: string) {
await expect(page.getByText(`Details: ${id}`)).toBeVisible();
}

export async function title(page: Page) {
await expect(page).toHaveTitle(/ReportStream - CDC's free, interoperable data transfer platform/);
}

export async function tableHeaders(page: Page) {
await expect(page.locator(".usa-table th").nth(0)).toHaveText(/Report ID/);
await expect(page.locator(".usa-table th").nth(1)).toHaveText("Date/time submitted");
Expand Down
40 changes: 40 additions & 0 deletions frontend-react/e2e/pages/authenticated/submissions-details.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { API_WATERS_REPORT } from "./report-details";
import { URL_SUBMISSION_HISTORY } from "./submission-history";
import { MOCK_GET_SUBMISSION_HISTORY } from "../../mocks/submissionHistory";
import { BasePage, BasePageTestArgs, type RouteHandlerFulfillEntry } from "../BasePage";

export const id = "73e3cbc8-9920-4ab7-871f-843a1db4c074";
export class SubmissionsDetailsPage extends BasePage {
static readonly URL_SUBMISSIONS_DETAILS = `${URL_SUBMISSION_HISTORY}/${id}`;

constructor(testArgs: BasePageTestArgs) {
super(
{
url: SubmissionsDetailsPage.URL_SUBMISSIONS_DETAILS,
title: "ReportStream - CDC's free, interoperable data transfer platform",
},
testArgs,
);

this.addMockRouteHandlers([this.createMockSubmissionHistoryHandler(MOCK_GET_SUBMISSION_HISTORY)]);
}

createMockSubmissionHistoryHandler(mockFileName: any, responseStatus = 200): RouteHandlerFulfillEntry {
return [
`${API_WATERS_REPORT}/${id}/history`,
() => {
return {
json: mockFileName,
status: responseStatus,
};
},
];
}

/**
* Error expected additionally if user context isn't admin
*/
get isPageLoadExpected() {
return super.isPageLoadExpected && this.testArgs.storageState === this.testArgs.adminLogin.path;
}
}
17 changes: 17 additions & 0 deletions frontend-react/e2e/pages/public/about/case-studies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BasePage, BasePageTestArgs } from "../../BasePage";

export class AboutCaseStudiesPage extends BasePage {
constructor(testArgs: BasePageTestArgs) {
super(
{
url: "/about/case-studies",
title: "ReportStream case studies",
heading: testArgs.page.getByRole("heading", {
name: "Case studies",
exact: true,
}),
},
testArgs,
);
}
}
17 changes: 17 additions & 0 deletions frontend-react/e2e/pages/public/about/release-notes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BasePage, BasePageTestArgs } from "../../BasePage";

export class AboutReleaseNotesPage extends BasePage {
constructor(testArgs: BasePageTestArgs) {
super(
{
url: "/about/release-notes",
title: "ReportStream release notes",
heading: testArgs.page.getByRole("heading", {
name: "Release notes",
exact: true,
}),
},
testArgs,
);
}
}
Loading

0 comments on commit 5b37652

Please sign in to comment.