Skip to content

Commit 57fd469

Browse files
docs: update CONTRIBUTING.md to split frontend/backend and add emulator info (#4871)
Updated CONTRIBUTING.md to improve the contributor experience by separating frontend and backend development instructions and providing information on how to use the website emulator for local testing without GCP credentials. - Split "Contributing code" into "Backend development" and "Frontend development". - Add instructions for non-internal contributors to use `make run-website-emulator`. - Mention adding testcase records to `gcp/website/testdata/osv/` for testing edge cases. - Fix a minor typo in the API server section. Closes #1427 --- *PR created automatically by Jules for task [4582872313076138700](https://jules.google.com/task/4582872313076138700) started by @jess-lowe* --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent f1e311c commit 57fd469

1 file changed

Lines changed: 36 additions & 20 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ poetry self add poetry-plugin-shell
6868
poetry shell
6969
```
7070

71-
### Running tests
71+
### Backend development
72+
73+
#### Running tests
7274

7375
Certain tests require you to auth with the Google Cloud SDK and to install the
7476
Firestore Emulator:
@@ -93,7 +95,7 @@ By default, this skips long tests, enable them by setting the `LONG_TESTS` varia
9395
LONG_TESTS=1 make api-server-tests
9496
```
9597

96-
#### Test result generation
98+
##### Test result generation
9799

98100
Many tests are written using a
99101
[simple framework](https://github.com/google/osv.dev/blob/a4b682a32575cc3314a5ef83c8e91b70c60f7b77/osv/tests.py#L32)
@@ -109,49 +111,63 @@ the environment variable `TESTS_GENERATE=1` and run the tests:
109111
TESTS_GENERATE=1 make all-tests
110112
```
111113

112-
### Linting and formatting
114+
#### Running a local API instance (maintainers only)
113115

114-
To lint your code, run
116+
Running a local instance of the API server requires the path to application
117+
default credentials. This is required so that the ESP container has credentials
118+
to download API configuration.
115119

116120
```shell
117-
make lint
121+
gcloud auth login --update-adc
122+
make run-api-server
118123
```
119124

120-
To format your code, run
125+
#### API E2E Snapshots
126+
127+
If you have made any changes to the API, please update the API query snapshots with
128+
121129
```shell
122-
yapf -i <file>.py
130+
gcloud auth login --update-adc
131+
make update-api-snapshots
123132
```
124133

125-
### Running local UI and API instances (maintainers only)
134+
and check the git diff to see if the API result changes are expected.
135+
136+
### Frontend development
126137

127-
#### UI
138+
#### Running a local UI instance (maintainers only)
128139

129140
```shell
130141
gcloud auth login --update-adc
131142
make run-website
132143
```
133144

134-
#### API
145+
#### Running a local UI instance
135146

136-
Running a local instance of the API server requires the path to application
137-
default credentials. The is required so that the ESP container has credentials
138-
to download API configuration.
147+
For contributors without access to the GCP project, you can use the website emulator which does
148+
not require Google Cloud project access. This emulator uses a local datastore
149+
and loads data from a local directory.
139150

140151
```shell
141-
gcloud auth login --update-adc
142-
make run-api-server
152+
make run-website-emulator
143153
```
144154

145-
#### API E2E Snapshots
155+
You can add testcase records to `gcp/website/testdata/osv/` to test odd cases.
156+
See [gcp/website/testdata/osv/README.md](gcp/website/testdata/osv/README.md)
157+
for more information on the format of these records.
146158

147-
If you have made any changes to the API, please update the API query snapshots with
159+
### Linting and formatting
160+
161+
To lint your code, run
148162

149163
```shell
150-
gcloud auth login --update-adc
151-
make update-api-snapshots
164+
make lint
152165
```
153166

154-
and check the git diff to see if the API result changes are expected.
167+
To format your code, run
168+
```shell
169+
yapf -i <file>.py
170+
```
155171

156172
### Making commits
157173

0 commit comments

Comments
 (0)