|
| 1 | +# CI tools |
| 2 | + |
| 3 | +Continuous Integration tools used by the `rust-bitcoin` org. |
| 4 | + |
| 5 | +#### Table Of Contents |
| 6 | + |
| 7 | +- [Lock files](#lock-files) |
| 8 | + * [Pinning](#dependency-pinning) |
| 9 | +- [Workflows](#workflows) |
| 10 | +- [get_matrix.sh](#get_matrix.sh) |
| 11 | +- [test_vars.sh](#test_vars.sh) |
| 12 | +- [run_task.sh](#run_task.sh) |
| 13 | + * [Environment variables](#environment-variables) |
| 14 | + * [Integration tests](#integration-tests) |
| 15 | + * [Crate specific tests](#crate-specific-tests) |
| 16 | + * [Fuzzing](#fuzzing) |
| 17 | + |
| 18 | +## Lock files |
| 19 | + |
| 20 | +All repositories MUST include a minimal and recent lock file: |
| 21 | + |
| 22 | +- `Cargo-recent.lock`: A manifest with some recent versions numbers that pass CI. |
| 23 | +- `Cargo-minimal.lock`: A manifest with some minimal version numbers that pass CI. |
| 24 | + |
| 25 | +The `run_taks.sh` script invokes copies each to `Cargo.toml` and uses `cargo --locked`. |
| 26 | + |
| 27 | +### Crates |
| 28 | + |
| 29 | +All repositories MUST include a file `crates.sh` that declares the crates to be tested. |
| 30 | +```bash |
| 31 | +#!/usr/bin/env bash |
| 32 | + |
| 33 | +# Crates in this workspace to test (excl. fuzz an integration-tests). |
| 34 | +CRATES="json client" |
| 35 | +``` |
| 36 | + |
| 37 | +### Pinning |
| 38 | + |
| 39 | +If MSRV build requires pinning of any dependencies then a `contrib/pin.sh` script should be present |
| 40 | +in the repository, for example: |
| 41 | + |
| 42 | +```yaml |
| 43 | +#!/usr/bin/env bash |
| 44 | +# |
| 45 | +# Do pinning as required for current MSRV. |
| 46 | + |
| 47 | +set -euo pipefail |
| 48 | + |
| 49 | +cargo update -p cc --precise 1.0.79 |
| 50 | +``` |
| 51 | + |
| 52 | + |
| 53 | +## Workflows |
| 54 | + |
| 55 | +If you want to use a specific version of nightly then use: |
| 56 | + |
| 57 | +```yml |
| 58 | + Prepare: |
| 59 | + runs-on: ubuntu-latest |
| 60 | + outputs: |
| 61 | + nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }} |
| 62 | + steps: |
| 63 | + - name: "Checkout repo" |
| 64 | + uses: actions/checkout@v4 |
| 65 | + - name: "Read nightly version" |
| 66 | + id: read_toolchain |
| 67 | + run: echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT |
| 68 | +``` |
| 69 | +
|
| 70 | +## get_matrix.sh |
| 71 | +
|
| 72 | +Used by the `run_task.sh` script, you should not need to touch this file directly. |
| 73 | + |
| 74 | +## run_task.sh |
| 75 | + |
| 76 | +Used by github actions to run a CI job, can also be run from the terminal. |
| 77 | + |
| 78 | +See `run_task.sh --help` for available tasks. |
| 79 | + |
| 80 | +### Environment variables |
| 81 | + |
| 82 | +All crates MUST include a file `contrib/test_vars.sh` |
| 83 | + |
| 84 | +```bash |
| 85 | +#!/usr/bin/env bash |
| 86 | +
|
| 87 | +# Test all these features with "std" enabled. |
| 88 | +FEATURES_WITH_STD="" |
| 89 | +
|
| 90 | +# Test all these features without "std" enabled. |
| 91 | +FEATURES_WITHOUT_STD="" |
| 92 | +
|
| 93 | +# Run these examples. |
| 94 | +EXAMPLES="" |
| 95 | +``` |
| 96 | + |
| 97 | +`EXAMPLES` string is of format: |
| 98 | +```bash |
| 99 | +"EXAMPLE_1:FEATURE_A,FEATURE_B EXAMPLE_2:FEATURE_C" |
| 100 | +``` |
| 101 | + |
| 102 | +### Integration tests |
| 103 | + |
| 104 | +The `integration` task expects to find a directory called `integration-tests` and runs the file |
| 105 | +within it called `run.sh`. |
| 106 | + |
| 107 | +### Crate specific tests |
| 108 | + |
| 109 | +Additional, crate specific, tests can be put in an optional `contrib/extra_tests.sh` file, which is |
| 110 | +expected to be a normal `bash` file (including exit non-zero on failure). |
| 111 | + |
| 112 | +### Fuzzing |
| 113 | + |
| 114 | +Fuzz tests are expected to be in a crate called `fuzz/`. The `run_task.sh` script just builds |
| 115 | +the fuzz crate as a sanity check. |
0 commit comments