-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We would like to put all the CI scripts in a single place instead of copied to each repository. Add a `ci/` directory and in it a `run_task.sh` script as well as auxilary scripts required. Include a README to document the directory.
- Loading branch information
Showing
2 changed files
with
460 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# CI tools | ||
|
||
Continuous Integration tools used by the `rust-bitcoin` org. | ||
|
||
#### Table Of Contents | ||
|
||
- [Repository](#repository) | ||
* [Lock files](#lock-files) | ||
* [Crates](#crates) | ||
* [Pinning](#dependency-pinning) | ||
- [Workflows](#workflows) | ||
- [get_matrix.sh](#get_matrix.sh) | ||
- [test_vars.sh](#test_vars.sh) | ||
- [run_task.sh](#run_task.sh) | ||
* [Environment variables](#environment-variables) | ||
* [Integration tests](#integration-tests) | ||
* [Crate specific tests](#crate-specific-tests) | ||
* [Fuzzing](#fuzzing) | ||
|
||
## Repository | ||
|
||
The `run_task.sh` script expects a few things to be present in all repositories. | ||
|
||
- lock files: `Cargo-recent.lock` and `Cargo-minimal.lock` | ||
- crate declarations: `contrib/crates.sh` | ||
- pinning: `contrib/pin.sh` | ||
|
||
## Lock files | ||
|
||
All repositories MUST include a minimal and recent lock file: | ||
|
||
- `Cargo-recent.lock`: A manifest with some recent versions numbers that pass CI. | ||
- `Cargo-minimal.lock`: A manifest with some minimal version numbers that pass CI. | ||
|
||
The `run_taks.sh` script invokes copies each to `Cargo.toml` and uses `cargo --locked`. | ||
|
||
(Suggestion: `cargo +nightly build -- -Z minimal-versions`) | ||
|
||
### Crates | ||
|
||
All repositories MUST include a file `crates.sh` that declares the crates to be tested. | ||
|
||
```bash | ||
#!/usr/bin/env bash | ||
|
||
# Crates in this workspace to test (excl. fuzz an integration-tests). | ||
CRATES="json client" | ||
``` | ||
|
||
### Pinning | ||
|
||
Pinning is optional. | ||
|
||
If MSRV build requires pinning of any dependencies then a `contrib/pin.sh` script should | ||
be present in the repository, for example: | ||
|
||
```yaml | ||
#!/usr/bin/env bash | ||
# | ||
# Do pinning as required for current MSRV. | ||
|
||
set -euo pipefail | ||
|
||
cargo update -p cc --precise 1.0.79 | ||
``` | ||
|
||
## Workflows | ||
|
||
If you want to use a specific version of nightly then use: | ||
|
||
```yml | ||
Prepare: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }} | ||
steps: | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
- name: "Read nightly version" | ||
id: read_toolchain | ||
run: echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT | ||
``` | ||
## run_task.sh | ||
Used by github actions to run a CI job, can also be run from the terminal. | ||
See `run_task.sh --help` for available tasks. | ||
|
||
### Environment variables | ||
|
||
All crates MUST include a file `contrib/test_vars.sh` | ||
|
||
```bash | ||
#!/usr/bin/env bash | ||
# Test all these features with "std" enabled. | ||
# | ||
# Ignore this if crate does not have "std" feature. | ||
FEATURES_WITH_STD="" | ||
# Test all these features without "std" enabled. | ||
# | ||
# Use this even if crate does not have "std" feature. | ||
FEATURES_WITHOUT_STD="" | ||
# Run these examples. | ||
EXAMPLES="" | ||
``` | ||
|
||
`EXAMPLES` string is of format: | ||
```bash | ||
"EXAMPLE_1:FEATURE_A,FEATURE_B EXAMPLE_2:FEATURE_C" | ||
``` | ||
|
||
### Integration tests | ||
|
||
The `integration` task expects to find a directory called `integration-tests` and runs the file | ||
within it called `run.sh`. | ||
|
||
### Crate specific tests | ||
|
||
Additional, crate specific, tests can be put in an optional `contrib/extra_tests.sh` file, which is | ||
expected to be a normal `bash` file (including exit non-zero on failure). | ||
|
||
### Fuzzing | ||
|
||
Fuzz tests are expected to be in a crate called `fuzz/`. The `run_task.sh` script just builds | ||
the fuzz crate as a sanity check. |
Oops, something went wrong.