|
| 1 | +name: all-tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + |
| 9 | +permissions: write-all |
| 10 | + |
| 11 | +jobs: |
| 12 | + # From https://doc.rust-lang.org/rustc/instrument-coverage.html |
| 13 | + gen-coverage: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + timeout-minutes: 30 |
| 16 | + |
| 17 | + environment: |
| 18 | + name: ${{ github.ref_name != 'main' && 'testing' || 'unrestricted' }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + submodules: recursive |
| 24 | + |
| 25 | + - uses: dtolnay/rust-toolchain@nightly |
| 26 | + with: |
| 27 | + components: llvm-tools-preview |
| 28 | + - uses: Swatinem/rust-cache@v2 |
| 29 | + - uses: taiki-e/install-action@cargo-llvm-cov |
| 30 | + |
| 31 | + - name: Regular Tests |
| 32 | + run: cargo llvm-cov test --no-report --tests --all-features |
| 33 | + |
| 34 | + - name: Doc Tests |
| 35 | + run: cargo llvm-cov test --no-report --doc --all-features |
| 36 | + |
| 37 | + - name: Coverage Report |
| 38 | + run: cargo llvm-cov report --doctests --cobertura > coverage.xml |
| 39 | + |
| 40 | + - name: Generate Coverage Report |
| 41 | + uses: clearlyip/code-coverage-report-action@v5 |
| 42 | + id: code_coverage_report_action |
| 43 | + # Don't run for dependabot unless you fix PR comment permissions |
| 44 | + if: ${{ github.actor != 'dependabot[bot]'}} |
| 45 | + with: |
| 46 | + # Location of the generated coverage file |
| 47 | + filename: 'coverage.xml' |
| 48 | + only_list_changed_files: true |
| 49 | + badge: true |
| 50 | + fail_on_negative_difference: true |
| 51 | + |
| 52 | + - name: Add Coverage PR Comment |
| 53 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 54 | + # Make sure the report was generated and that the event is actually a pull request, run if failed or success |
| 55 | + if: steps.code_coverage_report_action.outputs.file != '' && github.event_name == 'pull_request' && (success() || failure()) |
| 56 | + with: |
| 57 | + recreate: true |
| 58 | + path: code-coverage-results.md |
| 59 | + |
| 60 | + # See https://crates.io/crates/cargo-hack |
| 61 | + build_features: |
| 62 | + runs-on: ubuntu-latest |
| 63 | + timeout-minutes: 30 |
| 64 | + |
| 65 | + environment: |
| 66 | + name: ${{ github.ref_name != 'main' && 'testing' || 'unrestricted' }} |
| 67 | + |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - uses: awalsh128/cache-apt-pkgs-action@v1 |
| 72 | + with: |
| 73 | + packages: libsodium-dev |
| 74 | + |
| 75 | + - uses: dtolnay/rust-toolchain@stable |
| 76 | + - uses: Swatinem/rust-cache@v2 |
| 77 | + - uses: taiki-e/install-action@cargo-hack |
| 78 | + |
| 79 | + - run: | |
| 80 | + cargo hack --each-feature build --ignore-private |
| 81 | + cargo hack --each-feature test --ignore-private --no-run |
| 82 | +
|
| 83 | + # From https://github.com/rust-lang/miri |
| 84 | + miri: |
| 85 | + runs-on: ubuntu-latest |
| 86 | + timeout-minutes: 30 |
| 87 | + |
| 88 | + environment: |
| 89 | + name: ${{ github.ref_name != 'main' && 'testing' || 'unrestricted' }} |
| 90 | + |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v3 |
| 93 | + |
| 94 | + - uses: awalsh128/cache-apt-pkgs-action@v1 |
| 95 | + with: |
| 96 | + packages: libsodium-dev |
| 97 | + |
| 98 | + - name: Install Miri |
| 99 | + run: | |
| 100 | + rustup toolchain install nightly --component miri |
| 101 | + rustup override set nightly |
| 102 | + cargo miri setup |
| 103 | + - name: Test with Miri |
| 104 | + run: | |
| 105 | + MIRIFLAGS="-Zmiri-disable-isolation" \ |
| 106 | + cargo miri test --all-features |
| 107 | +
|
| 108 | + # From https://doc.rust-lang.org/cargo/guide/continuous-integration.html#verifying-rust-version |
| 109 | + # See https://crates.io/crates/cargo-hack |
| 110 | + msrv: |
| 111 | + runs-on: ubuntu-latest |
| 112 | + timeout-minutes: 30 |
| 113 | + |
| 114 | + environment: |
| 115 | + name: ${{ github.ref_name != 'main' && 'testing' || 'unrestricted' }} |
| 116 | + |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@v4 |
| 119 | + |
| 120 | + - uses: awalsh128/cache-apt-pkgs-action@v1 |
| 121 | + with: |
| 122 | + packages: libsodium-dev |
| 123 | + |
| 124 | + - uses: dtolnay/rust-toolchain@stable |
| 125 | + - uses: Swatinem/rust-cache@v2 |
| 126 | + - uses: taiki-e/install-action@cargo-hack |
| 127 | + |
| 128 | + - run: cargo hack check --version-range 1.79 --all-targets --all-features --ignore-private |
| 129 | + |
| 130 | + test: |
| 131 | + strategy: |
| 132 | + matrix: |
| 133 | + os: [ubuntu, windows, macos] |
| 134 | + arch: [x86_64] |
| 135 | + include: |
| 136 | + - os: macos |
| 137 | + arch: arm |
| 138 | + triple: aarch64-apple-darwin |
| 139 | + runs-on: ${{ format('{0}-latest', matrix.os) }} |
| 140 | + timeout-minutes: 30 |
| 141 | + |
| 142 | + environment: |
| 143 | + name: ${{ github.ref_name != 'main' && 'testing' || 'unrestricted' }} |
| 144 | + |
| 145 | + steps: |
| 146 | + - uses: actions/checkout@v4 |
| 147 | + with: |
| 148 | + submodules: recursive |
| 149 | + |
| 150 | + - uses: dtolnay/rust-toolchain@stable |
| 151 | + if: ${{ matrix.triple == null }} |
| 152 | + - uses: dtolnay/rust-toolchain@stable |
| 153 | + if: ${{ matrix.triple }} |
| 154 | + with: |
| 155 | + target: ${{ matrix.triple }} |
| 156 | + |
| 157 | + - uses: Swatinem/rust-cache@v2 |
| 158 | + |
| 159 | + - run: cargo test --verbose --all-features |
0 commit comments