Skip to content

Commit

Permalink
Add a Makefile for building and testing the Dashboard (#3273)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
webbnh authored Feb 23, 2023
1 parent cdeecc0 commit 307ce47
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
10 changes: 5 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ 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
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/*
43 changes: 43 additions & 0 deletions dashboard/Makefile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions jenkins/runlocal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 307ce47

Please sign in to comment.