Skip to content

Commit

Permalink
feat: generate enclave manager ui in build process and check prettier (
Browse files Browse the repository at this point in the history
…#1717)

## Description:
This pr includes the new enclave manager in the build process -
specifically in the `engine` build process. This removes the need to
commit the built emui to the codebase.

Additionally `yarn prettier` is added as a build step to the emui, which
will fail the build if prettier has not been run (as is currently the
case in main).

This change also includes a fix to all linting warnings, so that there
are no warnings in the production build.

## Is this change user facing?
NO

## References (if applicable):
* devconnect burndown
  • Loading branch information
Dartoxian authored Nov 16, 2023
1 parent 6bf65d2 commit d6be248
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 138 deletions.
42 changes: 42 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ parameters:
file-artifacts-expander-image-filename:
type: string
default: "file-artifacts-expander-image.tgz"
enclave-manager-yarn-cache-key-prefix:
type: string
default: "enclave-manager_yarn"
engine-server-image-filename:
type: string
default: "engine-server-image.tgz"
Expand Down Expand Up @@ -394,6 +397,33 @@ jobs:
paths:
- "<< pipeline.parameters.core-server-image-filename >>"

build_enclave_manager_webapp:
executor: ubuntu_vm
steps:
- checkout

- <<: *abort_job_if_only_docs_changes

# Cache our dependencies
- restore_cache:
keys:
- << pipeline.parameters.enclave-manager-yarn-cache-key-prefix>>-{{ checksum "enclave-manager/api/typescript/yarn.lock" }}-{{ checksum "enclave-manager/web/yarn.lock" }}

- run: npm install -g yarn

- run: |
enclave-manager/scripts/build.sh
- save_cache:
key: << pipeline.parameters.enclave-manager-yarn-cache-key-prefix>>-{{ checksum "enclave-manager/api/typescript/yarn.lock" }}-{{ checksum "enclave-manager/web/yarn.lock" }}
paths:
- "/home/circleci/.cache/yarn"

- persist_to_workspace:
root: engine/server
paths:
- webapp

build_engine_launcher:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version >>"
Expand All @@ -416,6 +446,11 @@ jobs:

- <<: *abort_job_if_only_docs_changes

- attach_workspace:
at: "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>"

- run: cp -R << pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/webapp engine/server/webapp

# Generate Kurtosis Version
- run: "<<pipeline.parameters.generate-kurtosis-version-script-path>>"

Expand Down Expand Up @@ -1235,6 +1270,11 @@ workflows:
ignore:
- main

- build_enclave_manager_webapp:
filters:
branches:
ignore:
- main
- build_engine_launcher:
filters:
branches:
Expand All @@ -1243,6 +1283,8 @@ workflows:
- build_engine_server:
context:
- docker-user
requires:
- build_enclave_manager_webapp
filters:
branches:
ignore:
Expand Down
28 changes: 28 additions & 0 deletions enclave-manager/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# 2021-07-08 WATERMARK, DO NOT REMOVE - This script was generated from the Kurtosis Bash script template

set -euo pipefail # Bash "strict mode"
script_dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
root_dirpath="$(dirname "${script_dirpath}")"



# ==================================================================================================
# Constants
# ==================================================================================================
BUILD_SCRIPT_RELATIVE_FILEPATHS=(
"api/scripts/build.sh"
"web/scripts/build.sh"
)


# ==================================================================================================
# Main Logic
# ==================================================================================================
for build_script_rel_filepath in "${BUILD_SCRIPT_RELATIVE_FILEPATHS[@]}"; do
build_script_abs_filepath="${root_dirpath}/${build_script_rel_filepath}"
if ! bash "${build_script_abs_filepath}"; then
echo "Error: Build script '${build_script_abs_filepath}' failed" >&2
exit 1
fi
done
12 changes: 12 additions & 0 deletions enclave-manager/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn prettier`

Runs `prettier --check` to check that the code matches the formatting that [`prettier`](https://prettier.io/) would apply.

### `yarn prettier:fix`

Applies any formatting changes prettier wants to apply to this application. For ease of use you can use IDE integrations
to auto apply prettier changes on file save, see instructions:

- [Here](https://plugins.jetbrains.com/plugin/10456-prettier) for Intellij
- [Here](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) for vscode

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
Expand Down
2 changes: 1 addition & 1 deletion enclave-manager/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
},
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
"prebuild": "rm -rf ../../engine/server/webapp",
"clean": "rm -rf build",
"cleanInstall": "rm -rf node_modules; yarn install",
"start": "react-scripts start",
"start:prod": "serve -s build",
"prebuild": "rm -rf ../../engine/server/webapp",
"build": "react-scripts build",
"postbuild": "cp -r build/ ../../engine/server/webapp",
"prettier": "prettier . --check",
Expand Down
1 change: 1 addition & 0 deletions enclave-manager/web/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ lang_root_dirpath="$(dirname "${script_dirpath}")"
# ==================================================================================================
cd "${lang_root_dirpath}"
yarn install --frozen-lockfile
yarn prettier
# There are no unit tests currently
# CGO_ENABLED=0 yarn test
yarn clean
Expand Down
5 changes: 3 additions & 2 deletions enclave-manager/web/src/components/LocationListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { useKurtosisClient } from "../client/enclaveManager/KurtosisClientContex
export const LocationListener = () => {
const client = useKurtosisClient();
const navigate = useNavigate();
const cloudUrl = client.getCloudUrl();

useEffect(() => {
if (client.getCloudUrl()) {
if (cloudUrl) {
const route = client.getParentRequestedRoute();
if (route) navigate(route);
}
}, [client.getCloudUrl()]);
}, [cloudUrl, client, navigate]);

return <></>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
ModalHeader,
ModalOverlay,
Text,
Tooltip, useToast,
Tooltip,
useToast,
} from "@chakra-ui/react";
import { EnclaveMode } from "enclave-manager-sdk/build/engine_service_pb";
import { useMemo, useRef, useState } from "react";
Expand Down Expand Up @@ -80,8 +81,6 @@ export const ConfigureEnclaveModal = ({
return isDefined(value) ? `${value}` : "";
case ArgumentValueType.STRING:
return value || "";
case ArgumentValueType.JSON:
return isDefined(value) ? JSON.stringify(value) : "{}";
case ArgumentValueType.LIST:
assertDefined(innerType1, `Cannot parse a list argument type without knowing innerType1`);
return isDefined(value) ? value.map((v: any) => convertArgValue(innerType1, v)) : [];
Expand Down Expand Up @@ -167,7 +166,9 @@ export const ConfigureEnclaveModal = ({
}
} catch (err) {
toast({
title: `An error occurred while preparing data for running package. The package arguments were not proper JSON: ${stringifyError(err)}`,
title: `An error occurred while preparing data for running package. The package arguments were not proper JSON: ${stringifyError(
err,
)}`,
colorScheme: "red",
});
return;
Expand Down
2 changes: 2 additions & 0 deletions engine/server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The webapp is generated by the enclave-manager/web build process
webapp/
10 changes: 0 additions & 10 deletions engine/server/webapp/asset-manifest.json

This file was deleted.

Binary file removed engine/server/webapp/favicon.ico
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion engine/server/webapp/index.html

This file was deleted.

Binary file removed engine/server/webapp/logo.png
Binary file not shown.
3 changes: 0 additions & 3 deletions engine/server/webapp/static/js/main.efcd178a.js

This file was deleted.

116 changes: 0 additions & 116 deletions engine/server/webapp/static/js/main.efcd178a.js.LICENSE.txt

This file was deleted.

1 change: 0 additions & 1 deletion engine/server/webapp/static/js/main.efcd178a.js.map

This file was deleted.

1 change: 1 addition & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ BUILD_SCRIPT_RELATIVE_FILEPATHS=(
"api/scripts/build.sh"
"metrics-library/scripts/build.sh"
"core/scripts/build.sh"
"enclave-manager/scripts/build.sh"
"engine/scripts/build.sh"
"cli/scripts/build.sh"
)
Expand Down

0 comments on commit d6be248

Please sign in to comment.