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

[plz rebase merge] Cache Sentry Builds to S3 #3392

Merged
merged 2 commits into from
Jul 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
213 changes: 208 additions & 5 deletions .github/workflows/protocol-build-dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# workflows/protocol-build-depdendencies.yml
# workflows/protocol-build-dependencies.yml
#
# Build & Publish Fractal protocol dependencies
# Build and publish Fractal version-compatible builds of the Fractal protocol dependencies to AWS S3
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
run: |
# configure and build OpenSSL with -O3 flag
./config --release
make
make -j

###################################################################################
############################# LINUX UBUNTU STEPS START ############################
Expand All @@ -102,7 +102,7 @@ jobs:
run: |
# configure and build OpenSSL with -O3 flag
./config --release
make
make -j

###################################################################################
################################# PUBLISH STEPS START #############################
Expand Down Expand Up @@ -140,11 +140,14 @@ jobs:

###################################################################################

- name: Checkout Git Repository
- name: Checkout Fractal Git Repository
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && failure() }}
uses: actions/checkout@v2

- name: Setup Python-based notifications
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && failure() }}
working-directory: .github/workflows/helpers
shell: bash
run: ./notifications/setup_notifications.sh

- name: Notify Slack on Workflow Error (Only on Push/Workflow_dispatch Events)
Expand All @@ -160,7 +163,7 @@ jobs:
slack_post(slack_webhook=SLACK_WEBHOOK, channel=SLACK_CHANNEL, body=BODY)

notify-slack-openssl:
name: Notify Slack
name: Notify Slack for OpenSSL Build
needs: [build-and-publish-openssl]
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && success() }}
runs-on: ubuntu-20.04
Expand All @@ -183,3 +186,203 @@ jobs:
BODY = f"Fractal `OpenSSL libcrypto` Static Library Deployed to Production via Upload to AWS S3 (<https://github.com/fractal/fractal/actions/runs/${{ github.run_id }} | see logs>)"

slack_post(slack_webhook=SLACK_WEBHOOK, channel=SLACK_CHANNEL, body=BODY, title=TITLE)

build-and-publish-sentry:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}

# Platforms to build on/for
strategy:
matrix:
config:
- name: "Sentry (Windows)"
os: windows-2019
- name: "Sentry (macOS)"
os: macos-10.15
- name: "Sentry (Linux Ubuntu)"
os: ubuntu-20.04

env:
windows-tar-name: fractal-windows-sentry-shared-lib.tar.gz
macos-tar-name: fractal-macos-sentry-shared-lib.tar.gz
linux-tar-name: fractal-linux-sentry-shared-lib.tar.gz
headers-tar-name: fractal-sentry-headers.tar.gz
s3-bucket-uri: s3://fractal-protocol-shared-libs
s3-bucket-region: us-east-1

steps:
################################# CONFIG STEPS START ###############################

- name: Checkout Sentry Native Git Repository
uses: actions/checkout@v2
with:
repository: getsentry/sentry-native
ref: "0.4.10" # GitHub Tag of the Sentry release we use
submodules: recursive # Sentry uses (nested) submodules for external dependencies

# To publish Sentry shared library and crashpad executable to AWS S3
- name: Configure AWS S3 CLI
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
aws-region: ${{ env.s3-bucket-region }}

###################################################################################
################################ WINDOWS STEPS START ##############################

- name: Install cmake via Chocolatey on Windows GHA Machine
if: runner.os == 'Windows'
uses: crazy-max/ghaction-chocolatey@v1
with:
args: install cmake --pre --no-progress --installargs 'ADD_CMAKE_TO_PATH=System'

- name: On Windows, Set up Visual Studio Developer Command Prompt (for nmake)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: On Windows, Set up NASM
if: runner.os == 'Windows'
uses: ilammy/setup-nasm@v1

- name: Build Sentry Native on Windows
if: runner.os == 'Windows'
shell: cmd # Acts as Visual Studio Developer Command Prompt due to ilammy/msvc-dev-cmd@v1
run: |
REM configure and build Sentry Native for Windows on the GitHub Actions Windows OS Version
cmake -S . ^
-B build ^
-D CMAKE_BUILD_TYPE=Release ^
-D SENTRY_BUILD_SHARED_LIBS=ON ^
-D SENTRY_BUILD_RUNTIMESTATIC=ON ^
-D SENTRY_BUILD_TESTS=OFF ^
-D SENTRY_BACKEND=crashpad ^
-G Ninja
ninja -C build
move build\crashpad_build\handler\crashpad_handler.exe .
move build\sentry.dll .
move build\sentry.lib .

###################################################################################
################################# MACOS STEPS START ###############################

- name: Build Sentry Native on macOS
if: runner.os == 'macOS'
env:
FRACTAL_OSX_SYSROOT: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
run: |
# configure and build Sentry Native
cmake -S . \
-B build \
-D CMAKE_BUILD_TYPE=Release \
-D SENTRY_BUILD_SHARED_LIBS=ON \
-D SENTRY_BUILD_RUNTIMESTATIC=ON \
-D SENTRY_BUILD_TESTS=OFF \
-D SENTRY_BACKEND=crashpad
cd build
make -j

# move files to location for publish steps to tar
mv crashpad_build/handler/crashpad_handler ..
mv libsentry.dylib ..

###################################################################################
############################# LINUX UBUNTU STEPS START ############################

- name: Build Sentry Native on Linux Ubuntu
if: runner.os == 'Linux'
run: |
# install needed dependencies
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev

# configure and build Sentry Native
cmake -S . \
-B build \
-D CMAKE_BUILD_TYPE=Release \
-D SENTRY_BUILD_SHARED_LIBS=ON \
-D SENTRY_BUILD_RUNTIMESTATIC=ON \
-D SENTRY_BUILD_TESTS=OFF \
-D SENTRY_BACKEND=crashpad
cd build
make -j

# move files to location for publish steps to tar
mv crashpad_build/handler/crashpad_handler ..
mv libsentry.so ..

###################################################################################
################################# PUBLISH STEPS START #############################

# Only publish to AWS S3 on Push events (code merged into `dev`), PRs only build to test
- name: Tar Sentry and Upload to AWS S3 (Only on Push/Workflow_dispatch Events)
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
shell: bash --noprofile --norc -eo pipefail {0}
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
tar -zcvf ${{ env.linux-tar-name }} libsentry.so crashpad_handler
aws s3 cp ${{ env.linux-tar-name }} ${{ env.s3-bucket-uri }}/${{ env.linux-tar-name }}
elif [ "$RUNNER_OS" == "Windows" ]; then
tar -zcvf ${{ env.windows-tar-name }} sentry.dll sentry.lib crashpad_handler.exe
aws s3 cp ${{ env.windows-tar-name }} ${{ env.s3-bucket-uri }}/${{ env.windows-tar-name }}
else
tar -zcvf ${{ env.macos-tar-name }} libsentry.dylib crashpad_handler
aws s3 cp ${{ env.macos-tar-name }} ${{ env.s3-bucket-uri }}/${{ env.macos-tar-name }}
fi

# Only run once, as headers are identical on every OS
- name: Tar Sentry headers and Upload to AWS S3 (Only on Push/Workflow_dispatch Events)
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && runner.os == 'Linux'}}
run: |
# tar and upload the Sentry headers
tar -zcvf ${{ env.headers-tar-name }} include
aws s3 cp ${{ env.headers-tar-name }} ${{ env.s3-bucket-uri }}/${{ env.headers-tar-name }}

###################################################################################

- name: Checkout Fractal Git Repository
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && failure() }}
uses: actions/checkout@v2

- name: Setup Python-based notifications
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && failure() }}
working-directory: .github/workflows/helpers
shell: bash
run: ./notifications/setup_notifications.sh

- name: Notify Slack on Workflow Error (Only on Push/Workflow_dispatch Events)
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && failure() }}
shell: python3 {0}
run: |
from notifications.slack_bot import slack_post

SLACK_WEBHOOK = "${{ secrets.SLACK_HOOKS_ENDPOINT }}"
SLACK_CHANNEL = "#alerts-prod"
BODY = f"@releases :rotating_light: Failed to deploy Sentry Shared Library to AWS S3, investigate immediately :rotating_light: (<https://github.com/fractal/fractal/actions/runs/${{ github.run_id }} | see logs>)"

