Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read schema from PR branches for sandboxed deployments. #255

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
overwrite: true
parameters:
-p ROUTE=pubcode-${{ github.event.number }}.apps.silver.devops.gov.bc.ca
-p MIN_REPLICAS=1 -p MAX_REPLICAS=2 -p MEMORY_REQUEST=75Mi -p MEMORY_LIMIT=150Mi -p CPU_REQUEST=100m -p CPU_LIMIT=125m
-p MIN_REPLICAS=1 -p MAX_REPLICAS=2 -p MEMORY_REQUEST=75Mi -p MEMORY_LIMIT=150Mi -p CPU_REQUEST=100m -p CPU_LIMIT=125m -p VITE_SCHEMA_BRANCH=${{ github.event.pull_request.head.ref }}

steps:
- uses: bcgov-nr/[email protected]
Expand Down
4 changes: 4 additions & 0 deletions frontend/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
}
encode gzip

handle /config.js {
header Content-Type "text/javascript"
respond `window.config = {"VITE_SCHEMA_BRANCH":"{$VITE_SCHEMA_BRANCH}"};`
}
handle {
root * /app/dist
try_files {path} {path}/ /index.html
Expand Down
4 changes: 4 additions & 0 deletions frontend/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


// eslint-disable-next-line import/prefer-default-export
export const env = { ...import.meta.env, ...window.config };
1 change: 1 addition & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BCGov Public Code</title>
<script src="/config.js"></script>
</head>
<body>
<div id="root"></div>
Expand Down
5 changes: 5 additions & 0 deletions frontend/openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ parameters:
- name: LOG_LEVEL
description: Caddy logging level DEBUG, INFO, WARN, ERROR, PANIC, and FATAL (https://github.com/caddyserver/caddy/blob/master/logging.go)
value: "info"
- name: VITE_SCHEMA_BRANCH
description: Vite schema branch to use
value: "main" # override with values for PR based deployment.
objects:
- apiVersion: v1
kind: ImageStream
Expand Down Expand Up @@ -97,6 +100,8 @@ objects:
env:
- name: LOG_LEVEL
value: ${LOG_LEVEL}
- name: VITE_SCHEMA_BRANCH
value: ${VITE_SCHEMA_BRANCH}
ports:
- containerPort: 3000
protocol: TCP
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/FormComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import React, { useEffect, useState } from "react";
import Form from "@rjsf/material-ui";
import validator from "@rjsf/validator-ajv8";
import * as YAML from "js-yaml";
//import * as localSchema from "../../../schema/bcgovpubcode.json";
import { env } from "../../env";
//import * as localSchema from "../../../schema/bcgovpubcode.json"; // uncmmment this line for local schema for testing
import { useLocation, useNavigate } from "react-router";
import { Backdrop, CircularProgress } from "@material-ui/core";
import * as _ from "lodash";
// below props needs to be treated properly for the form to work properly as the nesting does not work if they are undefined.
const props = ["product_information.business_capabilities_standard", "product_technology_information.ci_cd_tools", "product_technology_information.data_storage_platforms", "product_technology_information.frontend_frameworks", "product_technology_information.hosting_platforms", "product_technology_information.spatial_mapping_technologies", "product_external_dependencies.common_components", "product_external_dependencies.identity_authorization"];

const jsonSchemaBranch = env.VITE_SCHEMA_BRANCH || "main";
function removeBlankFields(jsonData) {
if (jsonData) {
for (const replaceProp of props) {
Expand Down Expand Up @@ -57,13 +58,14 @@ const FormComponent = () => {
});

const [schema, setSchema] = useState(null);
//const [schema, setSchema] = useState(localSchema); // uncomment this line for local schema for testing
const [error, setError] = useState(null);
const navigate = useNavigate();
useEffect(() => {
async function fetchData() {
try {
const response = await fetch(
"https://raw.githubusercontent.com/bcgov/pubcode/main/schema/bcgovpubcode.json"
`https://raw.githubusercontent.com/bcgov/pubcode/${jsonSchemaBranch}/schema/bcgovpubcode.json`
);
const data = await response.json();
setSchema(data);
Expand Down
4 changes: 2 additions & 2 deletions schema/bcgovpubcode.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"ministry": {
"uniqueItems": true,
"title": "Ministry",
"description": "This key contains the ministry name. link: https://www2.gov.bc.ca/gov/content/governments/organizational-structure/ministries-organizations/ministries",
"description": "This key contains the ministry name. -> link: https://www2.gov.bc.ca/gov/content/governments/organizational-structure/ministries-organizations/ministries",
"type": "array",
"items": {
"enum": [
Expand Down Expand Up @@ -739,4 +739,4 @@
],
"title": "JSON schema for bcgovpubcode.yml",
"type": "object"
}
}