Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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 <file>.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 (non-internal contributors)
Comment thread
jess-lowe marked this conversation as resolved.
Resolved

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 non-internal contributors, you can use the website emulator which does
Comment thread
jess-lowe marked this conversation as resolved.
Resolved
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 <file>.py
```

### Making commits

Expand Down
Loading