From 307ce47fd57c2bea3d573293e03abfed4b3cc5a9 Mon Sep 17 00:00:00 2001 From: Webb Scales <7795764+webbnh@users.noreply.github.com> Date: Thu, 23 Feb 2023 10:01:38 -0500 Subject: [PATCH] Add a Makefile for building and testing the Dashboard (#3273) Add a Makefile for the Pbench Dashboard, to allow it to be built (and re-built) only as needed and to provide an encapsulated interface for running lint and unit tests, etc. The build.sh script is changed to use make to clear and install the Dashboard dependences, to run lint, and to run unit tests. And, a new make invocation is added after we build the Server and Agent RPMs to also build the Dashboard deployment. Also, jenkins/runlocal is modified to build the Dashboard, as well. --- build.sh | 10 +++++----- dashboard/Makefile | 43 +++++++++++++++++++++++++++++++++++++++++++ jenkins/runlocal | 3 +++ 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 dashboard/Makefile diff --git a/build.sh b/build.sh index 281a17ae1c..3b6c597dc3 100755 --- a/build.sh +++ b/build.sh @@ -21,15 +21,14 @@ fi # Install the Dashboard dependencies, including the linter's dependencies and # the unit test dependencies. First, remove any existing Node modules and # package-lock.json to ensure that we install the latest. -mkdir -p ${HOME}/.config -( cd dashboard && rm -rf node_modules package-lock.json && npm install ) +make -C dashboard clean node_modules # Test for code style and lint (echo the commands before executing them) set -x black --check . flake8 . isort --check . -( cd dashboard && npx eslint --max-warnings 0 "src/**" ) +make -C dashboard run_lint # We need to invoke the alembic check with host networking so that it can reach # the PostgreSQL pod it creates. EXTRA_PODMAN_SWITCHES="--network host" jenkins/run tox -e alembic-migration check @@ -37,12 +36,13 @@ set +x # Run unit tests tox # Agent and Server unit tests and legacy tests -( cd dashboard && CI=true npm test ) # Dashboard unit tests +make -C dashboard run_unittests # Dashboard unit tests -# Build RPMS for the Server and Agent +# Build RPMS for the Server and Agent and build the Dashboard deployment make -C server/rpm distclean # Cleans all RPMs, both Server and Agent. make -C server/rpm ci make -C agent/rpm ci +make -C dashboard build # Display our victory ls -l ${HOME}/rpmbuild*/RPMS/noarch/* diff --git a/dashboard/Makefile b/dashboard/Makefile new file mode 100644 index 0000000000..fda8b1f9ca --- /dev/null +++ b/dashboard/Makefile @@ -0,0 +1,43 @@ +# +# A Makefile for building the Pbench Dashboard deployment for use in Pbench +# Server functional test and Staging/Production deployments. +# +# This makefile defines the following targets: +# +# all (the default): runs lint and unit tests and then builds +# the Pbench Dashboard deployment +# build: builds the Pbench Dashboard deployment +# clean: removes the artifacts created by the other targets +# run_lint: runs the Javascript linter +# run_unittests: runs the Dashboard unit tests +# + +# This is the list of all the subdirectories of the `dashboard` directory which +# contain "source" files for the Dashboard (Javascript, images, style sheets, +# HTML, et al.) -- anything which, if changed, should prompt a new build -- and +# the corresponding list of those files. +SRCDIRS := public src +FILES := $(shell find ${SRCDIRS} -type f) + +all: run_lint run_unittests build + +build: package-lock.json node_modules ${FILES} + mkdir -p build + npm run build + +run_lint: package-lock.json node_modules + npx eslint --max-warnings 0 "src/**" + +run_unittests: package-lock.json node_modules + CI=true npm test + +package-lock.json node_modules &: ${HOME}/.config package.json + npm install + +${HOME}/.config: + mkdir -p ${HOME}/.config + +clean: + rm -rf package-lock.json node_modules build + +.PHONY: all clean run_lint run_unittests diff --git a/jenkins/runlocal b/jenkins/runlocal index bb5f9d1ea7..47a7b1d976 100755 --- a/jenkins/runlocal +++ b/jenkins/runlocal @@ -25,6 +25,9 @@ make -C server/rpm clean rpm export RPM_PATH=${HOME}/rpmbuild/RPMS/noarch/pbench-server-*.rpm ls -ld ${RPM_PATH} +# Create a Pbench Dashboard deployment +WORKSPACE_TMP=${WORKSPACE_TMP:-${HOME}} jenkins/run make -C dashboard clean build + source /etc/os-release if [[ -z ${BASE_IMAGE} ]]; then