Skip to content

Commit

Permalink
docs: add testing instructions in CONTRIBUTING.md (#292)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Rafid Bin Mostofa <[email protected]>
  • Loading branch information
cjdcordeiro and rebornplusplus authored Jul 26, 2024
1 parent b4d6069 commit 4cf1397
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
10 changes: 1 addition & 9 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@ being proposed in this PR (i.e. feat, test, fix, ci, chore, docs).
<!-- This change MUST also be proposed to all newer, and still supported,
releases. List the corresponding PRs, or ignore if not applicable. -->

## Testing
<!-- Provide proof of testing and/or testing instructions, when applicable,
to help speed up the review process. -->

```bash
# Example:
# chisel cut ... --root <path> <pkg>_<proposed-slice>
# sudo chroot <path> <app>
```

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->

* [ ] I have read the [contributing guidelines](
https://github.com/canonical/chisel-releases/blob/main/CONTRIBUTING.md)
* [ ] I have tested my changes ([see how](https://github.com/canonical/chisel-releases/blob/main/CONTRIBUTING.md#7-test-your-slices-before-opening-a-pr))
* [ ] I have already submitted the [CLA form](
https://ubuntu.com/legal/contributors/agreement)

Expand Down
42 changes: 35 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ styles, we must strive for consistency and thus your contributions are expected
to match the existing codebase, as described by the following guidelines.
Any non-conforming proposals will be subject to immediate rejection.


- [Code of Conduct](#code-of-conduct)
- [Canonical Contributor Licence Agreement](#canonical-contributor-licence-agreement)
- [How to Contribute](#how-to-contribute)
Expand Down Expand Up @@ -265,12 +264,41 @@ conflicts between slice definitions files;
Apart from asserting your slice definitions' formatting, you must also test them
before opening a Pull Request.

Chisel supports custom releases, so please make sure you `cut` your custom
slices and run smoke tests on them.

***Tip**: to install slices from a custom Chisel release, simply provide its
absolute path to the `--release` option in Chisel. E.g.
`chisel cut --release $PWD/custom-chisel-release --root testfs pkg-a_sliceFoo`.*
Every Chisel release supports the functional testing for slices via
[Spread](https://github.com/snapcore/spread).

**We expect tests to be provided for every slice**, so please ensure you include
those in your PRs.

Here's how you can create and run tests for your slice definitions:

1. under `tests/spread/integration/`, make sure at least one folder matching the
package name you're slicing, exists,
1. inside that folder you must create a `task.yaml` file. This is where you'll
write all the tests for your slide definitions. Please follow the structure from
existing examples, providing at least the `summary` and `execute` fields inside
`task.yaml` (for other possible fields, please check the
[Spread docs](https://github.com/snapcore/spread)),
1. in `test/spread/lib/` you'll also find a set of helper functions that you
can call from within your `task.yaml` execution script,
1. once your test is ready, ensure you have the necessary requirements to run it
locally:
- Docker: you can install it via the [Snap Store](https://snapcraft.io/docker) or
by following the [official instructions](https://docs.docker.com/engine/install/)
- Spread: we recommend installing it from source (with
`go install github.com/snapcore/spread/cmd/spread@latest`), but there's
also a [Spread snap](https://snapcraft.io/spread)
- QEMU: if testing for multiple architectures, you'll need to install these
packages: `sudo apt-get install qemu binfmt-support qemu-user-static`
1. from the repository's root directory, you can now run
`spread tests/spread/integration/<pkg>` for running the tests for your package
`<pkg>` slices, on all architectures. Additionally, you can also:
- run `spread` for orchestrating **all** the tests (not just yours), for all
architectures, or
- run `spread docker:ubuntu-22.04-amd64` for orchestrating **all** the tests
(not just yours) for amd64 only, or
- run `spread docker:ubuntu-22.04-arm64v8:tests/spread/integration/<pkg>`
for running only the tests for your package `<pkg>` slices, on arm64.

#### 8. Open the PR(s)

Expand Down

0 comments on commit 4cf1397

Please sign in to comment.