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

Build UI during package instead of install #621

Merged
merged 31 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3ecaad1
Build UI during package
jboddey Jul 22, 2024
caf9476
Fix local build
jboddey Jul 22, 2024
17f30c6
Install npm
jboddey Jul 22, 2024
784d1a3
Remove duplicate build message
jboddey Jul 22, 2024
ff16719
Fix ESLint
sofyakurilova Jul 22, 2024
42cf14e
Fix script
jboddey Jul 22, 2024
e9c1c2b
Merge branch 'feature/ui_build' of /~https://github.com/google/testrun …
jboddey Jul 22, 2024
95b988c
Modify scripts
jboddey Jul 22, 2024
066750f
Improve scripts
jboddey Jul 22, 2024
877b6ec
Fix copy command
jboddey Jul 22, 2024
106a43f
Try installing package
jboddey Jul 22, 2024
9fb8063
Depend on package job
jboddey Jul 22, 2024
d6f3bc6
Add sudo
jboddey Jul 22, 2024
8b745f3
Add sudo
jboddey Jul 22, 2024
41cf179
Troubleshoot
jboddey Jul 23, 2024
b78eec7
Fix workflow
jboddey Jul 23, 2024
725ee58
Checkout source for prepare command
jboddey Jul 23, 2024
21b3861
Merge branch 'dev' into feature/ui_build
jboddey Jul 24, 2024
48ecbe1
Merge branch 'dev' into feature/ui_build
jboddey Jul 25, 2024
ae17556
Built ui within a container
jboddey Jul 25, 2024
c4e4e63
Merge branch 'dev' into feature/ui_build
jboddey Jul 25, 2024
e64f4a7
Merge branch 'dev' into feature/ui_build
jboddey Jul 30, 2024
27332d1
Mount src files for build instead of static copy in build image
jhughesbiot Jul 30, 2024
1225a87
Merge branch 'dev' into feature/ui_build
jhughesbiot Jul 30, 2024
e009e9e
Attempt to fix actions
jhughesbiot Jul 30, 2024
b596780
Remove manual build container cleanup methods
jhughesbiot Jul 30, 2024
349fb4a
undo failed attempts to fix actions
jhughesbiot Jul 30, 2024
2096751
Fix path
jhughesbiot Jul 30, 2024
27f6fd0
Remove -it flag
jboddey Jul 31, 2024
21686a3
Merge branch 'dev' into feature/ui_build
jboddey Jul 31, 2024
c8360d4
Merge branch 'dev' into feature/ui_build
jboddey Aug 1, 2024
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
10 changes: 7 additions & 3 deletions cmd/build
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ fi
# Builds all docker images
echo Building docker images

# Build user interface
echo Building user interface
if docker build -t test-run/ui -f modules/ui/ui.Dockerfile . ; then
# Check if UI has already been built (not if -l was used during install)
if [ ! -d "modules/ui/dist" ]; then
cmd/build_ui
fi

# Build UI image
if docker build -t testrun/ui -f modules/ui/ui.Dockerfile . ; then
jboddey marked this conversation as resolved.
Show resolved Hide resolved
echo Successully built the user interface
else
echo An error occured whilst building the user interface
Expand Down
26 changes: 26 additions & 0 deletions cmd/build_ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash -e

# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build the UI
echo Building user interface
cd modules/ui

# Run UI build commands
npm install
npm run build

# Return back to root dir
cd ../..
13 changes: 11 additions & 2 deletions cmd/package
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

# Creates a package for Testrun

# Check that user is not root
if [[ "$EUID" == 0 ]]; then
echo "Must not run as root. Use cmd/package as regular user"
exit 1
fi

MAKE_SRC_DIR=make
MAKE_CONTROL_DIR=make/DEBIAN/control

Expand All @@ -25,10 +31,10 @@ version=$(grep -R "Version: " $MAKE_CONTROL_DIR | awk '{print $2}')
# Replace invalid characters
version="${version//./_}"

# Delete existing make files
rm -rf $MAKE_SRC_DIR/usr
echo Building package for testrun v${version}

# Delete existing make files
echo Cleaning up previous build files
rm -rf $MAKE_SRC_DIR/usr

# Copy testrun script to /bin
Expand Down Expand Up @@ -63,6 +69,9 @@ cp -r local/root_certs $MAKE_SRC_DIR/usr/local/testrun/local/
# Copy framework and modules into testrun folder
cp -r {framework,modules} $MAKE_SRC_DIR/usr/local/testrun

# Build the UI
cmd/build_ui

# Build .deb file
dpkg-deb --build --root-owner-group make

Expand Down
2 changes: 1 addition & 1 deletion cmd/prepare
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
echo Installing system dependencies

# Install system dependencies
sudo apt-get update && sudo apt-get install openvswitch-common openvswitch-switch python3 libpangocairo-1.0-0 ethtool
sudo apt-get update && sudo apt-get install openvswitch-common openvswitch-switch python3 libpangocairo-1.0-0 ethtool npm

echo Finished installing system dependencies
4 changes: 2 additions & 2 deletions framework/python/src/core/testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _load_test_reports(self, device):
'test',
device.mac_addr.replace(':',''),
'report.json')

if not os.path.isfile(report_json_file_path):
# Revert to pre 1.3 file path
report_json_file_path = os.path.join(
Expand Down Expand Up @@ -463,7 +463,7 @@ def start_ui(self):

try:
client.containers.run(
image='test-run/ui',
image='testrun/ui',
auto_remove=True,
jboddey marked this conversation as resolved.
Show resolved Hide resolved
name='tr-ui',
hostname='testrun.io',
Expand Down
5 changes: 3 additions & 2 deletions modules/ui/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "1000kb",
"maximumWarning": "1500kb",
"maximumError": "3000kb"
},
{
Expand Down Expand Up @@ -93,6 +93,7 @@
}
},
"cli": {
"schematicCollections": ["@angular-eslint/schematics"]
"schematicCollections": ["@angular-eslint/schematics"],
"analytics": false
}
}
11 changes: 2 additions & 9 deletions modules/ui/ui.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Image name: test-run/ui
FROM node@sha256:ffebb4405810c92d267a764b21975fb2d96772e41877248a37bf3abaa0d3b590 as build

WORKDIR /modules/ui
COPY modules/ui/ /modules/ui
RUN npm install
RUN npm run build

# Image name: testrun/ui
FROM nginx@sha256:4c0fdaa8b6341bfdeca5f18f7837462c80cff90527ee35ef185571e1c327beac

COPY --from=build /modules/ui/dist/ /usr/share/nginx/html
COPY /modules/ui/dist/ /usr/share/nginx/html

EXPOSE 8080

Expand Down