Skip to content

Commit

Permalink
nginx: skip frontend build in tests
Browse files Browse the repository at this point in the history
This significantly decreases test turnaround time.

Local results (`./run-tests; time ./run-tests.sh`):

* with this PR: 14 seconds
* without this: 90 seconds

Cons:

* complicates build script (`build-frontend.sh`)
  • Loading branch information
alxndrsn committed Dec 3, 2024
1 parent 2d95a61 commit d3452e7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
18 changes: 16 additions & 2 deletions files/prebuild/build-frontend.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/bash -eu

cd client
npm clean-install --no-audit --fund=false --update-notifier=false
npm run build

if [[ ${SKIP_FRONTEND_BUILD-} != "" ]]; then
echo "[build-frontend] Skipping frontend build."

# Create minimal fake frontend to allow tests to pass:
mkdir -p dist
echo > dist/blank.html
echo > dist/favicon.ico
echo > dist/index.html '<div id="app"></div>'

exit
else
npm clean-install --no-audit --fund=false --update-notifier=false
npm run build
fi
2 changes: 2 additions & 0 deletions nginx.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ RUN apt-get update \

COPY ./ ./
RUN files/prebuild/write-version.sh

ARG SKIP_FRONTEND_BUILD
RUN files/prebuild/build-frontend.sh


Expand Down
2 changes: 2 additions & 0 deletions test/nginx.test.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ services:
build:
context: ..
dockerfile: nginx.dockerfile
args:
SKIP_FRONTEND_BUILD: true
depends_on:
- service
- enketo
Expand Down

0 comments on commit d3452e7

Please sign in to comment.