Skip to content

Commit

Permalink
Merge pull request #574 from garden-io/dev-workflow
Browse files Browse the repository at this point in the history
chore: simplify dev workflow
  • Loading branch information
eysi09 authored Feb 28, 2019
2 parents 4b0bcc0 + 3dfc333 commit 0bd8056
Show file tree
Hide file tree
Showing 13 changed files with 1,867 additions and 2,452 deletions.
28 changes: 25 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ jobs:
- npm_install
- run:
name: build
command: npm run build-service-ci
command: |
cd garden-service
npm run build-ci
# Save the built output to be used for the docker image and for the release steps
- persist_to_workspace:
# Must be an absolute path, or relative path from working_directory. This is a directory on the container which is
Expand Down Expand Up @@ -191,9 +193,22 @@ jobs:
- run:
name: test
command: |
npm run test-service-ci
cd garden-service
npm test
environment:
CHOKIDAR_USEPOLLING: "1"
test-dashboard:
<<: *node-config
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- npm_install
- run:
name: Test dashboard
command: |
cd dashboard
npm test
build-dashboard:
<<: *node-config
steps:
Expand All @@ -203,7 +218,9 @@ jobs:
- npm_install
- run:
name: Build dashboard
command: npm run build-dashboard-ci
command: |
cd dashboard
npm run build-ci
# Save the built output to be used for the docker image and for the release steps
- persist_to_workspace:
# Must be an absolute path, or relative path from working_directory. This is a directory on the container which is
Expand Down Expand Up @@ -235,6 +252,7 @@ workflows:
- build-service
- test-service
- build-dashboard
- test-dashboard
- build-service-docker:
requires:
- build-service
Expand All @@ -250,6 +268,8 @@ workflows:
- build-service
- build-dashboard:
<<: *only-master
- test-dashboard:
<<: *only-master
- release-service-docker:
<<: *only-master
context: docker
Expand All @@ -273,6 +293,8 @@ workflows:
- build-service
- build-dashboard:
<<: *only-tags
- test-dashboard:
<<: *only-tags
- release-service-docker:
<<: *only-tags
context: docker
Expand Down
55 changes: 47 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,68 @@ Install Node modules for the root package, and the `dashboard` and `garden-servi

npm run bootstrap

## Running a development version of the CLI
## Developing Garden

While developing the CLI, we recommend you run the dev command in your console:
### Initial build

Before running Garden for the first time, you need to do an initial build by running

```sh
npm run build
```

from the root directory. This ensures that the dashboard is built and ready to serve and that version files are in place.

### Developing

To develop the CLI, run the `dev` command in your console:

cd garden-service
npm run dev

This will do an initial development build, `npm link` it to your global npm folder, and then watch for
This will `npm link` it to your global npm folder, and then watch for
changes and auto-rebuild as you code. You can then run the `garden` command as normal.

Also, you might like to add a couple of shorthands:

alias g='garden'
alias k='kubectl'

## Testing
For developing the dashboard, please refer to the [dashboard docs](./dashboard/README.mdj).

### Tests

Tests are run using `mocha` via `npm test` from the directory of the package you want to test. To run a specific test, you can grep the test description with the `-g` flag. E.g., to the test the `taskGraph` of the `garden-service`, run:

```sh
cd garden-service
npm test -- -g "taskGraph"
```

Integration tests are run with:


```sh
npm run integ
```

### Checks

We have scripts for checking licenses, docs, linting and more. These can all be run with a single command:

```sh
npm run check-all
```

### Pre-push hook

Tests are run using `mocha`. To run the full test suite, including linting and other validation, simply run
from the root:
Before pushing, we automatically run the `check-all` script from above, as well as unit and integration tests. To skip these, run push with the `--no-verify` flag:

npm test
```sh
git push origin <my-branch> --no-verify
```

### CI
## CI

We use [Circle CI](https://circleci.com) for integration testing. Sometimes
it can be useful to test and debug the CI build locally, particularly when
Expand Down
46 changes: 38 additions & 8 deletions dashboard/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,68 @@
# Garden Dashboard _(experimental)_

This directory contains an experimental web dashboard for the Garden CLI.
This directory contains an experimental web dashboard for the Garden CLI. The dashboard is available on `localhost` when either the `garden dev` or `garden serve` commands are running.

All commands below assume that the current directory is root.

## Usage

To use with the Garden CLI, simply run:

```sh
cd garden-service
garden serve
```

or alternatively

```sh
cd garden-service
garden dev
```

and follow the dashboard link printed by the command.

## Develop

To develop the dashboard, first run:

```sh
garden serve
cd garden-service
garden serve # (or garden dev)
```

to start the `garden-service` API server, then run:
to start the `garden-service` API server. Then run:

```sh
npm start
cd dashboard
npm dev
```

to start the dashboard development server. The `start` command returns a link to the development version of the dashboard. The default is `http://localhost:3000`.

### CORS

To avoid Cross-Origin Resource Sharing (CORS) errors while developing, we proxy the request to the `garden-service` server, defaulting to port `9777`. If the `garden-service` server is running on a different port, use:
To avoid Cross-Origin Resource Sharing (CORS) errors while developing, we proxy the request to the `garden-service` server, defaulting to port `9777`.

To ensure the `garden-service` server runs on port `9777`, start it with:

```sh
cd garden-service
GARDEN_SERVER_PORT=9777 garden serve
```

or

```sh
cd garden-service
GARDEN_SERVER_PORT=9777 garden dev
```

Alternatively, you can run the `garden-service` server as usual and set the port on the dashboard side of things:

```sh
REACT_APP_GARDEN_SERVICE_PORT=PORT npm start
cd dashboard
REACT_APP_GARDEN_SERVICE_PORT=my_port npm start
```

See also `src/setupProxy.js` and [Adding Custom Environment Variables](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables).
Expand All @@ -43,10 +72,11 @@ See also `src/setupProxy.js` and [Adding Custom Environment Variables](https://f
To build the dashboard, run:

```
npm build
cd dashboard
npm run build
```

This builds the dashboard into the `build` directory, from where the `garden-service` API server serves it.
This builds the dashboard into the `garden-service/static/dashboard` directory, from where the `garden-service` API server serves it.

## About

Expand Down
14 changes: 14 additions & 0 deletions dashboard/bin/copy-to-static
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -e

# We copy the dashboard build directory to the garden-service static directory for the development build.
# For production builds the copy step is executed in CI.
# TODO: Remove this and use env vars to detect if Garden is running in dev mode and serve the build
# from the dashboard directory.

dashboard_root=$(cd `dirname $0` && cd .. && pwd)
garden_service_root=$(cd $dashboard_root && cd ../garden-service && pwd)
build_dir=$dashboard_root/build
dest_dir=${garden_service_root}/static/dashboard

rm -rf $dest_dir
cp -r $build_dir $dest_dir
30 changes: 0 additions & 30 deletions dashboard/gulpfile.ts

This file was deleted.

Loading

0 comments on commit 0bd8056

Please sign in to comment.