| 1 |
on: [push, pull_request] |
| 2 |
|
| 3 |
name: CI |
| 4 |
|
| 5 |
env: |
| 6 |
CARGO_HOME: ${{ github.workspace }}/.cargo |
| 7 |
CARGO_TERM_COLOR: always |
| 8 |
RUSTFLAGS: -D warnings -A unused-imports |
| 9 |
RUSTDOCFLAGS: -D warnings |
| 10 |
RUST_BACKTRACE: full |
| 11 |
|
| 12 |
jobs: |
| 13 |
# Check formatting. |
| 14 |
rustfmt: |
| 15 |
name: Rustfmt |
| 16 |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 17 |
runs-on: ubuntu-latest |
| 18 |
steps: |
| 19 |
- uses: actions/checkout@v4 |
| 20 |
- run: rustup update stable --no-self-update |
| 21 |
- run: rustc -Vv |
| 22 |
- run: cargo fmt --all -- --check |
| 23 |
|
| 24 |
# Build documentation. |
| 25 |
rustdoc: |
| 26 |
name: Rustdoc |
| 27 |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 28 |
runs-on: ubuntu-latest |
| 29 |
steps: |
| 30 |
- uses: actions/checkout@v4 |
| 31 |
- uses: actions/[email protected] |
| 32 |
with: |
| 33 |
path: | |
| 34 |
${{ env.CARGO_HOME }} |
| 35 |
target |
| 36 |
key: rustdoc-${{ runner.os }} |
| 37 |
- run: rustup update stable --no-self-update |
| 38 |
- run: rustc -Vv |
| 39 |
- run: cargo rustdoc --all-features -- --document-private-items |
| 40 |
|
| 41 |
# Run linter. |
| 42 |
clippy: |
| 43 |
name: Clippy |
| 44 |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 45 |
runs-on: ${{ matrix.os }} |
| 46 |
strategy: |
| 47 |
matrix: |
| 48 |
os: |
| 49 |
- ubuntu-latest |
| 50 |
- macos-latest |
| 51 |
- windows-latest |
| 52 |
steps: |
| 53 |
- uses: actions/checkout@v4 |
| 54 |
- uses: actions/[email protected] |
| 55 |
with: |
| 56 |
path: | |
| 57 |
${{ env.CARGO_HOME }} |
| 58 |
target |
| 59 |
key: clippy-${{ runner.os }} |
| 60 |
- run: rustup update stable --no-self-update |
| 61 |
- run: rustc -Vv |
| 62 |
- run: cargo clippy --all --all-targets --all-features |
| 63 |
|
| 64 |
# Run tests in `src/` and `tests/`. |
| 65 |
unit-test: |
| 66 |
name: Unit Test |
| 67 |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 68 |
runs-on: ${{ matrix.os }} |
| 69 |
strategy: |
| 70 |
matrix: |
| 71 |
os: |
| 72 |
- ubuntu-latest |
| 73 |
- macos-latest |
| 74 |
- windows-latest |
| 75 |
rust: |
| 76 |
- stable |
| 77 |
- nightly |
| 78 |
steps: |
| 79 |
- uses: actions/checkout@v4 |
| 80 |
- uses: actions/[email protected] |
| 81 |
with: |
| 82 |
path: | |
| 83 |
${{ env.CARGO_HOME }} |
| 84 |
target |
| 85 |
key: unit-test-${{ runner.os }}-${{ matrix.rust }} |
| 86 |
- run: rustup default ${{ matrix.rust }} |
| 87 |
- run: rustup update ${{ matrix.rust }} --no-self-update |
| 88 |
- run: rustc -Vv |
| 89 |
- run: cargo test -p divan -p divan-macros |
| 90 |
|
| 91 |
# Run tests in `src/` and `tests/` using Miri. |
| 92 |
unit-test-miri: |
| 93 |
name: Unit Test (Miri) |
| 94 |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 95 |
runs-on: ubuntu-latest |
| 96 |
steps: |
| 97 |
- uses: actions/checkout@v4 |
| 98 |
- uses: actions/[email protected] |
| 99 |
with: |
| 100 |
path: | |
| 101 |
${{ env.CARGO_HOME }} |
| 102 |
target |
| 103 |
key: miri-${{ runner.os }} |
| 104 |
- run: rustup default nightly |
| 105 |
- run: rustup update nightly --no-self-update |
| 106 |
- run: rustup component add miri |
| 107 |
- run: rustc -Vv |
| 108 |
- run: cargo miri test -p divan -p divan-macros |
| 109 |
|
| 110 |
# Run `examples/` directory as tests. |
| 111 |
examples-test: |
| 112 |
name: Examples Test |
| 113 |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 114 |
runs-on: ${{ matrix.os }} |
| 115 |
strategy: |
| 116 |
matrix: |
| 117 |
os: |
| 118 |
- ubuntu-latest |
| 119 |
- macos-latest |
| 120 |
- windows-latest |
| 121 |
rust: |
| 122 |
- stable |
| 123 |
- nightly |
| 124 |
env: |
| 125 |
DIVAN_ITEMS_COUNT: 0 |
| 126 |
DIVAN_BYTES_COUNT: 1 |
| 127 |
DIVAN_CHARS_COUNT: 2 |
| 128 |
steps: |
| 129 |
- uses: actions/checkout@v4 |
| 130 |
- uses: actions/[email protected] |
| 131 |
with: |
| 132 |
path: | |
| 133 |
${{ env.CARGO_HOME }} |
| 134 |
target |
| 135 |
key: examples-test-${{ runner.os }}-${{ matrix.rust }} |
| 136 |
- run: rustup default ${{ matrix.rust }} |
| 137 |
- run: rustup update ${{ matrix.rust }} --no-self-update |
| 138 |
- run: rustc -Vv |
| 139 |
- run: cargo test -p examples --all-features --benches |
| 140 |
|
| 141 |
# Run `examples/` directory as benchmarks. |
| 142 |
examples-bench: |
| 143 |
name: Examples Bench |
| 144 |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 145 |
runs-on: ${{ matrix.os }} |
| 146 |
env: |
| 147 |
# Run each benchmark within 2 seconds. |
| 148 |
DIVAN_MAX_TIME: 2 |
| 149 |
strategy: |
| 150 |
matrix: |
| 151 |
os: |
| 152 |
- ubuntu-latest |
| 153 |
- macos-latest |
| 154 |
- windows-latest |
| 155 |
steps: |
| 156 |
- uses: actions/checkout@v4 |
| 157 |
- uses: actions/[email protected] |
| 158 |
with: |
| 159 |
path: | |
| 160 |
${{ env.CARGO_HOME }} |
| 161 |
target |
| 162 |
key: examples-bench-${{ runner.os }} |
| 163 |
- run: rustup update stable --no-self-update |
| 164 |
- run: rustc -Vv |
| 165 |
- run: cargo bench -p examples --all-features |
| 166 |
|
| 167 |
# Run `internal_benches/` directory as benchmarks. |
| 168 |
internals-bench: |
| 169 |
name: Internals Bench |
| 170 |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 171 |
runs-on: ${{ matrix.os }} |
| 172 |
env: |
| 173 |
# Run each benchmark within 2 seconds. |
| 174 |
DIVAN_MAX_TIME: 2 |
| 175 |
strategy: |
| 176 |
matrix: |
| 177 |
os: |
| 178 |
- ubuntu-latest |
| 179 |
- macos-latest |
| 180 |
- windows-latest |
| 181 |
steps: |
| 182 |
- uses: actions/checkout@v4 |
| 183 |
- uses: actions/[email protected] |
| 184 |
with: |
| 185 |
path: | |
| 186 |
${{ env.CARGO_HOME }} |
| 187 |
target |
| 188 |
key: internals-bench-${{ runner.os }} |
| 189 |
- run: rustup update stable --no-self-update |
| 190 |
- run: rustc -Vv |
| 191 |
- run: cargo bench -p internal_benches --all-features |