aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: a7641de82dedc476b3d12d4c1c1a217f57ecc2f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: tests

on:
  push:
    branches:
      - "*"
    # not on tags
  pull_request:

env:
  BLAKE3_CI: "1"
  RUSTFLAGS: "-D warnings"
  RUST_BACKTRACE: "1"

jobs:
  cargo_tests:
    name: ${{ matrix.target.name }} ${{ matrix.channel }}
    runs-on: ${{ matrix.target.os }}
    strategy:
      fail-fast: false
      matrix:
        target: [
          { "os": "ubuntu-latest",  "toolchain": "x86_64-unknown-linux-gnu", "name": "Linux GNU" },
          { "os": "macOS-latest",   "toolchain": "x86_64-apple-darwin",      "name": "macOS" },
          { "os": "windows-latest", "toolchain": "x86_64-pc-windows-msvc",   "name": "Windows MSVC" },
          { "os": "windows-latest", "toolchain": "x86_64-pc-windows-gnu",    "name": "Windows GNU" }
        ]
        channel: [stable, beta, nightly]

    steps:
    - uses: actions/checkout@v1
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ format('{0}-{1}', matrix.channel, matrix.target.toolchain) }}
        profile: minimal
        override: true
    # Print the compiler version, for debugging.
    - name: print compiler version
      run: cargo run --quiet
      working-directory: ./tools/compiler_version
    # Print out instruction set support, for debugging.
    - name: print instruction set support
      run: cargo run --quiet
      working-directory: ./tools/instruction_set_support
    # Default tests plus Rayon and RustCrypto trait implementations.
    - run: cargo test --features=rayon,traits-preview
    # no_std tests.
    - run: cargo test --no-default-features

    # A matrix of different test settings:
    # - debug vs release
    # - assembly vs Rust+C intrinsics vs pure Rust intrinsics
    # - different levels of SIMD support
    #
    # Full SIMD support.
    - run: cargo test --features=
    - run: cargo test --features=prefer_intrinsics
    - run: cargo test --features=pure
    - run: cargo test --features= --release
    - run: cargo test --features=prefer_intrinsics --release
    - run: cargo test --features=pure --release
    # No AVX-512.
    - run: cargo test --features=no_avx512
    - run: cargo test --features=no_avx512,prefer_intrinsics
    - run: cargo test --features=no_avx512,pure
    - run: cargo test --features=no_avx512 --release
    - run: cargo test --features=no_avx512,prefer_intrinsics --release
    - run: cargo test --features=no_avx512,pure --release
    # No AVX2.
    - run: cargo test --features=no_avx512,no_avx2
    - run: cargo test --features=no_avx512,no_avx2,prefer_intrinsics
    - run: cargo test --features=no_avx512,no_avx2,pure
    - run: cargo test --features=no_avx512,no_avx2 --release
    - run: cargo test --features=no_avx512,no_avx2,prefer_intrinsics --release
    - run: cargo test --features=no_avx512,no_avx2,pure --release
    # No SSE4.1
    - run: cargo test --features=no_avx512,no_avx2,no_sse41
    - run: cargo test --features=no_avx512,no_avx2,no_sse41,prefer_intrinsics
    - run: cargo test --features=no_avx512,no_avx2,no_sse41,pure
    - run: cargo test --features=no_avx512,no_avx2,no_sse41 --release
    - run: cargo test --features=no_avx512,no_avx2,no_sse41,prefer_intrinsics --release
    - run: cargo test --features=no_avx512,no_avx2,no_sse41,pure --release
    # No SSE2
    - run: cargo test --features=no_avx512,no_avx2,no_sse41,no_sse2
    - run: cargo test --features=no_avx512,no_avx2,no_sse41,no_sse2,prefer_intrinsics
    - run: cargo test --features=no_avx512,no_avx2,no_sse41,no_sse2,pure
    - run: cargo test --features=no_avx512,no_avx2,no_sse41,no_sse2 --release
    - run: cargo test --features=no_avx512,no_avx2,no_sse41,no_sse2,prefer_intrinsics --release
    - run: cargo test --features=no_avx512,no_avx2,no_sse41,no_sse2,pure --release

    # Test benchmarks. RUSTC_BOOTSTRAP=1 lets this run on non-nightly toolchains.
    - run: cargo test --benches --features=rayon
      env:
        RUSTC_BOOTSTRAP: 1
    # Test vectors.
    - name: test vectors
      run: cargo test
      working-directory: ./test_vectors
    - name: test vectors intrinsics
      run: cargo test --features=prefer_intrinsics
      working-directory: ./test_vectors
    - name: test vectors pure
      run: cargo test --features=pure
      working-directory: ./test_vectors
    # Test b3sum.
    - name: test b3sum
      run: cargo test
      working-directory: ./b3sum
    - name: test b3sum --no-default-features
      run: cargo test --no-default-features
      working-directory: ./b3sum
    # Test C code.
    - name: cargo test C bindings assembly
      run: cargo test
      working-directory: ./c/blake3_c_rust_bindings
    - name: cargo test C bindings intrinsics
      run: cargo test --features=prefer_intrinsics
      working-directory: ./c/blake3_c_rust_bindings
    # Reference impl doc test.
    - name: reference impl doc test
      run: cargo test
      working-directory: ./reference_impl

  cross_tests:
    name: cross ${{ matrix.arch }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        arch:
          - i586-unknown-linux-musl
          - i686-unknown-linux-musl
          - armv7-unknown-linux-gnueabihf
          - aarch64-unknown-linux-gnu
          - mips-unknown-linux-gnu

    steps:
    - uses: actions/checkout@v1
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
    - run: cargo install cross
    # Test the portable implementation on everything.
    - run: cross test --target ${{ matrix.arch }}
    # Test building for ancient i386 processors without guaranteed SSE2 support.
    - run: cross rustc --target ${{ matrix.arch }} -- -C target-cpu=i386
      if: startsWith(matrix.arch, 'i586-') || startsWith(matrix.arch, 'i686-')
    # Test the NEON implementation on ARM targets.
    - run: cross test --target ${{ matrix.arch }} --features=neon
      if: startsWith(matrix.arch, 'armv7-') || startsWith(matrix.arch, 'aarch64-')
    # NEON is enabled by default on aarch64, disabling it through the no_neon feature.
    - run: cross test --target ${{ matrix.arch }} --features=no_neon
      if: startsWith(matrix.arch, 'aarch64-')
    # Test vectors. Note that this uses a hacky script due to path dependency limitations.
    - run: ./test_vectors/cross_test.sh --target ${{ matrix.arch }}
    # C code. Same issue with the hacky script.
    - run: ./c/blake3_c_rust_bindings/cross_test.sh --target ${{ matrix.arch }}
    - run: ./c/blake3_c_rust_bindings/cross_test.sh --target ${{ matrix.arch }} --features=neon
      if: startsWith(matrix.arch, 'armv7-') || startsWith(matrix.arch, 'aarch64-')
    - run: ./c/blake3_c_rust_bindings/cross_test.sh --target ${{ matrix.arch }} --features=no_neon
      if: startsWith(matrix.arch, 'aarch64-')

  # Currently only on x86.
  c_tests:
    name: C Makefile tests
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    # Test the intrinsics-based implementations.
    - run: make -f Makefile.testing test
      working-directory: ./c
    - run: make -f Makefile.testing clean && rm blake3_sse2.c
      working-directory: ./c
    - run: BLAKE3_NO_SSE2=1 make -f Makefile.testing test
      working-directory: ./c
    - run: make -f Makefile.testing clean && rm blake3_sse41.c
      working-directory: ./c
    - run: BLAKE3_NO_SSE2=1 BLAKE3_NO_SSE41=1 make -f Makefile.testing test
      working-directory: ./c
    - run: make -f Makefile.testing clean && rm blake3_avx2.c
      working-directory: ./c
    - run: BLAKE3_NO_SSE2=1 BLAKE3_NO_SSE41=1 BLAKE3_NO_AVX2=1 make -f Makefile.testing test
      working-directory: ./c
    - run: make -f Makefile.testing clean && rm blake3_avx512.c
      working-directory: ./c
    - run: BLAKE3_NO_SSE2=1 BLAKE3_NO_SSE41=1 BLAKE3_NO_AVX2=1 BLAKE3_NO_AVX512=1 make -f Makefile.testing test
      working-directory: ./c
    # Test the assembly implementations.
    - run: make -f Makefile.testing test_asm
      working-directory: ./c
    - run: make -f Makefile.testing clean && rm blake3_sse2_x86-64_unix.S
      working-directory: ./c
    - run: BLAKE3_NO_SSE2=1 make -f Makefile.testing test_asm
      working-directory: ./c
    - run: make -f Makefile.testing clean && rm blake3_sse41_x86-64_unix.S
      working-directory: ./c
    - run: BLAKE3_NO_SSE2=1 BLAKE3_NO_SSE41=1 make -f Makefile.testing test_asm
      working-directory: ./c
    - run: make -f Makefile.testing clean && rm blake3_avx2_x86-64_unix.S
      working-directory: ./c
    - run: BLAKE3_NO_SSE2=1 BLAKE3_NO_SSE41=1 BLAKE3_NO_AVX2=1 make -f Makefile.testing test_asm
      working-directory: ./c
    - run: make -f Makefile.testing clean && rm blake3_avx512_x86-64_unix.S
      working-directory: ./c
    - run: BLAKE3_NO_SSE2=1 BLAKE3_NO_SSE41=1 BLAKE3_NO_AVX2=1 BLAKE3_NO_AVX512=1 make -f Makefile.testing test_asm
      working-directory: ./c
    # Restore the files we deleted above.
    - run: git checkout .
    # Build the example.
    - run: make -f Makefile.testing example
      working-directory: ./c