Skip to content

Instantly share code, notes, and snippets.

@d3vAdv3ntur3s
Created July 31, 2021 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d3vAdv3ntur3s/a7d9ec0ce7608754e0a763128d6a2dfc to your computer and use it in GitHub Desktop.
Save d3vAdv3ntur3s/a7d9ec0ce7608754e0a763128d6a2dfc to your computer and use it in GitHub Desktop.
Example Makefile
SHELL:=/usr/bin/env bash #default shell used
MAKEFLAGS += --silent --jobs 10 #don't echo commands and parallelise
# Default task executed when running with make command only no args
default: help
#src: https://victoria.dev/blog/how-to-create-a-self-documenting-makefile/
help: ## Show this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
###################
# Development #
###################
run-backend: ## Run backend Node JS App locally
NODE_ENV=dev npm --prefix backend start
run-frontend: ## Run frontend React app in Dev mode locally
NODE_ENV=dev npm --prefix frontend start
run-frontend-storybook: ## Run frontend story book for demonstrating components
npm --prefix frontend storybook
###################
# Testing #
###################
test-all: test-backend test-frontend test-e2e ## Test frontend, backend, e2e tests
test-backend: ## Run tests of the backend via npm
NODE_ENV=test npm --prefix backend test;
test-frontend: ## Run tests of the frontend via npm
NODE_ENV=test npm --prefix frontend run test-ci;
test-e2e: ## Run headless browser tests of the locally running frontend via Cypress
CYPRESS_BASE_URL=http://localhost:8080/ npm --prefix e2e run cy:run
# targets don't produce any output
.PHONY: run-backend run-frontend run-frontend-storybook
.PHONY: test-all test-backend test-frontend test-e2e
# https://makefiletutorial.com for useful tips and help with make files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment