2024-05-10 13:07:03 +00:00
name : Lagom Template
on :
workflow_call :
inputs :
2024-05-08 23:33:51 +00:00
toolchain :
required : true
type : string
2024-05-10 13:07:03 +00:00
os_name :
required : true
type : string
os :
required : true
type : string
fuzzer :
required : false
type : string
default : 'NO_FUZZ'
2024-08-26 23:56:21 +00:00
clang_plugins :
required : false
type : boolean
default : false
2024-05-07 23:42:15 +00:00
env :
2024-08-27 22:43:14 +00:00
# runner.workspace = /home/runner/work/ladybird
# github.workspace = /home/runner/work/ladybird/ladybird
2024-06-03 12:40:19 +00:00
LADYBIRD_SOURCE_DIR : ${{ github.workspace }}
2024-05-07 23:42:15 +00:00
CCACHE_DIR : ${{ github.workspace }}/.ccache
2024-09-30 16:55:24 +00:00
VCPKG_ROOT : ${{ github.workspace }}/Build/vcpkg
2024-06-06 20:55:14 +00:00
VCPKG_BINARY_SOURCES : "clear;x-gha,readwrite"
2024-05-07 23:42:15 +00:00
2024-08-27 17:21:23 +00:00
# Use the compiler version for the ccache compiler hash. Otherwise, if plugins are enabled, the plugin .so files
# are included in the hash. This results in clean builds on every run as the .so files are rebuilt.
#
# Note: This only works because our plugins do not transform any code. If that becomes untrue, we must revisit this.
CCACHE_COMPILERCHECK : "%compiler% -v"
2024-05-07 23:42:15 +00:00
jobs :
CI :
2024-05-10 13:07:03 +00:00
runs-on : ${{ inputs.os }}
2024-05-07 23:42:15 +00:00
steps :
# Pull requests can trail behind `master` and can cause breakage if merging before running the CI checks on an updated branch.
# Luckily, GitHub creates and maintains a merge branch that is updated whenever the target or source branch is modified. By
# checking this branch out, we gain a stabler `master` at the cost of reproducibility.
- uses : actions/checkout@v4
if : ${{ github.event_name != 'pull_request' }}
- uses : actions/checkout@v4
if : ${{ github.event_name == 'pull_request' }}
with :
ref : refs/pull/${{ github.event.pull_request.number }}/merge
2024-05-10 13:07:03 +00:00
- name : Set Up Environment
2024-05-07 23:42:15 +00:00
uses : ./.github/actions/setup
with :
2024-05-10 13:07:03 +00:00
os : ${{ inputs.os_name }}
2024-05-07 23:42:15 +00:00
arch : 'Lagom'
# === PREPARE FOR BUILDING ===
- name : Assign Build Parameters
id : 'build-parameters'
run : |
2024-05-10 13:07:03 +00:00
if ${{ inputs.os_name == 'Linux' }} ; then
2024-05-08 23:33:51 +00:00
if ${{ inputs.toolchain == 'Clang' }} ; then
echo "host_cc=clang-18" >> "$GITHUB_OUTPUT"
echo "host_cxx=clang++-18" >> "$GITHUB_OUTPUT"
elif ${{ inputs.toolchain == 'GNU' }} ; then
echo "host_cc=gcc-13" >> "$GITHUB_OUTPUT"
echo "host_cxx=g++-13" >> "$GITHUB_OUTPUT"
fi
2024-05-10 13:07:03 +00:00
elif ${{ inputs.os_name == 'macOS' }} ; then
2024-06-19 12:19:24 +00:00
echo "host_cc=$(xcrun --find clang)" >> "$GITHUB_OUTPUT"
echo "host_cxx=$(xcrun --find clang++)" >> "$GITHUB_OUTPUT"
2024-05-07 23:42:15 +00:00
fi
2024-08-26 23:56:21 +00:00
if ${{ inputs.clang_plugins }} ; then
echo "ccache_key=${{ inputs.fuzzer }}-CLANG_PLUGINS" >> "$GITHUB_OUTPUT"
echo "cmake_options=-DENABLE_CLANG_PLUGINS=ON" >> "$GITHUB_OUTPUT"
else
echo "ccache_key=${{ inputs.fuzzer }}" >> "$GITHUB_OUTPUT"
echo "cmake_options=" >> "$GITHUB_OUTPUT"
fi
- name : Restore Caches
uses : ./.github/actions/cache-restore
id : 'cache-restore'
with :
os : ${{ inputs.os_name }}
arch : 'Lagom'
toolchain : ${{ inputs.toolchain }}
cache_key_extra : ${{ steps.build-parameters.outputs.ccache_key }}
2024-08-27 22:43:14 +00:00
ccache_path : ${{ env.CCACHE_DIR }}
2024-08-26 23:56:21 +00:00
download_cache_path : ${{ github.workspace }}/Build/caches
2024-06-14 16:14:37 +00:00
- name : Set dynamic environment variables
run : |
# Note: Required for vcpkg to use this compiler for its own builds.
echo "CC=${{ steps.build-parameters.outputs.host_cc }}" >> "$GITHUB_ENV"
echo "CXX=${{ steps.build-parameters.outputs.host_cxx }}" >> "$GITHUB_ENV"
2024-05-08 15:44:41 +00:00
# https://github.com/actions/runner-images/issues/9330
2024-05-10 13:07:03 +00:00
- name : Enable Microphone Access (macOS 14)
2024-11-07 22:16:47 +00:00
if : ${{ inputs.os_name == 'macOS' }}
2024-05-08 15:44:41 +00:00
run : sqlite3 $HOME/Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR IGNORE INTO access VALUES ('kTCCServiceMicrophone','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159,NULL,NULL,'UNUSED',1687786159);"
2024-05-07 23:42:15 +00:00
- name : Create Build Environment
2024-05-10 13:07:03 +00:00
if : ${{ inputs.fuzzer == 'NO_FUZZ' }}
2024-06-03 21:34:02 +00:00
working-directory : ${{ github.workspace }}
2024-05-07 23:42:15 +00:00
run : |
2024-08-27 18:31:12 +00:00
cmake --preset Sanitizer_CI -B Build \
2024-05-07 23:42:15 +00:00
-DINCLUDE_WASM_SPEC_TESTS=ON \
-DWASM_SPEC_TEST_SKIP_FORMATTING=ON \
2024-08-26 23:56:21 +00:00
${{ steps.build-parameters.outputs.cmake_options }} \
2024-10-07 12:23:34 +00:00
-DPython3_EXECUTABLE=${{ env.pythonLocation }}/bin/python \
2024-05-07 23:42:15 +00:00
-DCMAKE_C_COMPILER=${{ steps.build-parameters.outputs.host_cc }} \
-DCMAKE_CXX_COMPILER=${{ steps.build-parameters.outputs.host_cxx }}
2024-05-10 13:07:03 +00:00
- name : Create Build Environment
if : ${{ inputs.fuzzer == 'FUZZ' }}
2024-06-03 21:34:02 +00:00
working-directory : ${{ github.workspace }}
2024-05-10 13:07:03 +00:00
run : |
set -e
2024-07-17 17:03:09 +00:00
cmake --preset=CI -S Meta/Lagom -B ${{ github.workspace }}/Build/tools-build \
2024-06-07 21:41:53 +00:00
-DLAGOM_TOOLS_ONLY=ON \
2024-07-08 09:54:50 +00:00
-DINSTALL_LAGOM_TOOLS=ON \
2024-07-17 17:03:09 +00:00
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/Build/tools-install \
2024-10-07 12:23:34 +00:00
-DPython3_EXECUTABLE=${{ env.pythonLocation }}/bin/python \
2024-05-10 13:07:03 +00:00
-DCMAKE_C_COMPILER=gcc-13 \
-DCMAKE_CXX_COMPILER=g++-13 \
-Dpackage=LagomTools
2024-07-17 17:03:09 +00:00
ninja -C ${{ github.workspace }}/Build/tools-build install
2024-05-10 13:07:03 +00:00
2024-06-06 20:55:14 +00:00
cmake --preset Fuzzers_CI -B Build \
2024-10-07 12:23:34 +00:00
-DPython3_EXECUTABLE=${{ env.pythonLocation }}/bin/python \
2024-05-15 18:26:00 +00:00
-DCMAKE_C_COMPILER=${{ steps.build-parameters.outputs.host_cc }} \
-DCMAKE_CXX_COMPILER=${{ steps.build-parameters.outputs.host_cxx }} \
2024-07-17 17:03:09 +00:00
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Build/tools-install
2024-05-10 13:07:03 +00:00
2024-05-07 23:42:15 +00:00
# === BUILD ===
- name : Build
2024-06-03 21:34:02 +00:00
working-directory : ${{ github.workspace }}/Build
2024-05-07 23:42:15 +00:00
run : |
set -e
cmake --build .
2024-06-03 21:34:02 +00:00
cmake --install . --strip --prefix ${{ github.workspace }}/Install
2024-05-07 23:42:15 +00:00
- name : Enable the Ladybird Qt chrome
2024-05-10 13:07:03 +00:00
if : ${{ inputs.os_name == 'macOS' && inputs.fuzzer == 'NO_FUZZ' }}
2024-06-03 21:34:02 +00:00
working-directory : ${{ github.workspace }}
2024-05-07 23:42:15 +00:00
run : cmake -B Build -DENABLE_QT=ON
- name : Build the Ladybird Qt chrome
2024-05-10 13:07:03 +00:00
if : ${{ inputs.os_name == 'macOS' && inputs.fuzzer == 'NO_FUZZ' }}
2024-06-03 21:34:02 +00:00
working-directory : ${{ github.workspace }}/Build
2024-07-16 11:33:39 +00:00
run : cmake --build .
- name : Enable the AppKit chrome with Swift files
if : ${{ inputs.os_name == 'macOS' && inputs.fuzzer == 'NO_FUZZ' }}
working-directory : ${{ github.workspace }}
2024-08-17 18:53:39 +00:00
# FIXME: Don't force release build after https://github.com/LadybirdBrowser/ladybird/issues/1101 is fixed
run : cmake -B Build -DENABLE_QT=OFF -DENABLE_SWIFT=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
2024-07-16 11:33:39 +00:00
- name : Build the AppKit chrome with Swift files
if : ${{ inputs.os_name == 'macOS' && inputs.fuzzer == 'NO_FUZZ' }}
working-directory : ${{ github.workspace }}/Build
2024-05-07 23:42:15 +00:00
run : cmake --build .
- name : Save Caches
uses : ./.github/actions/cache-save
with :
arch : 'Lagom'
2024-08-27 22:43:14 +00:00
ccache_path : ${{ env.CCACHE_DIR }}
ccache_primary_key : ${{ steps.cache-restore.outputs.ccache_primary_key }}
2024-05-07 23:42:15 +00:00
# === TEST ===
- name : Test
2024-05-10 13:07:03 +00:00
if : ${{ inputs.fuzzer == 'NO_FUZZ' }}
2024-06-06 20:55:14 +00:00
working-directory : ${{ github.workspace }}
2024-08-27 18:31:12 +00:00
run : ctest --preset Sanitizer --output-on-failure --test-dir Build
2024-05-07 23:42:15 +00:00
env :
TESTS_ONLY : 1
- name : Upload LibWeb Test Artifacts
2024-05-10 13:07:03 +00:00
if : ${{ always() && inputs.fuzzer == 'NO_FUZZ' }}
2024-05-07 23:42:15 +00:00
uses : actions/upload-artifact@v4
with :
2024-05-10 13:07:03 +00:00
name : libweb-test-artifacts-${{ inputs.os_name }}
2024-11-09 17:50:33 +00:00
path : ${{ github.workspace }}/Build/UI/test-dumps
2024-05-07 23:42:15 +00:00
retention-days : 7
if-no-files-found : ignore
- name : Lints
2024-05-10 13:07:03 +00:00
if : ${{ inputs.os_name == 'Linux' && inputs.fuzzer == 'NO_FUZZ' }}
2024-05-07 23:42:15 +00:00
working-directory : ${{ github.workspace }}
run : |
set -e
2024-06-03 21:34:02 +00:00
git ls-files '*.ipc' | xargs ./Build/bin/IPCMagicLinter
2024-05-07 23:42:15 +00:00
env :
ASAN_OPTIONS : 'strict_string_checks=1:check_initialization_order=1:strict_init_order=1:detect_stack_use_after_return=1:allocator_may_return_null=1'
UBSAN_OPTIONS : 'print_stacktrace=1:print_summary=1:halt_on_error=1'