Skip to content

Commit

Permalink
Merge pull request #1633 from mstruebing/make
Browse files Browse the repository at this point in the history
TASK: Exchange yarn with make as build tool
  • Loading branch information
mstruebing authored Feb 13, 2018
2 parents 0c45995 + 025df1e commit a6e5057
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 42 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ indent_size = 2
[*.{md}]
indent_size = 2
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
3 changes: 1 addition & 2 deletions Build/Jenkins/update-neos-ui-compiled.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ npm install -g yarn
GIT_SHA1=`git rev-parse HEAD`
GIT_TAG=`git describe --exact-match HEAD 2>/dev/null || true`

yarn install
yarn build
make build-production

rm -Rf tmp_compiled_pkg
git clone git@github.com:neos/neos-ui-compiled.git tmp_compiled_pkg
Expand Down
3 changes: 1 addition & 2 deletions Build/TravisCi/InstallScripts/IntegrationTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ cd Packages/Application/Neos.Neos.Ui

# Since all environments depend on the node dependencies, install and
# afterwards prune them to remove extranous packages from previous/cached runs.
yarn install
yarn build
make build-production

# Deactivate the previous enabled handling of hidden files with the `mv` command.
shopt -u dotglob
2 changes: 1 addition & 1 deletion Build/TravisCi/Scripts/CodeStyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ set -e
# This file serves as the script for the TravisCI `CodeStyle` TEST_SUITE environment.
# The script will be executed in the package working directory.
#
yarn lint && yarn lint:editorconfig
make lint
2 changes: 1 addition & 1 deletion Build/TravisCi/Scripts/IntegrationTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ set -e
# The script will be executed in the package working directory.
#

yarn test:e2e
make test-e2e
2 changes: 1 addition & 1 deletion Build/TravisCi/Scripts/UnitTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ set -e
#

# Execute the unit tests.
yarn test
make test
160 changes: 160 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
################################################################################
#
# 888b 88 88888888888 ,ad8888ba, ad88888ba
# 8888b 88 88 d8"' `"8b d8" "8b
# 88 `8b 88 88 d8' `8b y8,
# 88 `8b 88 88aaaaa 88 88 `y8aaaaa,
# 88 `8b 88 88""""" 88 88 `"""""8b,
# 88 `8b 88 88 y8, ,8p `8b
# 88 `8888 88 y8a. .a8p y8a a8p
# 88 `888 88888888888 `"Y8888Y"' "Y88888P"
#
# <Makefile>
#
# 88 88 88
# 88 88 88
# 88 88 88
# 88 88 88
# 88 88 88
# 88 88 88
# Y8a. .a8P 88
# `"Y8888Y"' 88
#
#
################################################################################


################################################################################
# Variables
################################################################################


# Add node_modules and composer binaries to $PATH
export PATH := ./node_modules/.bin:./bin:$(PATH)


################################################################################
# Setup
################################################################################


check-requirements:
@which yarn &>/dev/null || \
(echo yarn is not installed: https://github.com/yarnpkg/yarn && false)

install:
yarn install

setup: check-requirements install build
@echo Please remember to set frontendDevelopmentMode \
to true in your Settings.yaml.
@echo
@echo 'Neos:'
@echo ' Neos:'
@echo ' Ui:'
@echo ' frontendDevelopmentMode: true'


################################################################################
# Builds
################################################################################


# TODO: figure out how to pass a parameter to other targets to reduce redundancy
build:
NEOS_BUILD_ROOT=$(shell pwd) webpack --progress --colors

build-watch:
NEOS_BUILD_ROOT=$(shell pwd) webpack --progress --colors --watch

build-watch-poll:
NEOS_BUILD_ROOT=$(shell pwd) webpack \
--progress --colors --watch-poll --watch

# clean anything before building for production just to be sure
build-production: clean install
cross-env NODE_ENV=production NEOS_BUILD_ROOT=$(shell pwd) \
webpack --progress --colors


################################################################################
# Code Quality
################################################################################


storybook:
lerna run --scope @neos-project/react-ui-components start

test:
lerna run test --concurrency 1

test-e2e:
yarn run testcafe chrome:headless Tests/IntegrationTests/* \
--selector-timeout=30000 --assertion-timeout=30000

lint: lint-js lint-editorconfig

lint-js:
lerna run lint --concurrency 1


lint-editorconfig:
editorconfig-checker \
--exclude-regexp 'LICENSE|\.vanilla\-css$$|banner\.js$$' \
--exclude-pattern \
'./{README.md,**/*.snap,**/*{fontAwesome,Resources}/**/*}'


################################################################################
# Releasing
################################################################################


called-with-version:
ifeq ($(VERSION),)
@echo No version information given.
@echo Please run this command like this:
@echo VERSION=1.0.0 make release
@false
endif

bump-version: called-with-version
lerna publish \
--skip-git --exact --repo-version=$(VERSION) \
--yes --force-publish --skip-npm
./Build/createVersionFile.sh

publish-npm: called-with-version
lerna publish --skip-git --exact --repo-version=$(VERSION) \
--yes --force-publish

tag: called-with-version
git tag $(VERSION)

# make a clean build from scratch
# and make sure that every lint and test stage is running through
release: called-with-version check-requirements \
build-production \
lint lint-editorconfig \
test test-e2e \
bump-version publish-npm tag
@echo
@echo
@echo
@echo '####################################################################'
@echo
@echo You should look at the git diff carefully and commit your changes
@echo
@echo Then push your changes into the master and trigger the jenkins build.


################################################################################
# Misc
################################################################################