slack_post(slack_webhook=SLACK_WEBHOOK, channel=SLACK_CHANNEL, body=BODY)

notify-slack-sentry:
name: Notify Slack for Sentry Build
needs: [build-and-publish-sentry]
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && success() }}
runs-on: ubuntu-20.04
steps:
- name: Checkout Git Repository
uses: actions/checkout@v2

- name: Setup Python-based notifications
working-directory: .github/workflows/helpers
run: ./notifications/setup_notifications.sh

- name: Notify Slack on Success
shell: python3 {0}
run: |
from notifications.slack_bot import slack_post

SLACK_WEBHOOK = "${{ secrets.SLACK_HOOKS_ENDPOINT }}"
SLACK_CHANNEL = "#alerts-prod"
TITLE = ":sentry: Sentry Shared Library Deployed :sentry:"
BODY = f"Fractal Sentry Static Library Deployed to Production via Upload to AWS S3 (<https://github.com/fractal/fractal/actions/runs/${{ github.run_id }} | see logs>)"

slack_post(slack_webhook=SLACK_WEBHOOK, channel=SLACK_CHANNEL, body=BODY, title=TITLE)
66 changes: 10 additions & 56 deletions protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ if (CPPCHECK AND ${CI} MATCHES "TRUE" AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
"--error-exitcode=1" # Propagate cppcheck errors to cmake
"--suppress=shiftTooManyBitsSigned"
"--suppress=*:${CMAKE_SOURCE_DIR}/fractal/clipboard/clipboard_osx.m" # suppress all warnings for clipboard_osx.m since cppcheck isn't supported on Objective-C
"--suppress=*:*/sentry-native/*.c" # Ignore errors that occur in sentry-native c files. We shouldn't ignore errors in sentry-native h files
"--suppress=*:*/sentry-native/vendor/*" # However, we should ignore errors in the c and h files of sentry-native's build dependencies
"--suppress=*:${CMAKE_SOURCE_DIR}/fractal/utils/lodepng.*" # suppress all lodepng warnings, since this is an external library that we should not touch
"-D__linux" # Needed for sentry.h to pass
"--inline-suppr" # Allow cppcheck-suppress comments in code
)
else()
Expand Down Expand Up @@ -227,7 +224,16 @@ else()
find_package(OpenSSL REQUIRED)
endif()


find_library(LIB_SENTRY NAMES sentry PATHS "${CMAKE_BINARY_DIR}/lib/${arch}/sentry/${CMAKE_SYSTEM_NAME}"
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
NO_CMAKE_FIND_ROOT_PATH)
if (NOT LIB_SENTRY)
message(FATAL_ERROR "Library sentry was not found! ${CMAKE_BINARY_DIR}/lib/${arch}/sentry/${CMAKE_SYSTEM_NAME}")
endif()

find_library(STATIC_SDL2 NAMES SDL2 SDL2-static PATHS "${CMAKE_BINARY_DIR}/lib/${arch}/SDL2/${CMAKE_SYSTEM_NAME}"
NO_DEFAULT_PATH
Expand All @@ -252,40 +258,6 @@ if ((NOT LIBMFX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
message(FATAL_ERROR "Library LIBMFX was not found! ${CMAKE_SOURCE_DIR}/lib/${arch}/mfx/${CMAKE_SYSTEM_NAME}")
endif()

#download and install Sentry CMake project
# This is fixed to sdk version 0.4.8
set(sentry_url https://github.com/getsentry/sentry-native/releases/download/0.4.10/sentry-native.zip)
set(sentry_dir sentry-native)
MESSAGE(VERBOSE ${CMAKE_SOURCE_DIR}/${sentry_dir})
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/${sentry_dir})
MESSAGE(STATUS "Downloading Sentry")
file(DOWNLOAD ${sentry_url} "${CMAKE_SOURCE_DIR}/${sentry_dir}.zip"
STATUS sentry_dl_status)
MESSAGE(VERBOSE ${sentry_dl_status})
file(MAKE_DIRECTORY ${sentry_dir})

execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xzf ${CMAKE_SOURCE_DIR}/${sentry_dir}.zip
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${sentry_dir}
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_SOURCE_DIR}/${sentry_dir}.zip
)
endif()

# Do this before setting the OSX compiler so we do not mess with the sentry-native build
message("Setting Sentry options")
set(SENTRY_BUILD_SHARED_LIBS ON CACHE BOOL "sentry create shared lib" FORCE)
set(SENTRY_BUILD_RUNTIMESTATIC ON CACHE BOOL "sentry runtimestatic" FORCE)
set(SENTRY_BACKEND crashpad CACHE STRING "sentry backend" FORCE)
add_subdirectory(sentry-native)

# set a standard location for the sentry shared lib so we can copy it into client/server build folders as a post build step
set_target_properties(sentry PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/sentry-native
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/sentry-native
)

#Set OSX compiler and SDK globally
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_C_COMPILER clang)
Expand All @@ -297,28 +269,10 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15) # deployment target must be <= than compiler SDK above
endif()

