- Requirements
- Project Structure
- Running Locally
- Populate Data Locally
- Populate Users Locally
- Generating Code
- Test Code
- Clean Up
The recommended way to do development is through the provided devcontainer. To run a devcontainer, check out this web page for the latest requirements to run devcontainer. The devcontainer will have everything pre-installed.
- backend/: Go backend code.
- frontend/: TypeScript frontend code.
- workflows/: Data pipelines for fetching and processing data.
- openapi/: OpenAPI specifications for APIs.
- jsonschema/: JSON schemas for data validation.
- antlr: Description of search grammar
- lib/gen: Output of generated code
# Terminal 1
make start-local
This command will build the necessary Docker images, start Minikube (a local Kubernetes cluster), and deploy the webstatus.dev services to it.
Once everything comes up, open a second terminal.
Important: By default, the services running in Minikube are not accessible from your host machine. To enable access, in a new terminal, run:
# Terminal 2
make port-forward-manual
The output should match this:
$ make port-forward-manual
pkill kubectl -9 || true
kubectl wait --for=condition=ready pod/frontend
pod/frontend condition met
kubectl wait --for=condition=ready pod/backend
pod/backend condition met
kubectl port-forward --address 127.0.0.1 pod/frontend 5555:5555 2>&1 >/dev/null &
kubectl port-forward --address 127.0.0.1 pod/backend 8080:8080 2>&1 >/dev/null &
Note: Ignore the WARN statements that are printed in terminal 1 as a result of this
command. However, if the WARN statements appear later on and you did not run
this command or the make port-forward-terminate
command, something may be wrong.
This will establish port forwarding, allowing you to access the backend at http://localhost:8080 and the frontend at http://localhost:5555.
If you terminate everything in terminal 1, run this to clean up:
# Terminal 2
make port-forward-terminate
Note: Ignore the WARN statements that are printed in terminal 1 as a result of this
command. However, if the WARN statements appear later on and you did not run
this command or the make port-forward-manual
command, something may be wrong.
The above skaffold command deploys multiple resources:
Resource | Description | Port Forwarded Address | Internal Address |
---|---|---|---|
backend | Backend service in ./backend | http://localhost:8080 | http://backend:8080 |
frontend | Frontend service in ./frontend | http://localhost:5555 | http://frontend:5555 |
datastore | Datastore Emulator | N/A | http://datastore:8085 |
spanner | Spanner Emulator | N/A | spanner:9010 (grpc) http://spanner:9020 (rest) |
redis | Redis | N/A | redis:6379 |
gcs | Google Cloud Storage Emulator | N/A | http://gcs:4443 |
auth | Auth Emulator | http://localhost:9099 http://localhost:9100/auth (ui) |
http://auth:9099 http://auth:9100/auth (ui) |
In the event the servers are not responsive, make a temporary change to a file in a watched directory (e.g. backend). This will rebuild and expose the services.
After doing an initial deployment, the databases will be empty. Currently, you can run a local version of the workflow to populate your database.
Run the following:
# Terminal 2 - Run local workflows
make dev_workflows
Note: If the command fails, there might be a problem with the live data it is pulling
An option could be to populate the database with fake data. This is useful if the live data sources are down or constantly changing.
# Terminal 2 - Run local workflows
make dev_fake_data
To test with real data from api.webstatus.dev
, you can replace the $API_URL
variable
in apiUrl
settings property value in the webstatus-app
component of
frontend/src/static/index.html
with the URL "https://api.webstatus.dev" as follows:
<webstatus-app
settings='{"apiUrl": "https://api.webstatus.dev" ...}'
></webstatus-app>
Open http://localhost:8080/v1/features
to see the features populated
from the latest snapshot from the web-features repo.
Resource | Location |
---|---|
backend | openapi/backend/openapi.yaml |
After doing an initial deployment, we need to set up users in the auth emulator.
make dev_fake_users
The output of the command will indicate if it is successful.
There two common configurations used to generate code for Go.
This repository uses oapi-codegen/oapi-codegen to generate the types.
The project use openapi-typescript to generate types.
If changes are made to the openapi definition, run:
make -B openapi
The project uses json schema to generate types from:
- browser-compat-data
- web-features
- We make minor tweaks to the web-features schema to work with the QuickType tool to successfully generate the types
We vendor the files schemas locally in the jsonschema folder.
make jsonschema
We use ANTLR v4 to describe the grammar for our search.
You can find the grammar in this file
In the same directory, is the README for the grammar.
Run make antlr-gen
TODO
To learn more about testing and linting the code, refer to the testing document.
To clean up the resources, do things in reverse:
- Stop Port Forwarding:
make port-forward-terminate
- Stop Services (Local Setup):
make stop-local