Skip to content

Commit

Permalink
Merge pull request #2174 from HHS/main
Browse files Browse the repository at this point in the history
[Prod] DevOps: Fail Fast, update python, cimg Namespace,  & Backup production DB on each deploy
  • Loading branch information
Jones-QuarteyDana committed May 30, 2024
2 parents 5d6b8d5 + 12bbe99 commit f28aa1f
Show file tree
Hide file tree
Showing 34 changed files with 2,405 additions and 86 deletions.
56 changes: 40 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ executors:
- image: cimg/node:18.20.3-browsers
environment:
DATABASE_URL: postgresql://postgres@localhost/ttasmarthub
- image: circleci/postgres:12.4-ram
- image: cimg/postgres:15.6
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secretpass
POSTGRES_DB: ttasmarthub
docker-python-executor:
docker:
- image: cimg/python:3.9.18
- image: cimg/python:3.9.19
docker-postgres-elasticsearch-executor:
docker:
- image: cimg/node:18.20.3-browsers
environment:
DATABASE_URL: postgresql://postgres@localhost/ttasmarthub
- image: circleci/postgres:12.4-ram
- image: cimg/postgres:15.6
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secretpass
Expand Down Expand Up @@ -462,9 +462,25 @@ jobs:
- run:
name: Lint backend
command: yarn lint:ci
- run:
name: Audit vulnerability of backend node_modules
command: |
chmod 744 ./run-yarn-audit.sh
./run-yarn-audit.sh;
- run:
name: Lint frontend
command: yarn --cwd frontend lint:ci
- run:
name: Audit vulnerability of frontend node_modules
command: |
cd frontend
chmod 744 ./run-yarn-audit.sh
./run-yarn-audit.sh;
- run:
name: Check nodejs version compatibility with buildpack
command: |
chmod +x ./bin/check_node_version_compatibility.sh
./bin/check_node_version_compatibility.sh
- store_artifacts: # store backend lint reports
path: reports
- store_artifacts: # store frontend lint reports
Expand Down Expand Up @@ -497,6 +513,11 @@ jobs:
source venv/bin/activate
pip install -U pip setuptools wheel
pip install -U -r requirements.txt
- run:
name: Check python version compatibility with buildpack
command: |
chmod +x ./bin/check_python_version_compatibility.sh
./bin/check_python_version_compatibility.sh
- save_cache:
paths:
- similarity_api/src/venv
Expand All @@ -522,11 +543,6 @@ jobs:
at: .
- setup_remote_docker:
version: default
- run:
name: Audit vulnerability of backend node_modules
command: |
chmod 744 ./run-yarn-audit.sh
./run-yarn-audit.sh;
- run:
name: Run migrations ci
command: yarn db:migrate:ci
Expand Down Expand Up @@ -563,7 +579,7 @@ jobs:
- run:
name: Syft SBOM
environment:
SYFT_VERSION: v0.82.0
SYFT_VERSION: v1.5.0
IMAGE_NAME: ghcr.io/kcirtapfromspace/cloudfoundry_circleci:latest
OUTPUT_FORMAT: json
OUTPUT_FILE: reports/syft_sbom.json
Expand All @@ -577,7 +593,7 @@ jobs:
- run:
name: Grype Docker image
environment:
GRYPE_VERSION: v0.62.2
GRYPE_VERSION: v0.78.0
OUTPUT_FORMAT: sarif
OUTPUT_FILE: reports/grype.json
command: |
Expand Down Expand Up @@ -607,12 +623,6 @@ jobs:
command: |
chmod 744 ./checkcolorhash.sh
./checkcolorhash.sh;
- run:
name: Audit vulnerability of frontend node_modules
command: |
cd frontend
chmod 744 ./run-yarn-audit.sh
./run-yarn-audit.sh;
- run:
name: Test frontend
command: yarn --cwd frontend run test:ci --maxWorkers=50%
Expand Down Expand Up @@ -1069,6 +1079,20 @@ workflows:
- dynamic_security_scan:
requires:
- build_and_lint
- backup_upload_production:
requires:
- test_backend
- test_frontend
- test_e2e
- test_api
- test_similarity_api
- test_utils
- cucumber_test
- dynamic_security_scan
filters:
branches:
only:
- << pipeline.parameters.prod_git_branch >>
- deploy:
requires:
- test_backend
Expand Down
35 changes: 35 additions & 0 deletions bin/check_node_version_compatibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# check_node_version_compatibility.sh
# Script to fetch the required Node.js version and compare with buildpack

# Read Node.js version from .nvmrc file at the root of the project and remove carriage returns and new lines
node_version_required=$(cat .nvmrc | tr -d '\r' | tr -d '\n')

# Fetch the latest release data from GitHub
latest_release_info=$(curl -s https://api.github.com/repos/cloudfoundry/nodejs-buildpack/releases/latest)

# Parse the release data to extract supported Node.js versions using jq, grep, awk, and sort
supported_versions=$(echo "$latest_release_info" | jq -r '.body' | grep 'node' | awk '{print $4}' | grep -vP '[^.0-9]' | sort -u)

# Check if the required version is supported by iterating over the array
version_found=0
for version in $supported_versions; do
echo "Checking if $version == $node_version_required"
if [[ "$version" == "$node_version_required" ]]; then
version_found=1
break
fi
done

echo ""

if [[ $version_found -eq 1 ]]; then
echo "Required Node.js version $node_version_required is supported."
exit 0 # Exit with success
else
echo "Required Node.js version $node_version_required is not supported."
echo "Supported Versions:"
echo "$supported_versions"
exit 1 # Exit with error
fi
35 changes: 35 additions & 0 deletions bin/check_python_version_compatibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# check_python_version_compatibility.sh
# Script to fetch the required Python version and compare with buildpack

# Read Python version from .python-version file
python_version_required=$(cat similarity_api/.python-version | tr -d '\r' | tr -d '\n')

# Fetch the latest release data from GitHub
latest_release_info=$(curl -s https://api.github.com/repos/cloudfoundry/python-buildpack/releases/latest)

# Parse the release data to extract supported Python versions using jq, grep, awk, and sort
supported_versions=$(echo "$latest_release_info" | jq -r '.body' | grep python | awk '{print $4}' | grep -vP '[^.0-9]' | sort -u)

# Check if the required version is supported by iterating over the array
version_found=0
for version in $supported_versions; do
echo "Checking if $version == $python_version_required"
if [[ "$version" == "$python_version_required" ]]; then
version_found=1
break
fi
done

echo ""

if [[ $version_found -eq 1 ]]; then
echo "Required Python version $python_version_required is supported."
exit 0 # Exit with success
else
echo "Required Python version $python_version_required is not supported."
echo "Supported Versions:"
echo "$supported_versions"
exit 1 # Exit with error
fi
10 changes: 10 additions & 0 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Admin from './pages/Admin';
import RegionalDashboard from './pages/RegionalDashboard';
import TrainingReports from './pages/TrainingReports';
import ResourcesDashboard from './pages/ResourcesDashboard';
import CourseDashboard from './pages/CourseDashboard';
import Unauthenticated from './pages/Unauthenticated';
import NotFound from './pages/NotFound';
import Home from './pages/Home';
Expand Down Expand Up @@ -261,6 +262,15 @@ function App() {
</AppWrapper>
)}
/>
<Route
exact
path="/dashboards/ipd-courses"
render={() => (
<AppWrapper authenticated logout={logout}>
<CourseDashboard />
</AppWrapper>
)}
/>
<Route
exact
path="/training-reports/:status(not-started|in-progress|complete|suspended)"
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,9 @@ fill: #1B1B1B;
writing-mode: vertical-lr;
transform: rotate(180deg);
}

.text-overflow-ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
2 changes: 2 additions & 0 deletions frontend/src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const GOVERNMENT_HOSTNAME_EXTENSION = '.ohs.acf.hhs.gov';
export const ESCAPE_KEY_CODE = 27;
export const GOALS_PER_PAGE = 10;
export const TOPICS_PER_PAGE = 10;
export const COURSES_PER_PAGE = 10;

