-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure development environment with hot reloading
- Add docs (CONTRIBUTING.md) - Add command: 'make set-override' - Add 'docker-compose.override.yml' to override sourced 'docker-compose.yml' - Add 'watcher' command - Change 'docker-entrypoint.sh' to: - (in Linux) Accept 'root' user, and swipe to the expected 'superset' user. - Serve the UI from 'webpack-dev-server' instead of 'flask'. Signed-off-by: David Pordomingo <[email protected]>
- Loading branch information
1 parent
345c08c
commit 3110ec6
Showing
6 changed files
with
256 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Contribution Guidelines | ||
|
||
As all source{d} projects, this project follows the | ||
[source{d} Contributing Guidelines](https://github.com/src-d/guide/blob/master/engineering/documents/CONTRIBUTING.md). | ||
|
||
|
||
# Additional Contribution Guidelines | ||
|
||
In addition to the [source{d} Contributing Guidelines](https://github.com/src-d/guide/blob/master/engineering/documents/CONTRIBUTING.md), | ||
this project follows the following guidelines. | ||
|
||
**Content:** | ||
|
||
- [Changelog](#changelog) | ||
- [Run source{d} CE For Development With Hot Reloading](#run-source-d-ce-for-development-with-hot-reloading) | ||
|
||
|
||
## Changelog | ||
|
||
This project lists the important changes between releases in the | ||
[`CHANGELOG.md`](CHANGELOG.md) file. | ||
|
||
If you open a PR, you should also add a brief summary in the `CHANGELOG.md` | ||
mentioning the new feature, change or bugfix that you proposed. | ||
|
||
|
||
## Run source{d} CE For Development With Hot Reloading | ||
|
||
Running **source{d} CE** in development mode will enable hot reloading at | ||
http://127.0.0.1:8088, so every change you perform in `srcd` or `superset` | ||
directories will trigger a refresh in your browser with the new code. | ||
|
||
1. Install the latest version of [**source{d} CE**](https://github.com/src-d/sourced-ce/releases) | ||
(see [installation guide](https://docs.sourced.tech/community-edition/quickstart/2-install-sourced) | ||
if needed) | ||
|
||
1. Run the watcher. | ||
|
||
<details> | ||
<summary><b>IMPORTANT note:</b> Requirements for the watcher</summary> | ||
|
||
The watcher requires either [`inotify-tools`](https://github.com/rvoicilas/inotify-tools/wiki) | ||
(for Linux), or [`fswatch`](https://github.com/emcrisostomo/fswatch) | ||
(for Linux and MacOS) | ||
|
||
- To install `inotify-tools` | ||
- in Ubuntu you can run: | ||
```shell | ||
$ sudo apt-get install inotify-tools | ||
``` | ||
|
||
- To install `fswatch`: | ||
- in MacOS, you can [use brew to install `fswatch`](https://brewinstall.org/install-fswatch-on-mac-with-brew): | ||
```shell | ||
$ brew install fswatch | ||
``` | ||
- in Ubuntu you can build and install [from `fswatch` sources](https://github.com/emcrisostomo/fswatch): | ||
```shell | ||
$ ./autogen.sh | ||
$ ./configure | ||
$ make | ||
$ sudo make install | ||
$ sudo ldconfig | ||
``` | ||
</details> | ||
|
||
<details> | ||
<summary><b>ALTERNATIVE:</b> If you can not use any watcher</summary> | ||
|
||
- If you cannot use any of these watchers, you can just run this: | ||
|
||
```shell | ||
$ make set-override # to prepare the environment | ||
$ make patch # needed EVERYTIME you change something in `srcd` | ||
$ make clean # once you finish, to clean up everything. | ||
``` | ||
</details> | ||
|
||
To watch for changes in `srcd` directory, run the local watcher in one tab, | ||
from your local `sourced-ui` root directory: | ||
|
||
```shell | ||
$ make dev-prepare | ||
``` | ||
|
||
You can stop it pressing `Ctrl+C`. Once you do it, the patch will be | ||
automatically cleaned. | ||
|
||
1. Run `sourced` as usually (see [execution guide](https://docs.sourced.tech/community-edition/quickstart/3-init-sourced) | ||
if needed): | ||
|
||
```shell | ||
# for repositories from GitHub organizations | ||
$ sourced init orgs <orgs...> --token=<token> | ||
# or, for repositories stored locally | ||
$ sourced init local </path/to/repos> | ||
``` | ||
|
||
The first time you launch it, it will take some time to build all the UI assets, | ||
you can see the progress of the build from `sourced-ui` logs (see next step). | ||
|
||
1. To see `sourced-ui` logs (with `npm` errors and such), run: | ||
|
||
```shell | ||
$ sourced logs -f sourced-ui | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: '3.2' | ||
services: | ||
sourced-ui: | ||
user: ${LOGIN_USER:-superset}:${LOGIN_USER:-superset} | ||
volumes: | ||
- ${SOURCED_UI_ABS_PATH}/superset/superset:/home/superset/superset | ||
- ${SOURCED_UI_ABS_PATH}/superset/dashboards:/home/superset/dashboards | ||
- ${SOURCED_UI_ABS_PATH}/superset/contrib/docker/superset_config.py:/home/superset/superset/superset_config.py | ||
- ${SOURCED_UI_ABS_PATH}/superset/contrib/docker/bootstrap.py:/home/superset/bootstrap.py | ||
- ${SOURCED_UI_ABS_PATH}/superset/contrib/docker/docker-entrypoint.sh:/entrypoint.sh | ||
environment: | ||
SUPERSET_ENV: development | ||
LOCAL_USER: ${LOCAL_USER:-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
trap ctrl_c SIGINT | ||
|
||
function ctrl_c { | ||
make --no-print-directory clean && \ | ||
echo -e "\033[1;92mPatch cleaned\033[0m" || \ | ||
echo -e "\033[1;33mCould not clean patch\033[0m" | ||
exit $? | ||
} | ||
|
||
function watch_inotify { | ||
inotifywait --recursive \ | ||
--event modify,move,create,delete \ | ||
$DIRECTORY_TO_OBSERVE | ||
} | ||
|
||
function watch_fswatch { | ||
fswatch --recursive --one-event \ | ||
--event Created --event Updated --event Removed \ | ||
${DIRECTORY_TO_OBSERVE} | ||
} | ||
|
||
|
||
if command -v inotifywait > /dev/null 2>&1; then | ||
whichWatcher=inotify | ||
function watcher { watch_inotify; } | ||
elif command -v fswatch > /dev/null 2>&1; then | ||
whichWatcher=fswatch | ||
function watcher { watch_fswatch; } | ||
else | ||
echo -e "\033[1;31m[ERROR] No watcher available\033[0m" | ||
echo "Neither 'inotify' nor 'fswatch' are available." | ||
echo "You can follow 'CONTRIBUTING.md' guidelines to install one of them," | ||
echo "" | ||
echo -e "\033[1;33m[alternative]\033[0m follow these steps:" | ||
echo "1. run 'make set-override' first," | ||
echo "2. then 'make patch' every time you change a file in 'srcd' dir" | ||
echo "3. and 'make clean' once you finish developing" | ||
echo "" | ||
exit 1 | ||
fi | ||
|
||
make --no-print-directory apply-patch | ||
echo -e "\033[1;92mWatching for changes in 'srcd'; using '${whichWatcher}' ...\033[0m" | ||
while watcher; do | ||
make --no-print-directory apply-patch | ||
done |