From 4a0ebde2510df3603fb7b62b4f3cf82f24918287 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Fri, 29 Nov 2024 18:09:01 +0000 Subject: [PATCH 1/9] B-21373:Added required for doc upload/scrolltoview error and disabling SubmitMoveOrder/ApproveSelected buttons --- .../DocumentViewer/DocumentViewer.stories.jsx | 13 ++++- .../DocumentViewerFileManager.jsx | 16 +++++- .../DocumentViewerFileManager.test.jsx | 28 ++++++++++ src/components/FileUpload/FileUpload.jsx | 4 ++ .../RequestedShipments.test.jsx | 19 +++++++ .../SubmittedRequestedShipments.jsx | 6 +- .../SubmittedRequestedShipments.stories.jsx | 9 ++- src/pages/Office/Orders/Orders.jsx | 6 +- .../ServicesCounselingMoveDetails.jsx | 18 +++--- .../ServicesCounselingMoveDetails.test.jsx | 56 +------------------ .../ServicesCounselingOrders.jsx | 6 +- src/utils/validation.js | 12 ++++ src/utils/validation.test.js | 37 ++++++++++++ 13 files changed, 152 insertions(+), 78 deletions(-) create mode 100644 src/utils/validation.test.js diff --git a/src/components/DocumentViewer/DocumentViewer.stories.jsx b/src/components/DocumentViewer/DocumentViewer.stories.jsx index 9bc363b2af6..b04c00ad9fe 100644 --- a/src/components/DocumentViewer/DocumentViewer.stories.jsx +++ b/src/components/DocumentViewer/DocumentViewer.stories.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; import DocumentViewer from './DocumentViewer'; import pdf from './sample.pdf'; @@ -57,18 +58,24 @@ const testImageFiles = [ export const PDFViewer = () => (
- + + +
); export const ImageViewer = () => (
- + + +
); export const DisplayDownloadOption = () => (
- + + +
); diff --git a/src/components/DocumentViewerFileManager/DocumentViewerFileManager.jsx b/src/components/DocumentViewerFileManager/DocumentViewerFileManager.jsx index 8cb2557dc77..3069117a1f8 100644 --- a/src/components/DocumentViewerFileManager/DocumentViewerFileManager.jsx +++ b/src/components/DocumentViewerFileManager/DocumentViewerFileManager.jsx @@ -28,6 +28,7 @@ const DocumentViewerFileManager = ({ files, documentType, updateAmendedDocument, + required, }) => { const queryClient = useQueryClient(); const filePondEl = useRef(); @@ -69,7 +70,10 @@ const DocumentViewerFileManager = ({ setShowUpload(true); setIsExpandedView(true); } - }, [documentType]); + if (required) { + setShowUpload(true); + } + }, [documentType, required]); const closeDeleteFileModal = () => { setCurrentFile(null); @@ -217,7 +221,7 @@ const DocumentViewerFileManager = ({ /> )} {!isExpandedView && ( - )} @@ -232,7 +236,13 @@ const DocumentViewerFileManager = ({ )}
+ {required && ( + + File upload is required + + )} PDF, JPG, or PNG only. Maximum file size 25MB. Each page must be clear and legible {!isExpandedView && ( - )} diff --git a/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx b/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx index ac76abe8c65..8d09b38935a 100644 --- a/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx +++ b/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx @@ -96,6 +96,14 @@ describe('DocumentViewerFileManager', () => { updateAmendedDocument: jest.fn(), }; + const ordersPropsNoFile = { + move: { id: 'move-id', locator: 'move-locator' }, + orderId: 'order-id', + required: true, + documentId: '', + files: [{}], + documentType: 'ORDERS', + }; it('renders without crashing', () => { renderWithQueryClient(); expect(screen.getByText('Manage Orders')).toBeInTheDocument(); @@ -287,4 +295,24 @@ describe('DocumentViewerFileManager', () => { expect(await screen.findByText(/failed to upload due to server error: upload failed/i)).toBeInTheDocument(); }); + + it('should disable the Manage Orders button', () => { + renderWithQueryClient(); + const manageDocumentsButton = screen.getByRole('button', { name: /manage orders/i }); + expect(manageDocumentsButton).toBeInTheDocument(); + expect(manageDocumentsButton).toBeDisabled(); + }); + it('should display File upload is required alert', () => { + renderWithQueryClient(); + + expect(screen.getByTestId('fileRequiredAlert')).toBeInTheDocument(); + expect(screen.getByTestId('fileRequiredAlert')).toHaveTextContent('File upload is required'); + }); + it('should disable the Manage Orders Done button', () => { + renderWithQueryClient(); + + const manageDocumentsDoneButton = screen.getByRole('button', { name: /done/i }); + expect(manageDocumentsDoneButton).toBeInTheDocument(); + expect(manageDocumentsDoneButton).toBeDisabled(); + }); }); diff --git a/src/components/FileUpload/FileUpload.jsx b/src/components/FileUpload/FileUpload.jsx index bb5f6d7de9a..5c51db5fcb3 100644 --- a/src/components/FileUpload/FileUpload.jsx +++ b/src/components/FileUpload/FileUpload.jsx @@ -35,6 +35,7 @@ const FileUpload = forwardRef( maxParralelUploads, fileValidateTypeLabelExpectedTypes, labelFileTypeNotAllowed, + required, }, ref, ) => { @@ -90,6 +91,7 @@ const FileUpload = forwardRef( /* eslint-disable react/jsx-props-no-spreading */ return ( { expect(screen.getByRole('button', { name: 'Approve selected' })).toBeDisabled(); }); + it('disables the Approve selected button when there is missing required information', async () => { + const { container } = render(submittedRequestedShipmentsComponentMissingRequiredInfo); + await act(async () => { + await userEvent.type( + container.querySelector('input[name="shipments"]'), + 'ce01a5b8-9b44-4511-8a8d-edb60f2a4aee', + ); + }); + + expect(await screen.getByRole('combobox', { name: 'Add a new shipment' })).toBeInTheDocument(); + + expect(screen.getByRole('button', { name: 'Approve selected' })).toBeDisabled(); + + await act(async () => { + await userEvent.click(screen.getByRole('checkbox', { name: 'Move management' })); + }); + + expect(screen.getByRole('button', { name: 'Approve selected' })).toBeDisabled(); + }); it('calls approveMTO onSubmit', async () => { const mockOnSubmit = jest.fn((id, eTag) => { return new Promise((resolve) => { diff --git a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx index 95a98e21427..0fd9d2054d4 100644 --- a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx +++ b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx @@ -85,6 +85,7 @@ const SubmittedRequestedShipments = ({ const { moveCode } = useParams(); const navigate = useNavigate(); + const hasOrderDocuments = ordersInfo.ordersDocuments?.length > 0; const handleButtonDropdownChange = (e) => { const selectedOption = e.target.value; @@ -196,10 +197,11 @@ const SubmittedRequestedShipments = ({ // if showing service items on a move with Prime shipments, enable button when shipment and service item are selected and there is no missing required Orders information // if not showing service items on a move with Prime shipments, enable button if a shipment is selected and there is no missing required Orders information const primeShipmentsForApproval = moveTaskOrder.availableToPrimeAt - ? formik.values.shipments.length > 0 && !missingRequiredOrdersInfo + ? formik.values.shipments.length > 0 && !missingRequiredOrdersInfo && hasOrderDocuments : formik.values.shipments.length > 0 && (formik.values.counselingFee || formik.values.shipmentManagementFee) && - !missingRequiredOrdersInfo; + !missingRequiredOrdersInfo && + hasOrderDocuments; // on a move with only External Vendor shipments enable button if a service item is selected const externalVendorShipmentsOnly = formik.values.counselingFee || formik.values.shipmentManagementFee; diff --git a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.stories.jsx b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.stories.jsx index 4948fa899de..8fa3bda08ee 100644 --- a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.stories.jsx +++ b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.stories.jsx @@ -1,5 +1,6 @@ import React from 'react'; import { Provider } from 'react-redux'; +import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; import { shipments, @@ -25,7 +26,9 @@ export default { return ( - + + + ); @@ -35,7 +38,9 @@ export default { return ( - + + + ); diff --git a/src/pages/Office/Orders/Orders.jsx b/src/pages/Office/Orders/Orders.jsx index 035f63b3a0b..0f91975dcb6 100644 --- a/src/pages/Office/Orders/Orders.jsx +++ b/src/pages/Office/Orders/Orders.jsx @@ -26,6 +26,7 @@ import { LOA_TYPE, MOVE_DOCUMENT_TYPE } from 'shared/constants'; import Restricted from 'components/Restricted/Restricted'; import { permissionTypes } from 'constants/permissions'; import DocumentViewerFileManager from 'components/DocumentViewerFileManager/DocumentViewerFileManager'; +import { scrollToViewFormikError } from 'utils/validation'; const deptIndicatorDropdownOptions = dropdownInputOptions(DEPARTMENT_INDICATOR_OPTIONS); const ordersTypeDropdownOptions = dropdownInputOptions(ORDERS_TYPE_OPTIONS); @@ -47,7 +48,7 @@ const Orders = ({ files, amendedDocumentId, updateAmendedDocument }) => { const ordersDocuments = files[MOVE_DOCUMENT_TYPE.ORDERS]; const amendedDocuments = files[MOVE_DOCUMENT_TYPE.AMENDMENTS]; - + const hasOrdersDocuments = ordersDocuments?.length > 0; const handleClose = useCallback(() => { let redirectPath; if (from === 'paymentRequestDetails') { @@ -369,6 +370,7 @@ const Orders = ({ files, amendedDocumentId, updateAmendedDocument }) => {
{
-
- )} @@ -236,13 +236,13 @@ const DocumentViewerFileManager = ({ )}
- {required && ( + {fileUploadrequired && ( File upload is required )} PDF, JPG, or PNG only. Maximum file size 25MB. Each page must be clear and legible {!isExpandedView && ( - )} diff --git a/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx b/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx index 8d09b38935a..1453c1d645b 100644 --- a/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx +++ b/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx @@ -99,7 +99,7 @@ describe('DocumentViewerFileManager', () => { const ordersPropsNoFile = { move: { id: 'move-id', locator: 'move-locator' }, orderId: 'order-id', - required: true, + fileUploadrequired: true, documentId: '', files: [{}], documentType: 'ORDERS', diff --git a/src/pages/Office/Orders/Orders.jsx b/src/pages/Office/Orders/Orders.jsx index 0f91975dcb6..605cb422683 100644 --- a/src/pages/Office/Orders/Orders.jsx +++ b/src/pages/Office/Orders/Orders.jsx @@ -370,7 +370,7 @@ const Orders = ({ files, amendedDocumentId, updateAmendedDocument }) => {
Date: Tue, 3 Dec 2024 17:06:46 +0000 Subject: [PATCH 5/9] fixed prop name --- .../DocumentViewerFileManager.jsx | 14 +++++++------- .../DocumentViewerFileManager.test.jsx | 2 +- src/pages/Office/Orders/Orders.jsx | 2 +- .../ServicesCounselingOrders.jsx | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/DocumentViewerFileManager/DocumentViewerFileManager.jsx b/src/components/DocumentViewerFileManager/DocumentViewerFileManager.jsx index 8eda60b5665..7e765b93882 100644 --- a/src/components/DocumentViewerFileManager/DocumentViewerFileManager.jsx +++ b/src/components/DocumentViewerFileManager/DocumentViewerFileManager.jsx @@ -28,7 +28,7 @@ const DocumentViewerFileManager = ({ files, documentType, updateAmendedDocument, - fileUploadrequired, + fileUploadRequired, }) => { const queryClient = useQueryClient(); const filePondEl = useRef(); @@ -70,10 +70,10 @@ const DocumentViewerFileManager = ({ setShowUpload(true); setIsExpandedView(true); } - if (fileUploadrequired) { + if (fileUploadRequired) { setShowUpload(true); } - }, [documentType, fileUploadrequired]); + }, [documentType, fileUploadRequired]); const closeDeleteFileModal = () => { setCurrentFile(null); @@ -221,7 +221,7 @@ const DocumentViewerFileManager = ({ /> )} {!isExpandedView && ( - )} @@ -236,13 +236,13 @@ const DocumentViewerFileManager = ({ )}
- {fileUploadrequired && ( + {fileUploadRequired && ( File upload is required )} PDF, JPG, or PNG only. Maximum file size 25MB. Each page must be clear and legible {!isExpandedView && ( - )} diff --git a/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx b/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx index 1453c1d645b..83ea734dfc5 100644 --- a/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx +++ b/src/components/DocumentViewerFileManager/DocumentViewerFileManager.test.jsx @@ -99,7 +99,7 @@ describe('DocumentViewerFileManager', () => { const ordersPropsNoFile = { move: { id: 'move-id', locator: 'move-locator' }, orderId: 'order-id', - fileUploadrequired: true, + fileUploadRequired: true, documentId: '', files: [{}], documentType: 'ORDERS', diff --git a/src/pages/Office/Orders/Orders.jsx b/src/pages/Office/Orders/Orders.jsx index 605cb422683..1bf21c4fc50 100644 --- a/src/pages/Office/Orders/Orders.jsx +++ b/src/pages/Office/Orders/Orders.jsx @@ -370,7 +370,7 @@ const Orders = ({ files, amendedDocumentId, updateAmendedDocument }) => {
Date: Thu, 19 Dec 2024 14:44:03 +0000 Subject: [PATCH 6/9] ci/cd work --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6abab421058..817f5fd3576 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,16 +32,16 @@ variables: GOLANGCI_LINT_VERBOSE: "-v" # Specify the environment: loadtest, demo, exp - DP3_ENV: &dp3_env demo + DP3_ENV: &dp3_env placeholder_env # Specify the branch to deploy - DP3_BRANCH: &dp3_branch B-18585-gitlab-deploy + DP3_BRANCH: &dp3_branch placeholder_branch_name # Ignore branches for integration tests - INTEGRATION_IGNORE_BRANCH: &integration_ignore_branch B-18585-gitlab-deploy - INTEGRATION_MTLS_IGNORE_BRANCH: &integration_mtls_ignore_branch B-18585-gitlab-deploy - CLIENT_IGNORE_BRANCH: &client_ignore_branch B-18585-gitlab-deploy - SERVER_IGNORE_BRANCH: &server_ignore_branch B-18585-gitlab-deploy + INTEGRATION_IGNORE_BRANCH: &integration_ignore_branch placeholder_branch_name + INTEGRATION_MTLS_IGNORE_BRANCH: &integration_mtls_ignore_branch placeholder_branch_name + CLIENT_IGNORE_BRANCH: &client_ignore_branch placeholder_branch_name + SERVER_IGNORE_BRANCH: &server_ignore_branch placeholder_branch_name stages: - pre_checks From ae0ba3e1beb33238ed0555f9e920afe2e242b4a9 Mon Sep 17 00:00:00 2001 From: josiahzimmerman-caci Date: Fri, 20 Dec 2024 19:31:04 +0000 Subject: [PATCH 7/9] ci/cd work --- .gitlab-ci.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 817f5fd3576..5ddc9807652 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,10 +14,6 @@ variables: DOCKERHUB_PASSWORD: DOCKERHUB_PASSWORD DOCKER_TOKEN: DOCKER_TOKEN registry: https://registry.hub.docker.com/ - #EKS Default current max - KUBERNETES_CPU_REQUEST: "2" - KUBERNETES_MEMORY_REQUEST: "8Gi" - KUBERNETES_MEMORY_LIMIT: "8Gi" #Circle CI need to replace #CIRCLE_PROJECT_USERNAME: "my-username" # Replace with the actual namespace @@ -130,6 +126,10 @@ pre_deps_yarn: compile_app_client: stage: build image: $DOCKER_APP_IMAGE + variables: + KUBERNETES_CPU_REQUEST: "2" + KUBERNETES_MEMORY_REQUEST: "8Gi" + KUBERNETES_MEMORY_LIMIT: "8Gi" before_script: *setup_milmove_env needs: - pre_deps_yarn @@ -151,6 +151,10 @@ compile_app_client: compile_app_server: stage: build image: $DOCKER_APP_IMAGE + variables: + KUBERNETES_CPU_REQUEST: "2" + KUBERNETES_MEMORY_REQUEST: "4Gi" + KUBERNETES_MEMORY_LIMIT: "4Gi" needs: - pre_deps_golang - pre_deps_yarn From 713d36dc6ebf6257b81a53bebef5dea4fff875bc Mon Sep 17 00:00:00 2001 From: josiahzimmerman-caci Date: Mon, 23 Dec 2024 16:42:08 +0000 Subject: [PATCH 8/9] ci/cd work --- .gitlab-ci.yml | 336 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 312 insertions(+), 24 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ddc9807652..cf23c744800 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,6 +53,71 @@ stages: - export PATH=${PATH}:${GOPATH}/bin:~/transcom/mymove/builds/milmove/mymove - export REACT_APP_ERROR_LOGGING=otel +.announce_failure: &announce_failure + - if [[ "$CI_COMMIT_BRANCH" == "main" && "$CI_JOB_STATUS" == "failed" ]]; then + echo "Announcing broken branch in GitLab CI" + fi + +.setup_aws_vars_dp3: &setup_aws_vars_dp3 + - export AWS_DEFAULT_REGION=$(eval echo \$${DP3_ENV^^}_REGION) + - export AWS_ACCOUNT_ID=$(eval echo \$${DP3_ENV^^}_ACCOUNT_ID) + - export AWS_ACCESS_KEY_ID=$(eval echo \$${DP3_ENV^^}_ACCESS_KEY_ID) + - export AWS_SECRET_ACCESS_KEY=$(eval echo \$${DP3_ENV^^}_SECRET_ACCESS_KEY) + +.setup_tls_vars_dp3: &setup_tls_vars_dp3 + - export TLS_CERT=$(eval echo \$${DP3_ENV^^}_DP3_CERT) + - export TLS_KEY=$(eval echo \$${DP3_ENV^^}_DP3_KEY) + - export TLS_CA=$(eval echo \$${DP3_ENV^^}_DP3_CA) + +.setup_aws_vars_stg: &setup_aws_vars_stg + - export AWS_DEFAULT_REGION=$STG_REGION + - export AWS_ACCOUNT_ID=$STG_ACCOUNT_ID + - export AWS_ACCESS_KEY_ID=$STG_ACCESS_KEY_ID + - export AWS_SECRET_ACCESS_KEY=$STG_SECRET_ACCESS_KEY + - export SERVICE_RESERVATION_CPU=2048 + - export SERVICE_RESERVATION_MEM=4096 + +.setup_tls_vars_stg: &setup_tls_vars_stg + - export TLS_CERT=$STG_MOVE_MIL_DOD_TLS_CERT + - export TLS_KEY=$STG_MOVE_MIL_DOD_TLS_KEY + - export TLS_CA=$STG_MOVE_MIL_DOD_TLS_CA + +.setup_aws_vars_prd: &setup_aws_vars_prd + - export AWS_REGION=$PRD_REGION + - export AWS_ACCOUNT_ID=$PRD_ACCOUNT_ID + - export AWS_ACCESS_KEY_ID=$PRD_ACCESS_KEY_ID + - export AWS_SECRET_ACCESS_KEY=$PRD_SECRET_ACCESS_KEY + +.setup_tls_vars_prd: &setup_tls_vars_prd + - export TLS_CERT=$PRD_MOVE_MIL_DOD_TLS_CERT + - export TLS_KEY=$PRD_MOVE_MIL_DOD_TLS_KEY + - export TLS_CA=$PRD_MOVE_MIL_DOD_TLS_CA + +.setup_release_dp3: &setup_release_dp3 + #if demo/loadtest/exp + - export ECR_REPOSITORY_URI = $(eval echo \$${DP3_ENV^^}_ACCOUNT_ID).dkr.ecr.$(eval echo \$${DP3_ENV^^}_DEFAULT_REGION).amazonaws.com + - export APP_DOCKER_FILE = Dockerfile.dp3 + - export TASK_DOCKER_FILE = Dockerfile.tasks_dp3 + +.setup_release_stg: &setup_release_stg + #if main + - export ECR_REPOSITORY_URI = ${STG_ACCOUNT_ID}.dkr.ecr.${STG_DEFAULT_REGION}.amazonaws.com + - export APP_DOCKER_FILE = Dockerfile.dp3 + - export TASK_DOCKER_FILE = Dockerfile.tasks_dp3 + +.setup_release_prd: &setup_release_prd + #build off prd variables + - export ECR_REPOSITORY_URI = ${PRD_ACCOUNT_ID}.dkr.ecr.${PRD_DEFAULT_REGION}.amazonaws.com + - export APP_DOCKER_FILE = Dockerfile.dp3 + - export TASK_DOCKER_FILE = Dockerfile.tasks_dp3 + +.kaniko_before_setup: &kaniko_before_setup + # prep login for kaniko + mkdir -p /kaniko/.docker + echo "Simulating Docker image build setup..." + echo "{\"credHelpers\":{\"${ECR_REPOSITORY_URI}\":\"ecr-login\"}}" > /kaniko/.docker/config.json + + sast: stage: pre_checks include: @@ -89,6 +154,10 @@ pre_deps_golang: stage: pre_checks image: $DOCKER_APP_IMAGE before_script: *setup_milmove_env + variables: + KUBERNETES_CPU_REQUEST: "2" + KUBERNETES_MEMORY_REQUEST: "4Gi" + KUBERNETES_MEMORY_LIMIT: "4Gi" script: - for i in $(seq 1 5); do go mod download && break || s=$? && sleep 5; done; (exit $s) - scripts/check-generated-code go.sum @@ -123,6 +192,67 @@ pre_deps_yarn: paths: - ~/.cache/yarn +check_generated_code: + stage: pre_checks + image: $DOCKER_APP_IMAGE # Replace with the appropriate Docker image + needs: + - pre_deps_golang + before_script: + - *setup_milmove_env + script: + - make server_generate mocks_generate + - scripts/check-generated-code pkg/gen/ $(find . -type d -name "*mocks" -exec echo -n '{} ' \;) + +check_tls_certificate_dp3: + stage: pre_checks + image: $DOCKER_APP_IMAGE # Replace with your appropriate Docker image. + before_script: + - *setup_aws_vars_dp3 + - *setup_tls_vars_dp3 + - *announce_failure + script: + # Check if we are using a DP3 environment + - echo "Checking if we are using a DP3 environment at all..." + - | + if [[ $DP3_ENV != "demo" && $DP3_ENV != "exp" && $DP3_ENV != "loadtest" ]]; then + echo "Not a DP3 environment. Skipping TLS checks." + exit 0 + fi + - echo "Running TLS pair check..." + - /usr/local/bin/check-tls-pair "${TLS_KEY}" "${TLS_CERT}" + +check_tls_certificate_stg: + stage: pre_checks + image: $DOCKER_APP_IMAGE # This can reB-18585-gitlab-pipeline-work unchanged, or you can use a lightweight image since no real work is done. + before_script: + - *setup_aws_vars_stg + - *setup_tls_vars_stg + script: + - echo "Running TLS pair check..." + - /usr/local/bin/check-tls-pair "${TLS_KEY}" "${TLS_CERT}" + after_script: + - echo "Running failure notification if necessary..." + - | + if [[ "$CI_COMMIT_BRANCH" == "main" && "$CI_JOB_STATUS" == "failed" ]]; then + ./scripts/circleci-announce-broken-branch + fi + +check_tls_certificate_prd: + stage: pre_checks + image: $DOCKER_APP_IMAGE + before_script: + - *setup_tls_vars_prd + - *setup_aws_vars_prd + script: + - echo "Running TLS pair check for PRD environment..." + - /usr/local/bin/check-tls-pair "${TLS_KEY}" "${TLS_CERT}" + after_script: + - | + if [[ "$CI_COMMIT_BRANCH" == "main" && "$CI_JOB_STATUS" == "failed" ]]; then + echo "Announcing broken branch for main..." + scripts/circleci-announce-broken-branch + fi + compile_app_client: stage: build image: $DOCKER_APP_IMAGE @@ -180,6 +310,173 @@ compile_app_server: - /builds/milmove/mymove/config/otel/* expire_in: 1 week +build_push_app_stg: + stage: push + image: + name: gcr.io/kaniko-project/executor:v1.14.0-debug + entrypoint: [""] + needs: + - compile_app_client + - compile_app_server + before_script: + - *setup_release_stg + - *kaniko_before_setup + script: + - echo "Building and Pushing app Docker image..." + - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/${APP_DOCKER_FILE}" --destination "${ECR_REPOSITORY_URI}/app:$CI_COMMIT_SHORT_SHA" + after_script: + - echo "Build_complete" + rules: + - if: $CI_COMMIT_BRANCH == "main"' + +build_push_migrations_stg: + stage: push + image: + name: gcr.io/kaniko-project/executor:v1.14.0-debug + entrypoint: [""] + needs: + - compile_app_server + - compile_app_client + before_script: + - *setup_release_stg + - *kaniko_before_setup + script: + - echo "Building and Pushing migrations Docker image..." + - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/Dockerfile.migrations" --destination "${ECR_REPOSITORY_URI}/app-migrations:$CI_COMMIT_SHORT_SHA" + after_script: + - echo "Migrations image built and pushed successfully." + rules: + - if: $CI_COMMIT_BRANCH == "main"' + +build_push_tasks_stg: + stage: push + image: + name: gcr.io/kaniko-project/executor:v1.14.0-debug + entrypoint: [""] + needs: + - compile_app_server + - compile_app_client + before_script: + - *setup_release_stg + - *kaniko_before_setup + script: + - echo "Building tasks Docker image..." + - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/${TASK_DOCKER_FILE}" --destination "${ECR_REPOSITORY_URI}/app-tasks:$CI_COMMIT_SHORT_SHA" + after_script: + - echo "Tasks image built successfully." + rules: + - if: $CI_COMMIT_BRANCH == "main"' + +push_otel_collector_image_stg: + stage: push + image: + name: $DOCKER_BASE_IMAGE + entrypoint: [""] + needs: + - compile_app_server + - compile_app_client + before_script: + - *setup_release_stg + script: + - echo "Logging in to Amazon ECR with Crane..." + - aws ecr get-login-password --region us-gov-west-1 | crane auth login ${ECR_REPOSITORY_URI} -u AWS --password-stdin + + - echo "Pulling the AWS OTel Collector image from the public registry with Crane..." + - crane pull --insecure public.ecr.aws/aws-observability/aws-otel-collector:v0.31.0 image.tar + + - echo "Pushing the image to our private ECR using Crane..." + - crane push --insecure image.tar ${ECR_REPOSITORY_URI}/otel-collector:${CI_COMMIT_SHORT_SHA} + + - echo "Cleaning up the temporary image file..." + - rm image.tar + allow_failure: false + rules: + - if: '$CI_COMMIT_BRANCH == "main"' + +build_push_app_prd: + stage: push + image: + name: gcr.io/kaniko-project/executor:v1.14.0-debug + entrypoint: [""] + needs: + - compile_app_client + - compile_app_server + before_script: + - *setup_release_prd + - *kaniko_before_setup + script: + - echo "Building and Pushing app Docker image..." + - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/${APP_DOCKER_FILE}" --destination "${ECR_REPOSITORY_URI}/app:$CI_COMMIT_SHORT_SHA" + after_script: + - echo "Build_complete" + rules: + - if: $CI_COMMIT_BRANCH == "main"' + +build_push_migrations_prd: + stage: push + image: + name: gcr.io/kaniko-project/executor:v1.14.0-debug + entrypoint: [""] + needs: + - compile_app_server + - compile_app_client + before_script: + - *setup_release_prd + - *kaniko_before_setup + script: + - echo "Building and Pushing migrations Docker image..." + - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/Dockerfile.migrations" --destination "${ECR_REPOSITORY_URI}/app-migrations:$CI_COMMIT_SHORT_SHA" + after_script: + - echo "Migrations image built and pushed successfully." + rules: + - if: $CI_COMMIT_BRANCH == "main"' + +build_push_tasks_prd: + stage: push + image: + name: gcr.io/kaniko-project/executor:v1.14.0-debug + entrypoint: [""] + needs: + - compile_app_server + - compile_app_client + before_script: + - *setup_release_prd + - *kaniko_before_setup + script: + - echo "Building tasks Docker image..." + - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/${TASK_DOCKER_FILE}" --destination "${ECR_REPOSITORY_URI}/app-tasks:$CI_COMMIT_SHORT_SHA" + after_script: + - echo "Tasks image built successfully." + rules: + - if: $CI_COMMIT_BRANCH == "main"' + +push_otel_collector_image_prd: + stage: push + image: + name: $DOCKER_BASE_IMAGE + entrypoint: [""] + needs: + - compile_app_server + - compile_app_client + before_script: + - *setup_release_prd + script: + - echo "Logging in to Amazon ECR with Crane..." + - aws ecr get-login-password --region us-gov-west-1 | crane auth login ${ECR_REPOSITORY_URI} -u AWS --password-stdin + + - echo "Pulling the AWS OTel Collector image from the public registry with Crane..." + - crane pull --insecure public.ecr.aws/aws-observability/aws-otel-collector:v0.31.0 image.tar + + - echo "Pushing the image to our private ECR using Crane..." + - crane push --insecure image.tar ${ECR_REPOSITORY_URI}/otel-collector:${CI_COMMIT_SHORT_SHA} + + - echo "Cleaning up the temporary image file..." + - rm image.tar + allow_failure: false + rules: + - if: '$CI_COMMIT_BRANCH == "main"' + + build_push_app_dp3: stage: push image: @@ -189,18 +486,13 @@ build_push_app_dp3: - compile_app_client - compile_app_server before_script: - - ls bin - - mkdir -p /kaniko/.docker - - echo "Simulating Docker image build setup..." - #TODO: make dynamic from anchors and value - - echo "{\"credHelpers\":{\"${ECR_REPOSITORY_URI}\":\"ecr-login\"}}" > /kaniko/.docker/config.json + - *setup_release_dp3 + - *kaniko_before_setup script: - echo "Building and Pushing app Docker image..." - - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/Dockerfile.dp3" --destination "${ECR_REPOSITORY_URI}/app:$CI_COMMIT_SHORT_SHA" + - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/${APP_DOCKER_FILE}" --destination "${ECR_REPOSITORY_URI}/app:$CI_COMMIT_SHORT_SHA" after_script: - echo "Build_complete" - # rules: - # - if: $CI_COMMIT_BRANCH != "main"' build_push_migrations_dp3: stage: push @@ -211,9 +503,8 @@ build_push_migrations_dp3: - compile_app_server - compile_app_client before_script: - - mkdir -p /kaniko/.docker - - echo "Simulating migrations Docker image build..." - - echo "{\"credHelpers\":{\"${ECR_REPOSITORY_URI}\":\"ecr-login\"}}" > /kaniko/.docker/config.json + - *setup_release_dp3 + - *kaniko_before_setup script: - echo "Building and Pushing migrations Docker image..." - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/Dockerfile.migrations" --destination "${ECR_REPOSITORY_URI}/app-migrations:$CI_COMMIT_SHORT_SHA" @@ -229,13 +520,11 @@ build_push_tasks_dp3: - compile_app_server - compile_app_client before_script: - - mkdir -p /kaniko/.docker - - echo "Simulating tasks Docker image build..." - - echo "{\"credHelpers\":{\"${ECR_REPOSITORY_URI}\":\"ecr-login\"}}" > /kaniko/.docker/config. - - ls -la /builds/milmove/mymove/bin/ + - *setup_release_dp3 + - *kaniko_before_setup script: - echo "Building tasks Docker image..." - - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/Dockerfile.tasks" --destination "${ECR_REPOSITORY_URI}/app-tasks:$CI_COMMIT_SHORT_SHA" + - /kaniko/executor --context "${CI_PROJECT_DIR}/" --dockerfile "${CI_PROJECT_DIR}/${TASK_DOCKER_FILE}" --destination "${ECR_REPOSITORY_URI}/app-tasks:$CI_COMMIT_SHORT_SHA" after_script: - echo "Tasks image built successfully." @@ -289,6 +578,7 @@ deploy_migrations_dp3: # ./scripts/circleci-announce-broken-branch # fi timeout: 40m + deploy_tasks_dp3: stage: deploy image: @@ -302,9 +592,9 @@ deploy_tasks_dp3: - echo "Getting Digest from AWS" - export ECR_DIGEST=$(aws ecr describe-images --repository-name app-tasks --image-ids imageTag=$CI_COMMIT_SHORT_SHA --query 'imageDetails[0].imageDigest' --output text) - echo "Deploying GHC fuel price data task service" - - ./scripts/ecs-deploy-task-container save-ghc-fuel-price-data "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/app-tasks@${ECR_DIGEST}" "${APP_ENVIRONMENT}" + - ./scripts/ecs-deploy-task-container save-ghc-fuel-price-data "${ECR_REPOSITORY_URI}/app-tasks@${ECR_DIGEST}" "${APP_ENVIRONMENT}" - echo "Deploying payment reminder email task service" - - ./scripts/ecs-deploy-task-container send-payment-reminder "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/app-tasks@${ECR_DIGEST}" "${APP_ENVIRONMENT}" + - ./scripts/ecs-deploy-task-container send-payment-reminder "${ECR_REPOSITORY_URI}/app-tasks@${ECR_DIGEST}" "${APP_ENVIRONMENT}" # # Run failure announcement only if on the main branch # - | # if [[ "$CI_COMMIT_BRANCH" == "main" && "$CI_JOB_STATUS" == "failed" ]]; then @@ -332,9 +622,9 @@ deploy_app_client_tls_dp3: - export ECR_DIGEST=$(aws ecr describe-images --repository-name app --image-ids imageTag=$CI_COMMIT_SHORT_SHA --query 'imageDetails[0].imageDigest' --output text) - echo "Getting otel collector Digest from AWS" - export OTEL_ECR_DIGEST=$(aws ecr describe-images --repository-name otel-collector --image-ids imageTag=$CI_COMMIT_SHORT_SHA --query 'imageDetails[0].imageDigest' --output text) - - export OTEL_COLLECTOR_IMAGE="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/otel-collector@${OTEL_ECR_DIGEST}" + - export OTEL_COLLECTOR_IMAGE="${ECR_REPOSITORY_URI}/otel-collector@${OTEL_ECR_DIGEST}" - echo "Deploying app-client-tls service" - - ./scripts/ecs-deploy-service-container app-client-tls "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/app@${ECR_DIGEST}" "${APP_ENVIRONMENT}" "/bin/milmove serve" + - ./scripts/ecs-deploy-service-container app-client-tls "${ECR_REPOSITORY_URI}/app@${ECR_DIGEST}" "${APP_ENVIRONMENT}" "/bin/milmove serve" - echo "Running Health Check" # - bin/health-checker --schemes https --hosts api.demo.dp3.us --key ${TLS_KEY} --cert ${TLS_CERT} --ca ${TLS_CA} --tries 10 --backoff 3 --log-level info --timeout 5m # - echo "Running TLS Check" @@ -363,8 +653,6 @@ deploy_app_dp3: OPEN_TELEMETRY_SIDECAR: "true" HEALTH_CHECK: "true" script: - - ls bin - - pwd - echo "Comparing against deployed commit" # - ./scripts/compare-deployed-commit "" "$CI_COMMIT_SHA" "$TLS_KEY" "$TLS_CERT" "$TLS_CA" - echo "Creating .go-version file if not already present" @@ -380,9 +668,9 @@ deploy_app_dp3: - export ECR_DIGEST=$(aws ecr describe-images --repository-name app --image-ids imageTag=$CI_COMMIT_SHORT_SHA --query 'imageDetails[0].imageDigest' --output text) - echo "Getting otel collector digest from AWS" - export OTEL_ECR_DIGEST=$(aws ecr describe-images --repository-name otel-collector --image-ids imageTag=$CI_COMMIT_SHORT_SHA --query 'imageDetails[0].imageDigest' --output text) - - export OTEL_COLLECTOR_IMAGE="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/otel-collector@${OTEL_ECR_DIGEST}" + - export OTEL_COLLECTOR_IMAGE="${ECR_REPOSITORY_URI}/otel-collector@${OTEL_ECR_DIGEST}" - echo "Deploying app service" - - ./scripts/ecs-deploy-service-container app "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/app@${ECR_DIGEST}" "${APP_ENVIRONMENT}" "/bin/milmove serve" + - ./scripts/ecs-deploy-service-container app "${ECR_REPOSITORY_URI}/app@${ECR_DIGEST}" "${APP_ENVIRONMENT}" "/bin/milmove serve" - echo "Running Health Check" # - bin/health-checker --schemes https --hosts my.demo.dp3.us,office.demo.dp3.us,admin.demo.dp3.us --tries 10 --backoff 3 --log-level info --timeout 5m # - echo "Running TLS Check" From aa45abfa9fa3893423f899d4a1558bc56c6b1e87 Mon Sep 17 00:00:00 2001 From: josiahzimmerman-caci Date: Mon, 23 Dec 2024 16:55:27 +0000 Subject: [PATCH 9/9] ci/cd work --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf23c744800..a6043baaca9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -327,7 +327,7 @@ build_push_app_stg: after_script: - echo "Build_complete" rules: - - if: $CI_COMMIT_BRANCH == "main"' + - if: '$CI_COMMIT_BRANCH == "main"' build_push_migrations_stg: stage: push @@ -346,7 +346,7 @@ build_push_migrations_stg: after_script: - echo "Migrations image built and pushed successfully." rules: - - if: $CI_COMMIT_BRANCH == "main"' + - if: '$CI_COMMIT_BRANCH == "main"' build_push_tasks_stg: stage: push @@ -365,7 +365,7 @@ build_push_tasks_stg: after_script: - echo "Tasks image built successfully." rules: - - if: $CI_COMMIT_BRANCH == "main"' + - if: '$CI_COMMIT_BRANCH == "main"' push_otel_collector_image_stg: stage: push @@ -410,7 +410,7 @@ build_push_app_prd: after_script: - echo "Build_complete" rules: - - if: $CI_COMMIT_BRANCH == "main"' + - if: '$CI_COMMIT_BRANCH == "main"' build_push_migrations_prd: stage: push @@ -429,7 +429,7 @@ build_push_migrations_prd: after_script: - echo "Migrations image built and pushed successfully." rules: - - if: $CI_COMMIT_BRANCH == "main"' + - if: '$CI_COMMIT_BRANCH == "main"' build_push_tasks_prd: stage: push @@ -448,7 +448,7 @@ build_push_tasks_prd: after_script: - echo "Tasks image built successfully." rules: - - if: $CI_COMMIT_BRANCH == "main"' + - if: '$CI_COMMIT_BRANCH == "main"' push_otel_collector_image_prd: stage: push @@ -474,7 +474,7 @@ push_otel_collector_image_prd: - rm image.tar allow_failure: false rules: - - if: '$CI_COMMIT_BRANCH == "main"' + - if: '$CI_COMMIT_BRANCH == "main"' build_push_app_dp3: