Skip to content

Commit

Permalink
Merge branch 'release/yellow-boring-sponge' into CE-1254
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-funk authored Nov 28, 2024
2 parents 3b95fd8 + 5545ba2 commit 3358d13
Show file tree
Hide file tree
Showing 225 changed files with 3,175 additions and 1,772 deletions.
76 changes: 76 additions & 0 deletions .github/scripts/cleanup_nats_js.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash
# Cleanup NATS JetStream PVC (deletion)
# Why: nats js pvc does not have label passthrough https://github.com/nats-io/k8s/blob/nats-1.2.6/helm/charts/nats/files/stateful-set/jetstream-pvc.yaml
# So we manually find it and delete it on non-draft PR close and ONLY in *dev namespaces
#
# Dependencies: curl, oc
#
set -e # failfast
trap 'echo "Error occurred at line $LINENO while executing function $FUNCNAME"' ERR

# ENV:
# OC_NAMESPACE: namespace to scan
# SKIP_AUTH: set to true to skip auth and use your existing local kubeconfig
# OC_SERVER: OpenShift server URL
# OC_TOKEN: OpenShift token
# PR_NUMBER: PR number

help_str() {
echo "Usage: SKIP_AUTH=true OC_NAMESPACE=<namespace> PR_NUMBER=<number> ./cleanup_nats_js.sh"
echo ""
echo "Ensure you have curl, oc installed and available on your path, and have performed a oc login if skipping auth for a local run."
echo ""
echo "Note: this script will skip cleanup if the namespace is not a development environment."
}

# Handle auth
OC_TEMP_TOKEN=""
if [ -z "$OC_NAMESPACE" ]; then
echo "OC_NAMESPACE is not set. Exiting..."
help_str
exit 1
fi
if [ "$SKIP_AUTH" != "true" ]; then
if [ -z "$OC_SERVER" ]; then
echo "OC_SERVER is not set. Exiting..."
help_str
exit 1
fi
if [ -z "$OC_TOKEN" ]; then
echo "OC_TOKEN is not set. Exiting..."
help_str
exit 1
fi
# Auth flow
OC_TEMP_TOKEN=$(curl -k -X POST $OC_SERVER/api/v1/namespaces/$OC_NAMESPACE/serviceaccounts/pipeline/token --header "Authorization: Bearer $OC_TOKEN" -d '{"spec": {"expirationSeconds": 600}}' -H 'Content-Type: application/json; charset=utf-8' | jq -r '.status.token' )
oc login --token=$OC_TEMP_TOKEN --server=$OC_SERVER
oc project $OC_NAMESPACE # Safeguard!
fi

# test / prod safeguard
if [[ "$OC_NAMESPACE" != *"dev"* ]]; then
echo "Namespace is not configured to a development environment, skipping cleanup"
exit 0
fi

get_pvc_name() {
local pvc_name
pvc_name=$(oc get pvc -n $OC_NAMESPACE -oname | grep "nats-js" | grep "$PR_NUMBER")
echo "$pvc_name"
}

main() {
local pvc_name
pvc_name=$(get_pvc_name)
echo "Found pvc '$pvc_name' using PR Number $PR_NUMBER in namespace $OC_NAMESPACE"
if [ -z "$pvc_name" ]; then
echo "Error: no pvc found to delete"
echo "This failure could be expected if the helm build for the PR did not complete, or the PR was quickly opened and closed."
exit 1
fi
echo "Performing deletion of pvc $pvc_name..."
echo "..."
oc delete $pvc_name -n $OC_NAMESPACE
echo "Completed"
}
main
2 changes: 1 addition & 1 deletion .github/workflows/.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
command: npx cypress run --browser electron --config baseUrl=https://${{ env.PREFIX }}-frontend.${{ env.DOMAIN }} --env auth_base_url=${{ vars.KEYCLOAK_URL_DEV }},auth_realm=${{ vars.KEYCLOAK_REALM }},auth_client_id=${{ vars.KEYCLOAK_CLIENT_ID }},keycloak_user=${{ vars.KEYCLOAK_USER }},keycloak_user_02=${{ vars.KEYCLOAK_USER_02 }},keycloak_password=${{ secrets.KEYCLOAK_PASSWORD }}

- name: Upload Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-artifacts
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/merge-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
--set webeoc.pdb.enabled=true
--set nats.config.cluster.replicas=3
--set nats.config.cluster.enabled=true
--set backup.enabled=true
--set backup.persistence.size=256Mi

promote:
name: Promote Images
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,19 @@ jobs:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
cleanup: label
cleanup: label

cleanup-nats-js:
name: Cleanup NATS JetStream PVC
runs-on: ubuntu-22.04
environment:
timeout-minutes: 2
if: ${{ ! github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v4
- run: ./.github/scripts/cleanup_nats_js.sh
env:
OC_NAMESPACE: ${{ vars.OC_NAMESPACE }}
OC_SERVER: ${{ vars.OC_SERVER }}
OC_TOKEN: ${{ secrets.OC_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
11 changes: 8 additions & 3 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on:
pull_request:
branches:
- release/**
types:
- opened
- reopened
- synchronize
- ready_for_review

concurrency:
# Cancel in progress for PR open and close
Expand Down Expand Up @@ -35,12 +40,12 @@ jobs:
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
triggers: ('backend/' 'frontend/' 'webeoc/' 'migrations/')
# with:
# triggers: ('backend/' 'frontend/' 'webeoc/' 'migrations/')

tests:
name: Tests
if: needs.deploys.outputs.triggered == 'true'
if: needs.deploys.outputs.triggered == 'true' && ${{ !github.event.pull_request.draft }}
needs: [deploys]
uses: ./.github/workflows/.tests.yml

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
deploy-prod:
name: Deploy (prod)
needs: [vars]
uses: bcgov/quickstart-openshift-helpers/.github/workflows/.deployer.yml@v0.5.0
uses: bcgov/quickstart-openshift-helpers/.github/workflows/.deployer.yml@v0.8.3
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
Expand All @@ -86,6 +86,8 @@ jobs:
--set nats.config.cluster.enabled=true
--set bitnami-pg.backup.cronjob.storage.size=512Mi
--set bitnami-pg.primary.persistence.size=512Mi
--set backup.enabled=true
--set backup.persistence.size=256Mi

promote:
name: Promote Images
Expand Down
19 changes: 19 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://docs.sonarqube.org/latest/analysis/analysis-parameters/
sonar.projectKey=bcgov_nr-compliance-enforcement
sonar.organization=bcgov-sonarcloud
sonar.host.url=https://sonarcloud.io
sonar.projectName=nr-compliance-enforcement
sonar.verbose=true

# Path is relative to the .sonarcloud.properties file. Defaults to .
sonar.sources=.
sonar.modules=frontend,backend

# Ignore duplication scanning for tests
sonar.cpd.exclusions=**/*spec.ts,**/cypress/**,**/test/**

# Ignore database migrations
sonar.exclusions=**/migrations/**

# Identify the test files (https://docs.sonarsource.com/sonarqube-server/latest/project-administration/analysis-scope/#setting-the-initial-scope)
sonar.tests.inclusions=**/*spec.ts
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nr-compliance-enforcement",
"version": "0.0.1",
"version": "0.28.1",
"description": "BCGov devops quickstart. For reference, testing and new projects.",
"main": "index.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions backend/src/enum/case_management_error.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum CaseManagementError {
DECISION_ACTION_EXIST = "Decision Action Exist",
}
43 changes: 35 additions & 8 deletions backend/src/external_api/case_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ export const caseFileQueryFields: string = `
shortDescription
longDescription
activeIndicator
isLegacy
}
contactedComplainant
attended
locationType {
key
value
}
conflictHistory {
key
value
}
categoryLevel {
key
value
}
cat1Actions {
actionId
actor
date
actionCode
shortDescription
longDescription
activeIndicator
}
}
isReviewRequired
Expand Down Expand Up @@ -59,6 +83,7 @@ export const caseFileQueryFields: string = `
equipment {
id
typeCode
typeDescription
activeIndicator
address
xCoordinate
Expand All @@ -76,30 +101,32 @@ export const caseFileQueryFields: string = `
id
species
sex
sexDescription
age
ageDescription
categoryLevel
conflictHistory
categoryLevelDescription
identifyingFeatures
outcome
outcomeDescription
tags {
id
ear
earDescription
identifier
order
}
drugs {
id
vial
drug
drugDescription
amountUsed
injectionMethod
reactions
injectionMethodDescription
remainingUse
amountDiscarded
discardMethod
remainingUseDescription
additionalComments
order
}
actions {
Expand Down
13 changes: 13 additions & 0 deletions backend/src/middleware/maps/automapper-entity-to-dto-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ export const applyWildlifeComplaintMap = (mapper: Mapper) => {
return "";
}),
),
forMember(
(destination) => destination.isLargeCarnivore,
mapFrom((src) => src.species_code.large_carnivore_ind),
),
forMember(
(destination) => destination.natureOfComplaint,
mapFrom((src) => {
Expand Down Expand Up @@ -1452,6 +1456,15 @@ export const mapWildlifeReport = (mapper: Mapper, tz: string = "America/Vancouve
(destination) => destination.referenceNumber,
mapFrom((source) => source.complaint_identifier.reference_number),
),
forMember(
(destination) => destination.linkedComplaintIdentifier,
mapFrom((source) => {
const {
complaint_identifier: { linked_complaint_xref: linkedComplaints },
} = source;
return linkedComplaints[0]?.complaint_id;
}),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ export interface DrugUsedInput {
drug: string;
amountUsed: string;
injectionMethod: string;
reactions: string;

remainingUse: string;
amountDiscarded: string;
discardMethod: string;
additionalComments: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export interface WildlifeInput {
tags?: Array<EarTagInput>;
drugs?: Array<DrugUsedInput>;
actions?: Array<WildlifeActionInput>;
identifyingFeatures?: string;
}
5 changes: 5 additions & 0 deletions backend/src/types/models/code-tables/case-location-code.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseCodeTable } from "./code-table";

export interface CaseLocationCode extends BaseCodeTable {
caseLocationType: string;
}
2 changes: 2 additions & 0 deletions backend/src/types/models/code-tables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export const AvailableCodeTables = [
"team",
"complaint-method-received-codes",
"lead-agency",
"assessment-cat1-type",
"case-location-type",
];

export const AvailableAgencies = ["cos"];
Expand Down
1 change: 1 addition & 0 deletions backend/src/types/models/code-tables/species.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { BaseCodeTable } from "./code-table";
export interface Species extends BaseCodeTable {
species: string;
legacy: string;
isLargeCarnivore: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export interface ComplaintFilterParameters {
girTypeCode?: string;
complaintMethod?: string;
actionTaken?: string;
outcomeAnimal?: string;
}
1 change: 1 addition & 0 deletions backend/src/types/models/complaints/wildlife-complaint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BaseComplaint } from "nrs-ce-common-types";
export interface WildlifeComplaintDto extends ComplaintDto, BaseComplaint {
hwcrId: UUID;
species: string;
isLargeCarnivore: boolean;
natureOfComplaint: string;
attractants: Array<AttractantXrefDto>;
otherAttractants: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ export interface ComplaintReportData {
reportedBy: string;

updates: Array<ComplaintUpdateDto>;

linkedComplaintIdentifier: string;
}
Loading

0 comments on commit 3358d13

Please sign in to comment.