clean:
rm -Rf node_modules; rm -rf packages/*/node_modules


.PHONY: $@
49 changes: 26 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ In order to start contributing, follow the following steps:

1) Ensure you have the `dev-master` version installed (see above).

2) We require [Chrome](https://www.google.com/chrome/browser/desktop/index.html) as well as the `yarn`(`<sudo> npm install -g yarn`, https://yarnpkg.com/en/) command to be installed on your system.
2) We require [Chrome](https://www.google.com/chrome/browser/desktop/index.html) as well as the `yarn`(https://yarnpkg.com/en/) command and GNU Make(https://www.gnu.org/software/make/) to be installed on your system.

3) Inside `Configuration/Settings.yaml`, set the following property for disabling the pre-compiled files:

Expand All @@ -65,17 +65,7 @@ In order to start contributing, follow the following steps:
4) Run the initialization script:

```
cd Packages/Application/Neos.Neos.Ui
source Build/init.sh # do NodeJS stuff ie. install npm deps, copy githooks
yarn build # build everything using webpack (you might see some webpack warnings, but you can ignore them)
```

Alternatively, you can also run the initialization by hand; which will mean:
```
npm install -g yarn
yarn
yarn run build:ui:watch
make setup
```

5) Get an overview about the codebase. We've recorded [an introduction on YouTube](https://www.youtube.com/watch?v=RYBUS5Nxxxk) which
Expand All @@ -85,22 +75,23 @@ In order to start contributing, follow the following steps:
#### Development commands
| Command | Description |
| --------------- | ------------------------------ |
| `yarn clear` | delete all node_modules in every subdirectory. |
| `yarn build:ui` | Builds the ui via webpack. |
| `yarn build` | Runs `build:dev` optimised for production. |
| `yarn build:ui:watch` | Watches the source files for changes and runs a build:ui in case. |
| `yarn build:ui:watch-poll` | Watches (and polls) the source files on a file share. Should preferably be used when working an a VM for example. |
| `yarn start-storybook` | Starts the storybook server on port 9001. |
| `yarn lint` | Lints all source files. |
| `yarn test` | Executes `yarn lint` to trigger tests via ava. |
| `yarn test:e2e` | Executes integration tests. |
| `make clean` | delete all node_modules in every subdirectory. |
| `make build` | Runs the development build. |
| `make build-watch` | Watches the source files for changes and runs a build in case. |
| `make build-watch-poll` | Watches (and polls) the source files on a file share. Should preferably be used when working an a VM for example. |
| `make storybook` | Starts the storybook server on port 9001. |
| `make lint` | Executes `make lint-js` and `make lint-editorconfig`. |
| `make lint-js` | Runs test in all subpackages via lerna. |
| `make lint-editorconfig` | Tests if all files respect the `.editorconfig`. |
| `make test` | Executes the test on all source files. |
| `make test-e2e` | Executes integration tests. |

#### Code style
Our code style is based upon `xo`, with one big difference - We use 4 spaces instead of tabs, to align our code style a bit with the PSR-2 standard for our PHP codebase. To lint the code, execute `yarn lint` in your shell.
Our code style is based upon `xo`, with one big difference - We use 4 spaces instead of tabs, to align our code style a bit with the PSR-2 standard for our PHP codebase. To lint the code, execute `make lint` in your shell.

#### Writing unit tests
The unit tests are executed with [jest](https://facebook.github.io/jest/).
To run the unit tests, execute `yarn test` in your shell.
To run the unit tests, execute `make test` in your shell.

Adding unit tests is fairly simple, just create a file on the same tree level as your changed/new feature, named `[filename].spec.js` and karma will execute all tests found within the spec file, other than that, just orient yourself on the existing tests.

Expand All @@ -111,6 +102,18 @@ Use `it.only(() => {})` and `describe.only(() => {})` if you want to run a speci
For end to end testing we use the headless chrome. So it is mandatory to install the chrome browser for integration tests.
Since Chrome 59 the headless mode is integrated. So please install a Chome 59 or higher to execute the end to end tests.

#### Releasing
Run `VERSION=<VERSION_YOU_WANT_TO_RELEASE> make release`
e.g `VERSION=1.0.2 make release`.
This checks if you set the environment variable, reinstall all node_modules,
builds a production release runs `make lint`, `make test` and `make test-e2e`,
bumps the version locally via lerna and publish the version as a new npm tag.
After that you should carefully revisit your local changes, commit then and
open a pull request on Github. When travis runs through merge it an tag a new
release on Github.

After that trigger jenkins with the new version.


## License
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Expand Down
12 changes: 0 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@
"description": "Root package + shared dev dependencies for @neos-project packages, managed by lernaJS",
"license": "GNU GPLv3",
"private": true,
"scripts": {
"clear": "rm -Rf node_modules; rm -rf packages/*/node_modules",
"build": "./Build/createVersionFile.sh && cross-env NODE_ENV=production yarn build:ui",
"build:ui": "NEOS_BUILD_ROOT=$(pwd) webpack --progress --colors",
"build:ui:watch": "yarn build:ui -- --watch",
"build:ui:watch-poll": "yarn run build:ui -- --watch-poll --watch",
"start-storybook": "lerna run --scope @neos-project/react-ui-components start",
"test": "lerna run test --concurrency 1",
"test:e2e": "yarn run testcafe chrome:headless Tests/IntegrationTests/* --selector-timeout=30000 --assertion-timeout=30000",
"lint": "lerna run lint --concurrency 1",
"lint:editorconfig": "editorconfig-checker --exclude-regexp 'LICENSE|\\.vanilla\\-css$|banner\\.js$' --exclude-pattern './{README.md,**/*.snap,**/*{fontAwesome,Resources}/**/*}'"
},
"resolutions": {
"moment": "^2.20.1"
},
Expand Down

0 comments on commit a6e5057

Please sign in to comment.