# Store compiler options of native libraries, for now, we simply pass in "-w" to disable warnings
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(NONFRACTAL_COMPILE_OPTIONS -w)
target_compile_options(mini_chromium PRIVATE ${NONFRACTAL_COMPILE_OPTIONS})
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_compile_options(crashpad_compat PRIVATE ${NONFRACTAL_COMPILE_OPTIONS})
endif()
target_compile_options(crashpad_util PRIVATE ${NONFRACTAL_COMPILE_OPTIONS})
target_compile_options(crashpad_client PRIVATE ${NONFRACTAL_COMPILE_OPTIONS})
target_compile_options(crashpad_snapshot PRIVATE ${NONFRACTAL_COMPILE_OPTIONS})
target_compile_options(crashpad_minidump PRIVATE ${NONFRACTAL_COMPILE_OPTIONS})
target_compile_options(crashpad_handler_lib PRIVATE ${NONFRACTAL_COMPILE_OPTIONS})
target_compile_options(crashpad_tools PRIVATE ${NONFRACTAL_COMPILE_OPTIONS})
target_compile_options(crashpad_handler PRIVATE ${NONFRACTAL_COMPILE_OPTIONS})
target_compile_options(sentry PRIVATE ${NONFRACTAL_COMPILE_OPTIONS})
endif()

# Tell CMake where to look for includes
# Use SYSTEM flag to not get warnings from their files
include_directories(${CMAKE_SOURCE_DIR}) # For #include <fractal/**> semantics
include_directories(SYSTEM include)
include_directories(SYSTEM sentry-native/include)
include_directories(SYSTEM ${CMAKE_BINARY_DIR}/include)
include_directories(SYSTEM ${CMAKE_BINARY_DIR}/include/ffmpeg)

Expand Down
20 changes: 4 additions & 16 deletions protocol/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,21 @@ set_target_properties(FractalClient PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/client/build${arch}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/client/build${arch})

# copy the sentry shared library to the build folder after the build
# copy the sentry shared library and crashpad handler to the build folder after the build
add_custom_command(
TARGET FractalClient POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/sentry-native/${CMAKE_SHARED_LIBRARY_PREFIX}sentry${CMAKE_SHARED_LIBRARY_SUFFIX}
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_BINARY_DIR}/lib/64/sentry/${CMAKE_SYSTEM_NAME}/
$<TARGET_FILE_DIR:FractalClient>)

# MacOS and Windows default to crashpad for Sentry, and crashpad_handler needs to be in
# the same folder as the executable
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_custom_command(
TARGET FractalClient POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/sentry-native/crashpad_build/handler/crashpad_handler
$<TARGET_FILE_DIR:FractalClient>)
add_custom_command(
TARGET FractalClient POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/client/fclient
${CMAKE_BINARY_DIR})
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_custom_command(
TARGET FractalClient POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/sentry-native/crashpad_build/handler/crashpad_handler.exe
$<TARGET_FILE_DIR:FractalClient>)
add_custom_command(
TARGET FractalClient POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
Expand Down Expand Up @@ -120,7 +108,7 @@ target_link_libraries(FractalClient
fractalLogging
fractalUtils
${STATIC_SDL2}
sentry
${LIB_SENTRY}
)

#[[
Expand Down
Loading