1name: CI 2permissions: read-all 3 4on: 5 # For manual tests. 6 workflow_dispatch: 7 push: 8 tags: 9 - "*" # new tag version, like `0.8.4` or else 10 branches: 11 - master 12 pull_request: 13 branches: 14 - master 15 16jobs: 17 build-linux: 18 permissions: 19 contents: write 20 outputs: 21 digests-gcc: ${{ steps.hash-gcc.outputs.hashes }} 22 digests-clang: ${{ steps.hash-clang.outputs.hashes }} 23 name: Build Linux 24 runs-on: ubuntu-latest 25 strategy: 26 matrix: 27 cxx: [g++-10, clang++-12] 28 fail-fast: false 29 steps: 30 - uses: actions/checkout@v2 31 - name: cmake 32 run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . 33 - name: build 34 run: make -j 35 - name: test 36 run: ./flattests 37 - name: make flatc executable 38 run: | 39 chmod +x flatc 40 ./flatc --version 41 - name: flatc tests 42 run: python3 tests/flatc/main.py 43 - name: upload build artifacts 44 uses: actions/upload-artifact@v1 45 with: 46 name: Linux flatc binary ${{ matrix.cxx }} 47 path: flatc 48 # Below if only for release. 49 - name: Zip file 50 if: startsWith(github.ref, 'refs/tags/') 51 run: zip Linux.flatc.binary.${{ matrix.cxx }}.zip flatc 52 - name: Release zip file 53 uses: softprops/action-gh-release@v1 54 if: startsWith(github.ref, 'refs/tags/') 55 with: 56 files: Linux.flatc.binary.${{ matrix.cxx }}.zip 57 - name: Generate SLSA subjects - clang 58 if: matrix.cxx == 'clang++-12' && startsWith(github.ref, 'refs/tags/') 59 id: hash-clang 60 run: echo "::set-output name=hashes::$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" 61 - name: Generate SLSA subjects - gcc 62 if: matrix.cxx == 'g++-10' && startsWith(github.ref, 'refs/tags/') 63 id: hash-gcc 64 run: echo "::set-output name=hashes::$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" 65 66 build-windows: 67 permissions: 68 contents: write 69 outputs: 70 digests: ${{ steps.hash.outputs.hashes }} 71 name: Build Windows 2019 72 runs-on: windows-2019 73 steps: 74 - uses: actions/checkout@v2 75 - name: Add msbuild to PATH 76 uses: microsoft/setup-msbuild@v1.1 77 - name: cmake 78 run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON . 79 - name: build 80 run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 81 - name: test 82 run: Release\flattests.exe 83 - name: flatc tests 84 run: python3 tests/flatc/main.py --flatc Release\flatc.exe 85 - name: upload build artifacts 86 uses: actions/upload-artifact@v1 87 with: 88 name: Windows flatc binary 89 path: Release\flatc.exe 90 # Below if only for release. 91 - name: Zip file 92 if: startsWith(github.ref, 'refs/tags/') 93 run: move Release/flatc.exe . && Compress-Archive flatc.exe Windows.flatc.binary.zip 94 - name: Release binary 95 uses: softprops/action-gh-release@v1 96 if: startsWith(github.ref, 'refs/tags/') 97 with: 98 files: Windows.flatc.binary.zip 99 - name: Generate SLSA subjects 100 if: startsWith(github.ref, 'refs/tags/') 101 id: hash 102 shell: bash 103 run: echo "::set-output name=hashes::$(sha256sum Windows.flatc.binary.zip | base64 -w0)" 104 105 build-windows-2017: 106 name: Build Windows 2017 107 runs-on: windows-2019 108 steps: 109 - uses: actions/checkout@v2 110 - name: Add msbuild to PATH 111 uses: microsoft/setup-msbuild@v1.1 112 - name: cmake 113 run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . 114 - name: build tool version 15 (VS 2017) 115 run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=15.0 116 - name: test 117 run: Release\flattests.exe 118 119 build-windows-2015: 120 name: Build Windows 2015 121 runs-on: windows-2019 122 steps: 123 - uses: actions/checkout@v2 124 - name: Add msbuild to PATH 125 uses: microsoft/setup-msbuild@v1.1 126 - name: cmake 127 run: cmake -G "Visual Studio 14 2015" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . 128 - name: build tool version 14 (VS 2015) 129 run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0 130 - name: test 131 run: Release\flattests.exe 132 133 build-dotnet-windows: 134 name: Build .NET Windows 135 runs-on: windows-2019 136 strategy: 137 matrix: 138 configuration: [ 139 '', 140 '-p:UnsafeByteBuffer=true', 141 # Fails two tests currently. 142 #'-p:EnableSpanT=true,UnsafeByteBuffer=true' 143 ] 144 steps: 145 - uses: actions/checkout@v2 146 - name: Setup .NET Core SDK 147 uses: actions/setup-dotnet@v1.9.0 148 with: 149 dotnet-version: '3.1.x' 150 - name: Build 151 run: | 152 cd tests\FlatBuffers.Test 153 dotnet new sln --force --name FlatBuffers.Core.Test 154 dotnet sln FlatBuffers.Core.Test.sln add FlatBuffers.Core.Test.csproj 155 dotnet build -c Release ${{matrix.configuration}} -o out FlatBuffers.Core.Test.sln 156 - name: Run 157 run: | 158 cd tests\FlatBuffers.Test 159 out\FlatBuffers.Core.Test.exe 160 161 build-mac-intel: 162 permissions: 163 contents: write 164 outputs: 165 digests: ${{ steps.hash.outputs.hashes }} 166 name: Build Mac (for Intel) 167 runs-on: macos-latest 168 steps: 169 - uses: actions/checkout@v2 170 - name: cmake 171 run: cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_FLATC_EXECUTABLE=_build/Release/flatc -DFLATBUFFERS_STRICT_MODE=ON . 172 - name: build 173 # NOTE: we need this _build dir to not have xcodebuild's default ./build dir clash with the BUILD file. 174 run: xcodebuild -toolchain clang -configuration Release -target flattests SYMROOT=$(PWD)/_build 175 - name: check that the binary is x86_64 176 run: | 177 info=$(file _build/Release/flatc) 178 echo $info 179 echo $info | grep "Mach-O 64-bit executable x86_64" 180 - name: test 181 run: _build/Release/flattests 182 - name: make flatc executable 183 run: | 184 chmod +x _build/Release/flatc 185 ./_build/Release/flatc --version 186 - name: flatc tests 187 run: python3 tests/flatc/main.py --flatc ./_build/Release/flatc 188 - name: upload build artifacts 189 uses: actions/upload-artifact@v1 190 with: 191 name: Mac flatc binary 192 path: _build/Release/flatc 193 # Below if only for release. 194 - name: Zip file 195 if: startsWith(github.ref, 'refs/tags/') 196 run: mv _build/Release/flatc . && zip MacIntel.flatc.binary.zip flatc 197 - name: Release binary 198 uses: softprops/action-gh-release@v1 199 if: startsWith(github.ref, 'refs/tags/') 200 with: 201 files: MacIntel.flatc.binary.zip 202 - name: Generate SLSA subjects 203 if: startsWith(github.ref, 'refs/tags/') 204 id: hash 205 run: echo "::set-output name=hashes::$(shasum -a 256 MacIntel.flatc.binary.zip | base64)" 206 207 build-mac-universal: 208 permissions: 209 contents: write 210 outputs: 211 digests: ${{ steps.hash.outputs.hashes }} 212 name: Build Mac (universal build) 213 runs-on: macos-latest 214 steps: 215 - uses: actions/checkout@v2 216 - name: cmake 217 run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_FLATC_EXECUTABLE=_build/Release/flatc -DFLATBUFFERS_STRICT_MODE=ON . 218 - name: build 219 # NOTE: we need this _build dir to not have xcodebuild's default ./build dir clash with the BUILD file. 220 run: xcodebuild -toolchain clang -configuration Release -target flattests SYMROOT=$(PWD)/_build 221 - name: check that the binary is "universal" 222 run: | 223 info=$(file _build/Release/flatc) 224 echo $info 225 echo $info | grep "Mach-O universal binary with 2 architectures" 226 - name: test 227 run: _build/Release/flattests 228 - name: make flatc executable 229 run: | 230 chmod +x _build/Release/flatc 231 ./_build/Release/flatc --version 232 - name: upload build artifacts 233 uses: actions/upload-artifact@v1 234 with: 235 name: Mac flatc binary 236 path: _build/Release/flatc 237 # Below if only for release. 238 - name: Zip file 239 if: startsWith(github.ref, 'refs/tags/') 240 run: mv _build/Release/flatc . && zip Mac.flatc.binary.zip flatc 241 - name: Release binary 242 uses: softprops/action-gh-release@v1 243 if: startsWith(github.ref, 'refs/tags/') 244 with: 245 files: Mac.flatc.binary.zip 246 - name: Generate SLSA subjects 247 if: startsWith(github.ref, 'refs/tags/') 248 id: hash 249 run: echo "::set-output name=hashes::$(shasum -a 256 Mac.flatc.binary.zip | base64)" 250 251 build-android: 252 name: Build Android (on Linux) 253 runs-on: ubuntu-latest 254 steps: 255 - uses: actions/checkout@v2 256 - name: set up JDK 1.8 257 uses: actions/setup-java@v1 258 with: 259 java-version: 1.8 260 - name: set up flatc 261 run: | 262 cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . 263 make -j 264 echo "${PWD}" >> $GITHUB_PATH 265 - name: build 266 working-directory: android 267 run: gradle clean build 268 269 build-generator: 270 name: Check Generated Code 271 runs-on: ubuntu-latest 272 strategy: 273 matrix: 274 cxx: [g++-10, clang++-12] 275 steps: 276 - uses: actions/checkout@v2 277 - name: cmake 278 run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j 279 - name: Generate 280 run: scripts/check_generate_code.py 281 - name: Generate gRPC 282 run: scripts/check-grpc-generated-code.py 283 284 build-benchmarks: 285 name: Build Benchmarks (on Linux) 286 runs-on: ubuntu-latest 287 strategy: 288 matrix: 289 cxx: [g++-10] 290 steps: 291 - uses: actions/checkout@v2 292 - name: cmake 293 run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j 294 - name: Run benchmarks 295 run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}} 296 - name: Upload benchmarks results 297 uses: actions/upload-artifact@v1 298 with: 299 name: Linux flatbenchmark results ${{matrix.cxx}} 300 path: benchmarks/results_${{matrix.cxx}} 301 302 build-java: 303 name: Build Java 304 runs-on: ubuntu-latest 305 steps: 306 - uses: actions/checkout@v2 307 - name: test 308 working-directory: tests 309 run: bash JavaTest.sh 310 311 build-kotlin-macos: 312 name: Build Kotlin MacOS 313 runs-on: macos-latest 314 steps: 315 - name: Checkout 316 uses: actions/checkout@v2 317 - uses: gradle/wrapper-validation-action@v1 318 - uses: actions/setup-java@v2 319 with: 320 distribution: 'adopt-hotspot' 321 java-version: '11' 322 - name: Build 323 working-directory: kotlin 324 run: ./gradlew clean iosX64Test macosX64Test 325 326 build-kotlin-linux: 327 name: Build Kotlin Linux 328 runs-on: ubuntu-latest 329 steps: 330 - name: Checkout 331 uses: actions/checkout@v2 332 - uses: actions/setup-java@v2 333 with: 334 distribution: 'adopt-hotspot' 335 java-version: '11' 336 - uses: gradle/wrapper-validation-action@v1 337 - name: Build 338 working-directory: kotlin 339 # we are using docker's version of gradle 340 # so no need for wrapper validadation or user 341 # gradlew 342 run: gradle jvmMainClasses jvmTest jsTest jsBrowserTest 343 344 build-rust: 345 name: Build Rust 346 runs-on: ubuntu-latest 347 steps: 348 - uses: actions/checkout@v2 349 - name: test 350 working-directory: tests 351 run: bash RustTest.sh 352 353 build-python: 354 name: Build Python 355 runs-on: ubuntu-latest 356 steps: 357 - uses: actions/checkout@v2 358 - name: test 359 working-directory: tests 360 run: bash PythonTest.sh 361 362 build-go: 363 name: Build Go 364 runs-on: ubuntu-latest 365 steps: 366 - uses: actions/checkout@v2 367 - name: flatc 368 # FIXME: make test script not rely on flatc 369 run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j 370 - name: test 371 working-directory: tests 372 run: bash GoTest.sh 373 374 build-swift: 375 name: Build Swift 376 runs-on: ubuntu-latest 377 steps: 378 - uses: actions/checkout@v2 379 - name: test 380 working-directory: tests/FlatBuffers.Test.Swift 381 run: sh SwiftTest.sh 382 383 build-swift-wasm: 384 name: Build Swift Wasm 385 runs-on: ubuntu-latest 386 container: 387 image: ghcr.io/swiftwasm/carton:0.15.3 388 steps: 389 - uses: actions/checkout@v2 390 - name: Setup Wasmer 391 uses: wasmerio/setup-wasmer@v1 392 - name: Test 393 working-directory: tests/FlatBuffers.Test.Swift.Wasm 394 run: carton test 395 396 build-ts: 397 name: Build TS 398 runs-on: ubuntu-latest 399 steps: 400 - uses: actions/checkout@v2 401 - name: flatc 402 # FIXME: make test script not rely on flatc 403 run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j 404 - name: compile 405 run: npm run compile 406 - name: test 407 working-directory: tests 408 run: python3 TypeScriptTest.py 409 410 build-dart: 411 name: Build Dart 412 runs-on: ubuntu-latest 413 steps: 414 - uses: actions/checkout@v2 415 - uses: dart-lang/setup-dart@v1 416 with: 417 sdk: stable 418 - name: flatc 419 # FIXME: make test script not rely on flatc 420 run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j 421 - name: test 422 working-directory: tests 423 run: bash DartTest.sh 424 425 release-digests: 426 if: startsWith(github.ref, 'refs/tags/') 427 needs: [build-linux, build-windows, build-mac-intel, build-mac-universal] 428 outputs: 429 digests: ${{ steps.hash.outputs.digests }} 430 runs-on: ubuntu-latest 431 steps: 432 - name: Merge results 433 id: hash 434 env: 435 LINUXGCC_DIGESTS: "${{ needs.build-linux.outputs.digests-gcc }}" 436 LINUXCLANG_DIGESTS: "${{ needs.build-linux.outputs.digests-clang }}" 437 MAC_DIGESTS: "${{ needs.build-mac-universal.outputs.digests }}" 438 MACINTEL_DIGESTS: "${{ needs.build-mac-intel.outputs.digests }}" 439 WINDOWS_DIGESTS: "${{ needs.build-windows.outputs.digests }}" 440 run: | 441 set -euo pipefail 442 echo "$LINUXGCC_DIGESTS" | base64 -d > checksums.txt 443 echo "$LINUXCLANG_DIGESTS" | base64 -d >> checksums.txt 444 echo "$MAC_DIGESTS" | base64 -d >> checksums.txt 445 echo "$MACINTEL_DIGESTS" | base64 -d >> checksums.txt 446 echo "$WINDOWS_DIGESTS" | base64 -d >> checksums.txt 447 echo "::set-output name=digests::$(cat checksums.txt | base64 -w0)" 448 449 provenance: 450 if: startsWith(github.ref, 'refs/tags/') 451 needs: [release-digests] 452 permissions: 453 actions: read # To read the workflow path. 454 id-token: write # To sign the provenance. 455 contents: write # To add assets to a release. 456 uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.2.0 457 with: 458 base64-subjects: "${{ needs.release-digests.outputs.digests }}" 459 upload-assets: true # Optional: Upload to a new release 460