Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI Cleanup #400

Closed
wants to merge 71 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f08ddb9
Add BoringSSL build to main CI
bifurcation Oct 27, 2023
6206cc6
Add nasm dependency
bifurcation Oct 27, 2023
1de6c0e
Merge branch 'main' into boring-ci
bifurcation Oct 27, 2023
e73ebb2
Fix typos
bifurcation Oct 27, 2023
6c0471f
CI Cleanup
bifurcation Oct 27, 2023
3e42187
Make cache key consistent
bifurcation Oct 27, 2023
cf428c7
Make a matrix of non-clang-tidy builds
bifurcation Oct 27, 2023
eba1ee4
Fix validity issues in CI YAML
bifurcation Oct 27, 2023
4be26c8
Comment out most of the workflow
bifurcation Oct 27, 2023
02c0ea3
Reset to an earlier commit and comment things out
bifurcation Oct 27, 2023
cd71e79
Start preparing main matrix
bifurcation Oct 27, 2023
e836567
Run crypto in matrix
bifurcation Oct 27, 2023
03593ba
Add interop testing and legacy build
bifurcation Oct 27, 2023
364419b
Set deployment target to both off and on
bifurcation Oct 27, 2023
a00fbf4
Vibe check
bifurcation Oct 27, 2023
1a1c542
Set a value for the latest deployment target
bifurcation Oct 27, 2023
7a2d9b0
Remove the legacy macOS build
bifurcation Oct 27, 2023
858198d
Add clang-tidy build and normalize build directories
bifurcation Oct 27, 2023
8c9dcdc
Put build directories in temp storage
bifurcation Oct 27, 2023
61f7b9a
Remove interop testing
bifurcation Oct 28, 2023
799b005
Add composable build workflow
bifurcation Oct 28, 2023
e0865ca
Debug main_ci.yml
bifurcation Oct 28, 2023
87ea34d
Merge branch 'main' into ci-cleanup
bifurcation Oct 28, 2023
b5fb39f
Fix typo
bifurcation Oct 28, 2023
6be706a
Add action YAML
bifurcation Oct 28, 2023
c7aa60d
Name the file 'action.yml'
bifurcation Oct 28, 2023
09adbc7
Refer to the action without .yml
bifurcation Oct 28, 2023
c719dd6
Move checkout to main workflow
bifurcation Oct 28, 2023
3646930
Move 'env' within 'runs'
bifurcation Oct 28, 2023
8c227ad
Remove 'env' from action
bifurcation Oct 28, 2023
2343728
Revert action changes
bifurcation Oct 28, 2023
b4c334e
Really revert
bifurcation Oct 28, 2023
2f73ea0
Add interop and clang-tidy builds
bifurcation Oct 28, 2023
d08ff13
Take off the brakes
bifurcation Oct 28, 2023
a7a5142
Fix broken references
bifurcation Oct 28, 2023
e849c30
Disable Windows build
bifurcation Oct 29, 2023
54e213c
Start moving build tasks to a composite action
bifurcation Oct 30, 2023
0117556
Actually use composite action
bifurcation Oct 30, 2023
bee7467
Understand runner.os
bifurcation Oct 30, 2023
5fc6e43
Move dependencies to composite action
bifurcation Oct 30, 2023
791a9ba
Action typos
bifurcation Oct 30, 2023
170e453
Move cache control to action
bifurcation Oct 30, 2023
07d8c0f
Typo in input name
bifurcation Oct 30, 2023
c2703d4
Restor other steps, now using composite action
bifurcation Oct 30, 2023
c760137
Re-add fetch-depth
bifurcation Oct 30, 2023
48fac67
Re-enable all builds
bifurcation Oct 30, 2023
0a76413
Merge branch 'main' into ci-cleanup
bifurcation Oct 30, 2023
239cac6
Try to gain insight into Windows failure
bifurcation Oct 30, 2023
fde8f6a
Really disable non-Windows builds
bifurcation Oct 30, 2023
7c859e3
Change canary value
bifurcation Oct 30, 2023
c0e5294
Introduce some Microsoft-specific behavior
bifurcation Oct 30, 2023
6051900
Re-add some tolerance
bifurcation Oct 31, 2023
eec77aa
Fix Windows typo
bifurcation Oct 31, 2023
a8d9bfa
Skip Message Protection tests
bifurcation Oct 31, 2023
e395a07
Don't run spurious tests
bifurcation Oct 31, 2023
8f51800
Only run interop tests when testing interop
bifurcation Oct 31, 2023
8046138
Manually run tests to provide more output
bifurcation Nov 1, 2023
495731a
Save the cache to speed up future builds
bifurcation Nov 1, 2023
892761b
Typo
bifurcation Nov 1, 2023
9c31d3a
Manually run MLSpp unit tests
bifurcation Nov 1, 2023
98f1ad7
Revert to ctest; add SANITIZERS=ON
bifurcation Nov 2, 2023
c8271db
Re-enable interop tests
bifurcation Nov 2, 2023
b043ae1
Revert more changes
bifurcation Nov 2, 2023
5d5b52a
Fix Windows check
bifurcation Nov 2, 2023
82183b2
Remove sanitizers
bifurcation Nov 2, 2023
c04949f
Re-add sanitizers
bifurcation Nov 2, 2023
a079818
Revert "Re-add sanitizers"
bifurcation Nov 2, 2023
0c3d792
Revert "Remove sanitizers"
bifurcation Nov 2, 2023
ff99638
Revert "Revert "Remove sanitizers""
bifurcation Nov 2, 2023
03554b9
Revert "Revert "Re-add sanitizers""
bifurcation Nov 2, 2023
13dca8a
Re-enable other tests
bifurcation Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Install build prerequisites