// In Internet Explorer (tested on release 9 and 11) and Firefox 36 and earlier
// the Esc key returns "Esc" instead of "Escape".
Expand All @@ -174,3 +175,4 @@ export const LOCAL_STORAGE_DATA_KEY = (id) => `ar-form-data-${id}-${LOCAL_STORAG
export const LOCAL_STORAGE_ADDITIONAL_DATA_KEY = (id) => `ar-additional-data-${id}-${LOCAL_STORAGE_CACHE_NUMBER}`;
export const LOCAL_STORAGE_EDITABLE_KEY = (id) => `ar-can-edit-${id}-${LOCAL_STORAGE_CACHE_NUMBER}`;
export const SESSION_STORAGE_IMPERSONATION_KEY = `auth-impersonation-id-${LOCAL_STORAGE_CACHE_NUMBER}`;
export const REGIONAL_RESOURCE_DASHBOARD_FILTER_KEY = 'regional-resources-dashboard-filters';
4 changes: 2 additions & 2 deletions frontend/src/components/PaginationCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ function PaginationCard({

return (
<div className={`smart-hub--pagination-card display-flex bg-white ${className}`}>
<div className="display-flex flex-1 flex-align-center margin-left-4">{getPageInfo()}</div>
<div className="display-flex flex-1 flex-align-center">{getPageInfo()}</div>
<Pagination
className="padding-1"
className="margin-0"
currentPage={currentPage}
totalPages={getTotalPages()}
onClickNext={() => handlePageChange(currentPage + 1)}
Expand Down
44 changes: 29 additions & 15 deletions frontend/src/components/WidgetContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export default function WidgetContainer(
showHeaderBorder,
titleSlot,
className,
enableCheckboxes,
exportRows,
footNote,
},
) {
return (
Expand All @@ -44,6 +47,8 @@ export default function WidgetContainer(
className="flex-justify-self-end"
/>
) : null}
enableCheckboxes={enableCheckboxes}
exportRows={exportRows}
>
{titleSlot}
</WidgetContainerTitleGroup>
Expand All @@ -57,21 +62,24 @@ export default function WidgetContainer(
<div className="margin-top-0">
{children}
</div>
<div className="smart-hub-widget-container-footer">
{
showPagingBottom
? (
<PaginationCard
currentPage={currentPage}
totalCount={totalCount}
offset={offset}
perPage={perPage}
handlePageChange={handlePageChange}
/>
)
: null
}
</div>
{showPagingBottom || footNote ? (
<div className="smart-hub-widget-container-footer padding-3">
{footNote && (
<p className="usa-prose font-sans-3xs margin-top-0">
{footNote}
</p>
)}
{showPagingBottom && (
<PaginationCard
currentPage={currentPage}
totalCount={totalCount}
offset={offset}
perPage={perPage}
handlePageChange={handlePageChange}
/>
)}
</div>
) : null}
</Container>
);
}
Expand All @@ -93,6 +101,9 @@ WidgetContainer.propTypes = {
showHeaderBorder: PropTypes.bool,
titleSlot: PropTypes.node,
className: PropTypes.string,
enableCheckboxes: PropTypes.bool,
exportRows: PropTypes.func,
footNote: PropTypes.string,
};

WidgetContainer.defaultProps = {
Expand All @@ -111,4 +122,7 @@ WidgetContainer.defaultProps = {
titleSlot: null,
loadingLabel: 'Loading',
className: '',
enableCheckboxes: false,
exportRows: () => {},
footNote: null,
};
4 changes: 4 additions & 0 deletions frontend/src/components/WidgetContainer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@

.smart-hub-widget-container .smart-hub-widget-container-footer {
border-top: 1px solid $base-lighter;
}

.smart-hub-widget-container .smart-hub--menu-button .fa-ellipsis {
font-size: 1.5rem;
}
Loading

0 comments on commit f28aa1f

Please sign in to comment.