Skip to content

Commit

Permalink
Fix npm install race in CI
Browse files Browse the repository at this point in the history
MathQuill's CI system starts a server in the background by running
`make server`. Previously, this would run `npm install`, which could
race later ci steps that were attempting to use node modules.

Fix this by adding a NO_INSTALL environment variable that tells the
server not to automatically install npm dependencies.
  • Loading branch information
jwmerrill committed Sep 27, 2023
1 parent 47710a7 commit 49bba38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
# https://david263a.wordpress.com/2015/04/18/fixing-safari-cant-connect-to-localhost-issue-when-using-sauce-labs-connect-tunnel/
# https://support.saucelabs.com/customer/portal/questions/14368823-requests-to-localhost-on-microsoft-edge-are-failing-over-sauce-connect
- run:
command: PORT=8000 make server
command: PORT=8000 NO_INSTALL=1 make server
background: true
# Wait for tunnel to be ready (`make server` is much faster, no need to wait for it)
- run: |-
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,13 @@ $(BASIC_CSS): $(CSS_SOURCES) $(NODE_MODULES_INSTALLED) $(BUILD_DIR_EXISTS)
perl -pi -e s/{VERSION}/v$(VERSION)/ $@

$(NODE_MODULES_INSTALLED): package.json
ifdef NO_INSTALL
@echo "Skipping npm install because NO_INSTALL environment variable is set."
else
test -e $(NODE_MODULES_INSTALLED) || rm -rf ./node_modules/ # robust against previous botched npm install
NODE_ENV=development npm install
touch $(NODE_MODULES_INSTALLED)
endif

$(BUILD_DIR_EXISTS):
mkdir -p $(BUILD_DIR)
Expand Down

0 comments on commit 49bba38

Please sign in to comment.