diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6efd4f909f..6254815a6b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,7 +68,9 @@ poetry self add poetry-plugin-shell poetry shell ``` -### Running tests +### Backend development + +#### Running tests Certain tests require you to auth with the Google Cloud SDK and to install the Firestore Emulator: @@ -93,7 +95,7 @@ By default, this skips long tests, enable them by setting the `LONG_TESTS` varia LONG_TESTS=1 make api-server-tests ``` -#### Test result generation +##### Test result generation Many tests are written using a [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: TESTS_GENERATE=1 make all-tests ``` -### Linting and formatting +#### Running a local API instance (maintainers only) -To lint your code, run +Running a local instance of the API server requires the path to application +default credentials. This is required so that the ESP container has credentials +to download API configuration. ```shell -make lint +gcloud auth login --update-adc +make run-api-server ``` -To format your code, run +#### API E2E Snapshots + +If you have made any changes to the API, please update the API query snapshots with + ```shell -yapf -i .py +gcloud auth login --update-adc +make update-api-snapshots ``` -### Running local UI and API instances (maintainers only) +and check the git diff to see if the API result changes are expected. + +### Frontend development -#### UI +#### Running a local UI instance (maintainers only) ```shell gcloud auth login --update-adc make run-website ``` -#### API +#### Running a local UI instance -Running a local instance of the API server requires the path to application -default credentials. The is required so that the ESP container has credentials -to download API configuration. +For contributors without access to the GCP project, you can use the website emulator which does +not require Google Cloud project access. This emulator uses a local datastore +and loads data from a local directory. ```shell -gcloud auth login --update-adc -make run-api-server +make run-website-emulator ``` -#### API E2E Snapshots +You can add testcase records to `gcp/website/testdata/osv/` to test odd cases. +See [gcp/website/testdata/osv/README.md](gcp/website/testdata/osv/README.md) +for more information on the format of these records. -If you have made any changes to the API, please update the API query snapshots with +### Linting and formatting + +To lint your code, run ```shell -gcloud auth login --update-adc -make update-api-snapshots +make lint ``` -and check the git diff to see if the API result changes are expected. +To format your code, run +```shell +yapf -i .py +``` ### Making commits