From 585b2ff98e2a753c2acec3bb1920f2c7cfbc9374 Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Mon, 5 Mar 2018 16:04:41 -0800 Subject: [PATCH 1/3] Creates platform-specific packaging Makefile targets Renames deb package target "build" -> "build-deb" Creates "build-dmg" for distribution under macOS. Updates accordingly. --- Makefile | 8 ++++++-- README.md | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index a2d8c31..fd70417 100644 --- a/Makefile +++ b/Makefile @@ -15,14 +15,18 @@ clean: docker-clean ## Removes all build-related artifacts docker-build: ## Builds Docker image for creating Sunder Linux deb packages docker build . --build-arg=UID=$(UID) -t sunder-build -.PHONY: build -build: docker-build ## Builds Sunder Debian packages for Linux +.PHONY: build-deb +build-deb: docker-build ## Builds Sunder Debian packages for Linux docker volume create fpf-sunder-node && \ docker run \ -v $(PWD):/sunder \ -v fpf-sunder-node:/sunder/node_modules \ sunder-build:latest +.PHONY: build-dmg +build-dmg: ## Builds Sunder DMG and app bundle for macOS (requires macOS) + npm run dist + .PHONY: docker-clean docker-clean: ## Purges Docker images related to building Sunder deb packages tools/docker-clean diff --git a/README.md b/README.md index 5df0964..9dd949f 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ prerequisites for the build environment: Once you have the prerequisites installed, you should be able to ``` -make build +make build-deb ``` Packages will be found in `dist/`. @@ -45,7 +45,7 @@ Packages will be found in `dist/`. To package up the app for your current platform (e.g. OS X): ``` -npm run dist +make build-dmg ``` Note that this will run `build-app` so there's no need to run that beforehand. From 776bb40d2e31bf3f143540604d199327fb47155e Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Mon, 5 Mar 2018 16:18:58 -0800 Subject: [PATCH 2/3] Creates testing-related Makefile targets Updates docs in README. Fairly straightforward, merely chaining the targets as necessary to facilitate easy iterative testing. Simplifies CI logic by bundling all test-related actions under "make test". --- Makefile | 15 +++++++++++++++ README.md | 6 ++++-- circle.yml | 5 +---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index fd70417..0b8e518 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,21 @@ docs: docs-clean ## Runs livereload environment for local documentation editing # Spins up livereload environment for editing; blocks. sphinx-autobuild docs/ docs/_build/html +.PHONY: build-app +build-app: ## Packages Electron app locally via webpack for development and testing + npm run build-app + +.PHONY: test-unit +test-unit: ## Runs unit tests in local dev env + npm run test + +.PHONY: test-e2e +test-e2e: build-app ## Runs end-to-end integration tests local dev env + npm run test-e2e + +.PHONY: test +test: test-unit test-e2e ## Runs all unit and integration tests + # Explanation of the below shell command should it ever break. # 1. Set the field separator to ": ##" to parse lines for make targets. # 2. Check for second field matching, skip otherwise. diff --git a/README.md b/README.md index 9dd949f..ec5b402 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,11 @@ If you get an error from `node-gyp` during `npm install`, note that it expects ` ### Testing -- To run the unit tests: `npm run test` +- To run the unit tests: `make test-unit` - For development you might enjoy the continuously updating tests: `npm run test-watch` -- The end-to-end integration suite can be run with `npm run test-e2e`. Note that this runs agains built code, so an `npm run build-app` is prudent and/or necessary. +- The end-to-end integration suite can be run with `make test-e2e`. + Note that this runs agains built code, so `npm run build-app` will run beforehand. +- To run all tests, use `make test`. Again, `npm run build-app` will run before the integration tests. ## Building diff --git a/circle.yml b/circle.yml index 9211c35..fa3b01e 100644 --- a/circle.yml +++ b/circle.yml @@ -3,8 +3,5 @@ machine: version: 8.2.0 test: - pre: - - npm run build-app override: - - npm run test - - npm run test-e2e + - make test From 78b139a688c4ec8a1a7b15e6330d256df6e350f5 Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Tue, 6 Mar 2018 12:47:54 -0800 Subject: [PATCH 3/3] Installs node_modules as dependency if missing The `npm install` task takes ~23s even when no changes are required, so let's not delay the quick test runs (e.g. 3s for `make test-unit`) with unnecessary npm calls. Instead, we'll check for existence of the `node_modules/` directory locally, and install the npm modules only if it's missing. That'll still support automatic integration with the `make clean` target for clean builds. --- Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0b8e518..4a7d643 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,14 @@ build-deb: docker-build ## Builds Sunder Debian packages for Linux -v fpf-sunder-node:/sunder/node_modules \ sunder-build:latest +.PHONY: npm-install-init +npm-install-init: ## Installs npm modules locally only if node_modules/ absent + if [ ! -d node_modules ] ; then \ + npm install ; \ + fi + .PHONY: build-dmg -build-dmg: ## Builds Sunder DMG and app bundle for macOS (requires macOS) +build-dmg: npm-install-init ## Builds Sunder DMG and app bundle for macOS (requires macOS) npm run dist .PHONY: docker-clean @@ -50,15 +56,15 @@ docs: docs-clean ## Runs livereload environment for local documentation editing sphinx-autobuild docs/ docs/_build/html .PHONY: build-app -build-app: ## Packages Electron app locally via webpack for development and testing +build-app: npm-install-init ## Packages Electron app locally via webpack for development and testing npm run build-app .PHONY: test-unit -test-unit: ## Runs unit tests in local dev env +test-unit: npm-install-init ## Runs unit tests in local dev env npm run test .PHONY: test-e2e -test-e2e: build-app ## Runs end-to-end integration tests local dev env +test-e2e: npm-install-init build-app ## Runs end-to-end integration tests local dev env npm run test-e2e .PHONY: test