Skip to content

Commit 4398a46

Browse files
Update dev guide and generated protos.
1 parent ec2438a commit 4398a46

File tree

6 files changed

+520
-225
lines changed

6 files changed

+520
-225
lines changed

web/README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ Testgrid frontend code uses Lit elements and is written in Typescript. `tsconfig
66
More info about Lit and Typescript can be found in [Lit docs](https://lit.dev/) and [TS docs](https://www.typescriptlang.org/) respectively.
77

88
## Development
9-
Local development is done with the help of [Web Dev Server](https://modern-web.dev/docs/dev-server/overview/). Web dev server configurations are defined in `web-dev-server-{env}.config.mjs` file. Depending on the config, frontend will render from the data from either fake or prod API.
9+
Local development is done with the help of [Web Dev Server](https://modern-web.dev/docs/dev-server/overview/). Web dev server configurations are defined in `web-dev-server-{env}.config.mjs` file. Depending on the config, frontend will render from the data from either fake or prod API.
1010

11-
To see fake data, run `npm run start:local`. To see prod data, run `npm run start:k8s`. More info in the [Scripts](#scripts) section below.
11+
To develop locally:
12+
- Run `npm install`, then:
13+
- To see fake data, run `npm run start:local`
14+
- To see prod data, run `npm run start:k8s`
15+
16+
More info in the [Scripts](#scripts) section below.
17+
18+
TIP: If you hit unexpected errors, try running `rm -rf node_modules/`, then `npm install` to refresh dependencies.
1219

1320
## Testing
14-
Testing relies on [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) with the configuration defined in `web-test-runner.config.mjs`. Testing is currently happening across the fake data provided by `json-server`.
1521

1622
To run the tests, run `npm run test`. More info in the [Scripts](#scripts) section below.
1723

@@ -28,7 +34,15 @@ Most scripts are in `npm run` commands.
2834

2935
## Pulling from upstream
3036

31-
Upstream proto definitions can be generated by running `pb/bump-protos.sh`
37+
To generate or update the proto definitions:
38+
39+
- Checkout a local copy of https://github.com/GoogleCloudPlatform/testgrid, ex. `gh repo clone GoogleCloudPlatform/testgrid $HOME/gcp-testgrid`
40+
- Run
41+
```
42+
# Path to local GCP/testgrid repo, `$HOME/gcp-testgrid`
43+
TGREPO={{local GCP/testgrid repo}}
44+
bump-protos.sh "$TGREPO"
45+
```
3246

3347
## Configs and files
3448
- Frontend code is located in `src` dir.
@@ -38,4 +52,4 @@ Upstream proto definitions can be generated by running `pb/bump-protos.sh`
3852
- `tsconfig.json` defines how and where will the .ts files compile.
3953
- `web-dev-server-*.config.mjs` defines configuration parameters for the web dev server.
4054
- `web-test-runner.config.mjs` defined configuration parameters for the web test runner.
41-
- `rollup.config.js` defines how the code will be built and bundled.
55+
- `rollup.config.js` defines how the code will be built and bundled.

web/bump-protos.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,27 @@ set -o errexit
1717
set -o nounset
1818
set -o pipefail
1919

20-
WORKDIR="${HOME}/github/testgrid" # The root directory of your repository
20+
if [ "$#" -lt 1 ]
21+
then
22+
echo "Usage: $0 [path to local GCP/testgrid repo]"
23+
exit 1
24+
fi
25+
26+
# The location of your local https://github.com/GoogleCloudPlatform/testgrid repo, where the proto files live.
27+
TESTGRID_REPO=$1
28+
29+
WORKDIR="$(git rev-parse --show-toplevel)" # The root directory of your repository
2130
PROTO_DEST="${WORKDIR}/web/src/gen"
2231

32+
echo "Generating protos from source $TESTGRID_REPO to destination $PROTO_DEST..."
33+
2334
cd "${WORKDIR}/web"
2435

2536
# See https://github.com/timostamm/protobuf-ts/blob/master/MANUAL.md
26-
npx protoc --ts_out ${PROTO_DEST} --proto_path ${WORKDIR} --ts_opt long_type_string \
27-
${WORKDIR}/pb/custom_evaluator/custom_evaluator.proto \
28-
${WORKDIR}/pb/state/state.proto \
29-
${WORKDIR}/pb/summary/summary.proto \
30-
${WORKDIR}/pb/config/config.proto \
31-
${WORKDIR}/pb/test_status/test_status.proto \
32-
${WORKDIR}/pb/api/v1/data.proto
37+
npx protoc --ts_out ${PROTO_DEST} --proto_path ${TESTGRID_REPO} --ts_opt long_type_string \
38+
${TESTGRID_REPO}/pb/custom_evaluator/custom_evaluator.proto \
39+
${TESTGRID_REPO}/pb/state/state.proto \
40+
${TESTGRID_REPO}/pb/summary/summary.proto \
41+
${TESTGRID_REPO}/pb/config/config.proto \
42+
${TESTGRID_REPO}/pb/test_status/test_status.proto \
43+
${TESTGRID_REPO}/pb/api/v1/data.proto

0 commit comments

Comments
 (0)