Skip to content

Commit

Permalink
Install packages only when relevant files change (#3606)
Browse files Browse the repository at this point in the history
* Run yarn install only when relevant files change

* Remove leftover down.full Makefile target

We removed docker-compose.full.yml some time ago.
  • Loading branch information
rakyi authored May 16, 2024
1 parent daf5033 commit 8c7af45
Showing 1 changed file with 17 additions and 33 deletions.
50 changes: 17 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ifneq (,$(wildcard ./.env))
export
endif

.PHONY: help up up.full down down.full refresh refresh.wp refresh.full migrate svgtest itsJustJavascript
.PHONY: help up up.full down refresh refresh.wp refresh.full migrate svgtest itsJustJavascript

help:
@echo 'Available commands:'
Expand All @@ -36,7 +36,6 @@ help:
@echo
@echo ' GRAPHER + CLOUDFLARE (staff-only)'
@echo ' make up.full start dev environment via docker-compose and tmux'
@echo ' make down.full stop any services still running'
@echo ' make sync-images sync all images from the remote master'
@echo ' make update.chart-entities update the charts_x_entities join table'
@echo ' make reindex reindex (or initialise) search in Algolia'
Expand All @@ -49,11 +48,10 @@ help:

up: export DEBUG = 'knex:query'

up: require create-if-missing.env ../owid-content tmp-downloads/owid_metadata.sql.gz
up: require create-if-missing.env ../owid-content tmp-downloads/owid_metadata.sql.gz node_modules
@make validate.env
@make check-port-3306
@echo '==> Building grapher'
yarn install
yarn lerna run build

@echo '==> Starting dev environment'
Expand All @@ -76,11 +74,10 @@ up: require create-if-missing.env ../owid-content tmp-downloads/owid_metadata.sq
set -g mouse on \
|| make down

up.devcontainer: create-if-missing.env.devcontainer tmp-downloads/owid_metadata.sql.gz
up.devcontainer: create-if-missing.env.devcontainer tmp-downloads/owid_metadata.sql.gz node_modules
@make validate.env
@make check-port-3306
@echo '==> Building grapher'
yarn install
yarn lerna run build

@echo '==> Starting dev environment'
Expand All @@ -100,12 +97,11 @@ up.devcontainer: create-if-missing.env.devcontainer tmp-downloads/owid_metadata.

up.full: export DEBUG = 'knex:query'

up.full: require create-if-missing.env.full ../owid-content tmp-downloads/owid_metadata.sql.gz
up.full: require create-if-missing.env.full ../owid-content tmp-downloads/owid_metadata.sql.gz node_modules
@make validate.env.full
@make check-port-3306

@echo '==> Building grapher'
yarn install
yarn lerna run build

@echo '==> Starting dev environment'
Expand All @@ -127,11 +123,11 @@ up.full: require create-if-missing.env.full ../owid-content tmp-downloads/owid_m
bind X kill-pane \; \
bind Q kill-server \; \
set -g mouse on \
|| make down.full
|| make down

migrate:
migrate: node_modules
@echo '==> Running DB migrations'
yarn && yarn buildLerna && yarn runDbMigrations
yarn buildLerna && yarn runDbMigrations

refresh:
@echo '==> Downloading chart data'
Expand All @@ -143,9 +139,9 @@ refresh:
@echo '!!! If you use ETL, wipe indicators from your R2 staging with `rclone delete r2:owid-api-staging/[yourname]/ ' \
'--fast-list --transfers 32 --checkers 32 --verbose`'

refresh.pageviews:
refresh.pageviews: node_modules
@echo '==> Refreshing pageviews'
yarn && yarn refreshPageviews
yarn refreshPageviews

sync-images: sync-images.preflight-check
@echo '==> Syncing images to R2'
Expand All @@ -165,10 +161,6 @@ down:
@echo '==> Stopping services'
docker compose -f docker-compose.grapher.yml down

down.full:
@echo '==> Stopping services'
docker compose -f docker-compose.full.yml down

require:
@echo '==> Checking your local environment has the necessary commands...'
@which docker >/dev/null 2>&1 || (echo "ERROR: docker compose is required."; exit 1)
Expand Down Expand Up @@ -223,19 +215,18 @@ tmp-downloads/owid_metadata.sql.gz:
@echo '==> Downloading metadata'
./devTools/docker/download-grapher-metadata-mysql.sh

deploy:
deploy: node_modules
@echo '==> Starting from a clean slate...'
rm -rf itsJustJavascript

@echo '==> Building...'
yarn
yarn lerna run build --skip-nx-cache
yarn run tsc -b

@echo '==> Deploying...'
yarn buildAndDeploySite live

stage:
stage: node_modules
@if [[ ! "$(STAGING)" ]]; then \
echo 'ERROR: must set the staging environment'; \
echo ' e.g. STAGING=halley make stage'; \
Expand All @@ -246,16 +237,14 @@ stage:
rm -rf itsJustJavascript

@echo '==> Building...'
yarn
yarn lerna run build
yarn run tsc -b

@echo '==> Deploying to $(STAGING)...'
yarn buildAndDeploySite $(STAGING)

test:
test: node_modules
@echo '==> Linting'
yarn
yarn run eslint
yarn lerna run build
yarn lerna run buildTests
Expand All @@ -266,32 +255,27 @@ test:
@echo '==> Running tests'
yarn run jest

dbtest:
dbtest: node_modules
@echo '==> Building'
yarn
yarn buildTsc

@echo '==> Running db test script'
./db/tests/run-db-tests.sh

lint:
lint: node_modules
@echo '==> Linting'
yarn
yarn run eslint

check-formatting:
check-formatting: node_modules
@echo '==> Checking formatting'
yarn
yarn testPrettierAll

format:
format: node_modules
@echo '==> Fixing formatting'
yarn
yarn fixPrettierAll

unittest:
unittest: node_modules
@echo '==> Running tests'
yarn
yarn run jest --all

../owid-grapher-svgs:
Expand Down

0 comments on commit 8c7af45

Please sign in to comment.