CONTRIBUTING.md 3.13 KB
Newer Older
1
2
## Intro

3
4
5
This article goes into detail about multiple areas of interest to contributors,
which includes reviewers, developers, and integrators who each share an interest
in guiding crosvm's direction.
6
7
8
9
10
11
12
13

## Guidelines

The following is high level guidance for producing contributions to crosvm.

- Prefer mechanism to policy.
- Use existing protocols when they are adequate, such as virtio.
- Prefer security over code re-use and speed of development.
14
15
16
- Only the version of Rust in use by the Chrome OS toolchain is supported. This
  is ordinarily the stable version of Rust, but can be behind a version for a
  few weeks.
17
18
19
20
21
22
- Avoid distribution specific code.

## Code Health

### Scripts

23
24
25
In the `bin/` directory of the crosvm repository, there is the `clippy` script
which lints the Rust code and the `fmt` script which will format the crosvm Rust
code inplace.
26

27
### Running tests
28

29
The `./test_all` script will use docker containers to run all tests for crosvm.
30

31
32
33
34
35
36
37
38
For more details on using the docker containers for running tests locally,
including faster, iterative test runs, see `ci/README.md`.

### Submitting Code

See also,
[Chrome OS Contributing Guide](https://chromium.googlesource.com/chromiumos/docs/+/HEAD/contributing.md)

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Once your change is reviewed by a crosvm
[owner](https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/crosvm/OWNERS)
it will need to go through two layers of presubmit checks.

The review will trigger Kokoro to run crosvm specific tests. If you want to
check kokoro results before a review, you can set 'Commit Queue +1' in gerrit to
trigger a dry-run.

If you upload further changes after the you were given 'Code Review +2', Kokoro
will automatically trigger another test run. But you can also always comment
'kokoro rerun' to manually trigger another build if needed.

When Kokoro passes, it will set Verified +1 and the change is ready to be sent
to the
[ChromeOS commit queue](https://chromium.googlesource.com/chromiumos/docs/+/HEAD/contributing.md#send-your-changes-to-the-commit-queue)
by setting CQ+2.

Note: This is different from other ChromeOS repositories, where Verified +1 bit
is set by the developers to indicate that they successfully tested a change. The
Verified bit can only be set by Kokoro in the crosvm repository.

The commit queue will test your change on ChromeOS hardware, including high
level end-to-end tests. Only if all of those pass, will the change be submitted.

63
64
65
66
Failures here will cause the commit queue to reject the change until it is
re-added (CQ+2). Unfortunately, it is extremely common for false negatives to
cause a change to get rejected, so be ready to re-apply the CQ+2 label if you're
the owner of a ready to submit change.
67
68
69

### Style guidelines

70
71
To format all code, crosvm defers to rustfmt. In addition, the code adheres to
the following rules:
72
73
74
75

The `use` statements for each module should be grouped in this order

1.  `std`
76
77
78
79
80
81
82
83
2.  third-party crates
3.  chrome os crates
4.  crosvm crates
5.  `crate`

crosvm uses the [remain](https://github.com/dtolnay/remain) crate to keep error
enums sorted, along with the `#[sorted]` attribute to keep their corresponding
match statements in the same order.