inputs:
cache-dir:
description: Where to put vcpkg cache
required: true

runs:
using: "composite"
steps:
- name: Capture vcpkg revision for use in cache key
shell: bash
run: |
git -C vcpkg rev-parse HEAD > vcpkg_commit.txt

- name: Restore cache
uses: actions/cache@v3
with:
path: ${{ inputs.cache-dir }}
key: v01-vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg_commit.txt', 'alternatives/*/vcpkg.json') }}
restore-keys: |
v01-vcpkg-${{ runner.os }}

- name: Install dependencies (macOS)
if: ${{ runner.os == 'macOS' }}
shell: bash
run: |
brew install llvm pkg-config nasm
ln -s "/usr/local/opt/llvm/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "/usr/local/opt/llvm/bin/clang-tidy" "/usr/local/bin/clang-tidy"

- name: Install dependencies (Ubuntu)
if: ${{ runner.os == 'Linux' }}
shell: bash
run: |
sudo apt-get install -y linux-headers-$(uname -r) nasm
252 changes: 68 additions & 184 deletions .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ on:
env:
CMAKE_BUILD_PARALLEL_LEVEL: 3
CTEST_OUTPUT_ON_FAILURE: 1
CMAKE_BUILD_DIR: ${{ github.workspace }}/build
CMAKE_BUILD_OPENSSL3_DIR: ${{ github.workspace }}/build_openssl3
CMAKE_BUILD_BORINGSSL_DIR: ${{ github.workspace }}/build_boringssl
VCPKG_BINARY_SOURCES: files,${{ github.workspace }}/build/cache,readwrite
VCPKG_TOOLCHAIN_FILE: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
VCPKG_REPO: ${{ github.workspace }}/vcpkg
CACHE_VERSION: v01
CACHE_NAME: vcpkg
VCPKG_BINARY_SOURCES: files,${{ github.workspace }}/vcpkg_cache,readwrite
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake

jobs:
formatting-check:
Expand All @@ -34,226 +28,116 @@ jobs:
include-regex: '^\./(src|include|test|cmd)/.*\.(cpp|h)$'
fallback-style: 'Mozilla'

quick-linux-interop-check:
build-and-unit-test:
needs: formatting-check
name: Quick Linux Check and Interop
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

# write the commit hash of vcpkg to a text file so we can use it in the
# hashFiles for cache
- run: |
git -C ${{ env.VCPKG_REPO }} rev-parse HEAD > vcpkg_commit.txt

# First, attempt to pull key key, if that is not present, pull one of the
# restore-keys so we do not need to build from scratch.
# CACHE_VERSION - provide a way to reset cache
# CACHE_NAME - name of the cache in order to manage it
# matrix.os - cache per OS and version
# hashFiles - Recache if the vcpkg files change
- name: Restore Cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/build/cache
key: ${{ env.CACHE_VERSION }}-${{ env.CACHE_NAME }}-ubuntu-latest-${{ hashFiles('vcpkg_commit.txt', 'vcpkg.json', 'alternatives/openssl_3/vcpkg.json') }}
restore-keys: |
${{ env.CACHE_VERSION }}-${{ env.CACHE_NAME }}-ubuntu-latest

- name: Dependencies
run: |
sudo apt-get install -y linux-headers-$(uname -r) nasm

- name: Restore cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/build/cache
key: VCPKG-BinaryCache-${{ runner.os }}

- name: Build (OpenSSL 1.1)
run: |
cmake -B "${{ env.CMAKE_BUILD_DIR }}" -DTESTING=ON -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_TOOLCHAIN_FILE }}"
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target all

- name: Unit Test (OpenSSL 1.1)
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target test

- name: Build (Interop Harness)
run: |
cd cmd/interop
cmake -B build -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_TOOLCHAIN_FILE }}"
cmake --build build

- name: Test self-interop
run: |
make -C cmd/interop self-test

- name: Test interop on test vectors
run: |
make -C cmd/interop interop-test

- name: Test gRPC live interop with self
run: |
cd cmd/interop
./grpc-self-test.sh

- name: Build (OpenSSL 3)
run: |
cmake -B "${{ env.CMAKE_BUILD_OPENSSL3_DIR }}" -DTESTING=ON -DVCPKG_MANIFEST_DIR="alternatives/openssl_3" -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_TOOLCHAIN_FILE }}"
cmake --build "${{ env.CMAKE_BUILD_OPENSSL3_DIR }}"

- name: Unit Test (OpenSSL 3)
run: |
cmake --build "${{ env.CMAKE_BUILD_OPENSSL3_DIR }}" --target test

- name: Build (BoringSSL)
run: |
cmake -B "${{ env.CMAKE_BUILD_BORINGSSL_DIR }}" -DTESTING=ON -DVCPKG_MANIFEST_DIR="alternatives/boringssl_1.1" -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_TOOLCHAIN_FILE }}"
cmake --build "${{ env.CMAKE_BUILD_BORINGSSL_DIR }}"

- name: Unit Test (BoringSSL)
run: |
cmake --build "${{ env.CMAKE_BUILD_BORINGSSL_DIR }}" --target test

platform-sanitizer-tests:
if: github.event.pull_request.draft == false
needs: quick-linux-interop-check
name: Build and test platforms using sanitizers and clang-tidy
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
crypto: [openssl_1.1, openssl_3, boringssl]
include:
- os: windows-latest
ossl3-vcpkg-dir: "alternatives\\openssl_3"
boringssl-vcpkg-dir: "alternatives\\boringssl_1.1"
ctest-target: RUN_TESTS
- os: ubuntu-latest
ossl3-vcpkg-dir: "alternatives/openssl_3"
boringssl-vcpkg-dir: "alternatives/boringssl_1.1"
ctest-target: test
- os: macos-latest
ossl3-vcpkg-dir: "alternatives/openssl_3"
boringssl-vcpkg-dir: "alternatives/boringssl_1.1"
ctest-target: test

env:
BUILD_DIR: "${RUNNER_TEMP}/build_${{ matrix.crypto }}"
CRYPTO_DIR: "./alternatives/${{ matrix.crypto }}"

steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

# write the commit hash of vcpkg to a text file so we can use it in the
# hashFiles for cache
- run: |
git -C ${{ env.VCPKG_REPO }} rev-parse HEAD > vcpkg_commit.txt

# First, attempt to pull key key, if that is not present, pull one of the
# restore-keys so we do not need to build from scratch.
# CACHE_VERSION - provide a way to reset cache
# CACHE_NAME - name of the cache in order to manage it
# matrix.os - cache per OS and version
# hashFiles - Recache if the vcpkg files change
- name: Restore Cache
uses: actions/cache@v3
- uses: ./.github/actions/build
with:
path: ${{ github.workspace }}/build/cache
key: ${{ env.CACHE_VERSION }}-${{ env.CACHE_NAME }}-${{ matrix.os }}-${{ hashFiles('vcpkg_commit.txt', 'vcpkg.json', 'alternatives/openssl_3/vcpkg.json') }}
restore-keys: |
${{ env.CACHE_VERSION }}-${{ env.CACHE_NAME }}-${{ matrix.os }}
cache-dir: ${{ github.workspace }}/vcpkg_cache

- name: Dependencies (macOs)
if: ${{ matrix.os == 'macos-latest' }}
- name: Build
run: |
brew install llvm pkg-config nasm
ln -s "/usr/local/opt/llvm/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "/usr/local/opt/llvm/bin/clang-tidy" "/usr/local/bin/clang-tidy"
# XXX(RLB): If we do not have SANITIZERS=ON here, the Windows CI builds
# hang in the middle of unit testing.
cmake -B "${{ env.BUILD_DIR }}" -DVCPKG_MANIFEST_DIR="${{ env.CRYPTO_DIR }}" -DTESTING=ON -DSANITIZERS=ON
cmake --build "${{ env.BUILD_DIR }}"

- name: Dependencies (Ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Unit Test
run: |
sudo apt-get install -y linux-headers-$(uname -r) nasm
cmake --build "${{ env.BUILD_DIR }}" --target "${{ matrix.ctest-target}}"

interop-test:
if: github.event.pull_request.draft == false
needs: build-and-unit-test
name: Interop test
runs-on: ubuntu-latest

- name: Build (OpenSSL 1.1)
run: |
cmake -B "${{ env.CMAKE_BUILD_DIR }}" -DTESTING=ON -DCLANG_TIDY=ON -DSANITIZERS=ON -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_TOOLCHAIN_FILE }}"
cmake --build "${{ env.CMAKE_BUILD_DIR }}"
env:
BUILD_DIR: "${RUNNER_TEMP}/build_openssl_1.1"
CRYPTO_DIR: "./alternatives/openssl_1.1"

steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Unit Test (OpenSSL 1.1)
- uses: ./.github/actions/build
with:
cache-dir: ${{ github.workspace }}/vcpkg_cache

- name: Build
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target "${{ matrix.ctest-target}}"
cmake -B "${{ env.BUILD_DIR }}" -DVCPKG_MANIFEST_DIR="${{ env.CRYPTO_DIR }}"
cmake --build "${{ env.BUILD_DIR }}"

- name: Build (OpenSSL 3)
- name: Build (Interop Harness)
run: |
cmake -B "${{ env.CMAKE_BUILD_OPENSSL3_DIR }}" -DTESTING=ON -DCLANG_TIDY=ON -DSANITIZERS=ON -DVCPKG_MANIFEST_DIR="${{ matrix.ossl3-vcpkg-dir }}" -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_TOOLCHAIN_FILE }}"
cmake --build "${{ env.CMAKE_BUILD_OPENSSL3_DIR }}"
cd cmd/interop
cmake -B build
cmake --build build

- name: Unit Test (OpenSSL 3)
- name: Test self-interop
run: |
cmake --build "${{ env.CMAKE_BUILD_OPENSSL3_DIR }}" --target "${{ matrix.ctest-target}}"
make -C cmd/interop self-test

- name: Build (BoringSSL)
- name: Test interop on test vectors
run: |
cmake -B "${{ env.CMAKE_BUILD_BORINGSSL_DIR }}" -DTESTING=ON -DCLANG_TIDY=ON -DSANITIZERS=ON -DVCPKG_MANIFEST_DIR="${{ matrix.boringssl-vcpkg-dir }}" -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_TOOLCHAIN_FILE }}"
cmake --build "${{ env.CMAKE_BUILD_BORINGSSL_DIR }}"
make -C cmd/interop interop-test

- name: Unit Test (BoringSSL)
- name: Test gRPC live interop with self
run: |
cmake --build "${{ env.CMAKE_BUILD_BORINGSSL_DIR }}" --target "${{ matrix.ctest-target}}"
cd cmd/interop
./grpc-self-test.sh

old-macos-compatibility:
clang-tidy:
if: github.event.pull_request.draft == false
needs: quick-linux-interop-check
name: Build for older MacOS
runs-on: macos-latest
needs: build-and-unit-test
name: Build with clang-tidy
runs-on: ubuntu-latest
strategy:
matrix:
crypto: [openssl_1.1, openssl_3, boringssl]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might clean things up to make this the vcpkg manifest directory instead of crypto. It would make it more generic. Maybe it is a premature optimization. Just wanted to mention.


env:
CMAKE_BUILD_DIR: ${{ github.workspace }}/build
VCPKG_BINARY_SOURCES: files,${{ github.workspace }}/build/cache,readwrite
MACOSX_DEPLOYMENT_TARGET: 10.11
BUILD_DIR: "${RUNNER_TEMP}/build_${{ matrix.crypto }}"
CRYPTO_DIR: "./alternatives/${{ matrix.crypto }}"

steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

# write the commit hash of vcpkg to a text file so we can use it in the
# hashFiles for cache
- run: |
git -C ${{ env.VCPKG_REPO }} rev-parse HEAD > vcpkg_commit.txt

# First, attempt to pull key key, if that is not present, pull one of the
# restore-keys so we do not need to build from scratch.
# CACHE_VERSION - provide a way to reset cache
# CACHE_NAME - name of the cache in order to manage it
# matrix.os - cache per OS and version
# hashFiles - Recache if the vcpkg files change
- name: Restore Cache
uses: actions/cache@v3
- uses: ./.github/actions/build
with:
path: ${{ github.workspace }}/build/cache
key: ${{ env.CACHE_VERSION }}-${{ env.CACHE_NAME }}-macos-latest-legacy-${{ hashFiles('vcpkg_commit.txt', 'vcpkg.json', 'alternatives/openssl_3/vcpkg.json') }}
restore-keys: |
${{ env.CACHE_VERSION }}-${{ env.CACHE_NAME }}-macos-latest-legacy
${{ env.CACHE_VERSION }}-${{ env.CACHE_NAME }}-macos-latest
cache-dir: ${{ github.workspace }}/vcpkg_cache

- name: Dependencies
- name: Build with clang-tidy
run: |
brew install llvm pkg-config
ln -s "/usr/local/opt/llvm/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "/usr/local/opt/llvm/bin/clang-tidy" "/usr/local/bin/clang-tidy"

- name: Build
run: |
cmake -B "${{ env.CMAKE_BUILD_DIR }}" -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_TOOLCHAIN_FILE }}"
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target mlspp

cmake -B "${{ env.BUILD_DIR }}" -DVCPKG_MANIFEST_DIR="${{ env.CRYPTO_DIR }}" \
-DTESTING=ON -DCLANG_TIDY=ON -DSANITIZERS=ON
cmake --build "${{ env.BUILD_DIR }}"
25 changes: 12 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.13)

project(mlspp
VERSION 0.1
Expand Down Expand Up @@ -44,28 +44,24 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
add_compile_options(-Wall -pedantic -Wextra -Werror -Wmissing-declarations)
elseif(MSVC)
add_compile_options(/W4 /WX)
add_definitions(-DWINDOWS)

# MSVC helpfully recommends safer equivalents for things like
# getenv, but they are not portable.
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

if (SANITIZERS)
message("Enabling sanitizers")
add_definitions(-DSANITIZERS)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(SANITIZERS "-fsanitize=address -fsanitize=undefined")
add_compile_options(-fsanitize=address -fsanitize=undefined)
add_link_options(-fsanitize=address -fsanitize=undefined)
elseif(MSVC)
set(SANITIZERS "/fsanitize=address")
# MSVC uses a different flag, and doesn't require passing it to the linker
add_compile_options("/fsanitize=address")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZERS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZERS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZERS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZERS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SANITIZERS}")
add_definitions(-DSANITIZERS)
elseif (SANITIZERS AND MSVC)
message("Enabling sanitizers")
add_definitions("/fsanitize=address")
endif()

if(CLANG_TIDY)
Expand Down Expand Up @@ -96,6 +92,9 @@ endif()
### Dependencies
###

# Configure vcpkg to only build release libraries
set(VCPKG_BUILD_TYPE release)

# External libraries
find_package(OpenSSL REQUIRED)
if ( OPENSSL_FOUND )
Expand Down
File renamed without changes.
Loading