2020-11-07 15:54:27 +00:00
|
|
|
name: Build, lint, and test
|
|
|
|
|
|
|
|
on: [push, pull_request]
|
|
|
|
|
|
|
|
env:
|
|
|
|
# Don't mix these up!
|
|
|
|
# runner.workspace = /home/runner/work/serenity
|
|
|
|
# github.workspace = /home/runner/work/serenity/serenity
|
2021-04-20 00:51:04 +00:00
|
|
|
SERENITY_SOURCE_DIR: ${{ github.workspace }}
|
2020-11-07 15:54:27 +00:00
|
|
|
|
2021-07-01 13:34:38 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.head_ref || format('{0}-{1}', github.ref, github.run_number) }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-11-07 15:54:27 +00:00
|
|
|
jobs:
|
2021-02-04 02:04:22 +00:00
|
|
|
build_and_test_serenity:
|
2021-01-04 02:08:48 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2021-05-23 21:33:52 +00:00
|
|
|
debug-options: ['ALL_DEBUG', 'NORMAL_DEBUG']
|
2021-02-04 02:04:22 +00:00
|
|
|
os: [ubuntu-20.04]
|
2021-03-02 17:40:11 +00:00
|
|
|
# If ccache is broken and you would like to bust the ccache cache on Github Actions, increment this:
|
|
|
|
ccache-mark: [0]
|
2020-11-07 15:54:27 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2021-01-04 02:08:48 +00:00
|
|
|
# Set default Python to python 3.x, and set Python path such that pip install works properly
|
|
|
|
- uses: actions/setup-python@v2
|
2020-11-07 15:54:27 +00:00
|
|
|
|
|
|
|
# === OS SETUP ===
|
|
|
|
|
|
|
|
# Do we need to update the package cache first?
|
|
|
|
# sudo apt-get update -qq
|
2021-01-04 02:08:48 +00:00
|
|
|
- name: "Install Ubuntu dependencies"
|
2020-11-07 15:54:27 +00:00
|
|
|
# These packages are already part of the ubuntu-20.04 image:
|
2021-05-29 16:07:32 +00:00
|
|
|
# cmake clang-format-11 gcc-10 g++-10 libstdc++-10-dev libgmp-dev npm shellcheck
|
2021-05-21 10:04:55 +00:00
|
|
|
# Packages below aren't.
|
|
|
|
#
|
|
|
|
# We add the canonical-server/server-backports PPA to get updated QEMU releases without having to manage
|
|
|
|
# yet another cache in github actions
|
2020-12-30 21:45:54 +00:00
|
|
|
run: |
|
2021-05-21 10:04:55 +00:00
|
|
|
sudo add-apt-repository ppa:canonical-server/server-backports
|
2020-12-30 21:45:54 +00:00
|
|
|
sudo apt-get update
|
2021-05-29 16:07:32 +00:00
|
|
|
sudo apt-get install libmpfr-dev libmpc-dev ninja-build e2fsprogs qemu-utils qemu-system-i386 ccache
|
2020-11-07 15:54:27 +00:00
|
|
|
- name: Use GCC 10 instead
|
2021-05-29 16:07:32 +00:00
|
|
|
run: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10
|
2021-01-04 02:08:48 +00:00
|
|
|
|
|
|
|
- name: Install JS dependencies
|
2021-05-09 22:11:42 +00:00
|
|
|
run: sudo npm install -g prettier@2.2.1
|
2021-01-04 02:08:48 +00:00
|
|
|
- name: Install Python dependencies
|
|
|
|
# The setup-python action set default python to python3.x. Note that we are not using system python here.
|
|
|
|
run: |
|
|
|
|
python -m pip install --upgrade pip
|
|
|
|
pip install flake8 requests
|
2020-11-07 15:54:27 +00:00
|
|
|
- name: Check versions
|
2021-05-21 10:04:55 +00:00
|
|
|
run: set +e; g++ --version; g++-10 --version; clang-format --version; clang-format-11 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version
|
2020-11-07 15:54:27 +00:00
|
|
|
|
|
|
|
# === PREPARE FOR BUILDING ===
|
|
|
|
|
|
|
|
- name: Lint (Phase 1/2)
|
|
|
|
run: ${{ github.workspace }}/Meta/lint-ci.sh
|
2021-03-02 17:40:11 +00:00
|
|
|
- name: Prepare useful stamps
|
|
|
|
id: stamps
|
|
|
|
shell: cmake -P {0}
|
|
|
|
run: |
|
|
|
|
string(TIMESTAMP current_date "%Y_%m_%d_%H_%M_%S" UTC)
|
|
|
|
# Output everything twice to make it visible both in the logs
|
|
|
|
# *and* as actual output variable, in this order.
|
|
|
|
message(" set-output name=time::${current_date}")
|
|
|
|
message("::set-output name=time::${current_date}")
|
2021-04-18 06:34:26 +00:00
|
|
|
message(" set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}")
|
|
|
|
message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}")
|
2020-11-07 15:54:27 +00:00
|
|
|
- name: Toolchain cache
|
2021-06-03 12:42:40 +00:00
|
|
|
# TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged.
|
|
|
|
uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b
|
|
|
|
env:
|
|
|
|
CACHE_SKIP_SAVE: ${{ github.event_name == 'pull_request' }}
|
2020-11-07 15:54:27 +00:00
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/Toolchain/Cache/
|
2021-04-18 06:34:26 +00:00
|
|
|
# This assumes that *ALL* LibC and LibPthread headers have an impact on the Toolchain.
|
2020-11-07 15:54:27 +00:00
|
|
|
# This is wrong, and causes more Toolchain rebuilds than necessary.
|
|
|
|
# However, we want to avoid false cache hits at all costs.
|
2021-03-02 17:40:11 +00:00
|
|
|
key: ${{ runner.os }}-toolchain-i686-${{ steps.stamps.outputs.libc_headers }}
|
2020-11-07 15:54:27 +00:00
|
|
|
- name: Restore or regenerate Toolchain
|
|
|
|
run: TRY_USE_LOCAL_TOOLCHAIN=y ${{ github.workspace }}/Toolchain/BuildIt.sh
|
2021-03-02 17:40:11 +00:00
|
|
|
- name: ccache(1) cache
|
|
|
|
# Pull the ccache *after* building the toolchain, in case building the Toolchain somehow interferes.
|
2021-06-03 12:42:40 +00:00
|
|
|
# TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged.
|
|
|
|
uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b
|
|
|
|
env:
|
|
|
|
CACHE_SKIP_SAVE: ${{ github.event_name == 'pull_request' }}
|
2021-03-02 17:40:11 +00:00
|
|
|
with:
|
|
|
|
path: /home/runner/.ccache
|
|
|
|
# If you're here because ccache broke (it never should), increment matrix.ccache-mark.
|
|
|
|
# We want to always reuse the last cache, but upload a new one.
|
|
|
|
# This is achieved by using the "prefix-timestamp" format,
|
|
|
|
# and permitting the restore-key "prefix-" without specifying a timestamp.
|
|
|
|
# For this trick to work, the timestamp *must* come last, and it *must* be missing in 'restore-keys'.
|
2021-05-23 21:33:52 +00:00
|
|
|
key: ${{ runner.os }}-ccache-i686-v${{ matrix.ccache-mark }}-D${{ matrix.debug-options }}-toolchain_${{steps.stamps.outputs.libc_headers}}-time${{ steps.stamps.outputs.time }}
|
2021-03-04 17:54:30 +00:00
|
|
|
# IMPORTANT: Keep these two in sync!
|
2021-03-02 17:40:11 +00:00
|
|
|
restore-keys: |
|
2021-05-23 21:33:52 +00:00
|
|
|
${{ runner.os }}-ccache-i686-v${{ matrix.ccache-mark }}-D${{ matrix.debug-options }}-toolchain_${{steps.stamps.outputs.libc_headers}}-
|
2021-03-02 17:40:11 +00:00
|
|
|
- name: Show ccache stats before build and configure
|
|
|
|
run: |
|
|
|
|
# We only have 5 GiB of cache available *in total*. Beyond that, GitHub deletes caches.
|
|
|
|
# Currently, we use about 65 MB for the toolchain, and two ccache caches:
|
|
|
|
# One with ALL_DEBUG and one with NORMAL_DEBUG.
|
|
|
|
# Therefore, using 2.47 GB or more per ccache cache causes disaster.
|
|
|
|
# Building from scratch fills the ccache cache from 0 to about 0.7 GB, so 1.5 GB is plenty.
|
|
|
|
ccache -M 1500M
|
|
|
|
ccache -s
|
2021-05-23 21:33:52 +00:00
|
|
|
- name: Create build environment with extra debug options
|
2021-02-04 02:04:22 +00:00
|
|
|
working-directory: ${{ github.workspace }}
|
2021-05-23 21:33:52 +00:00
|
|
|
# Build the entire project with all available debug options turned on, to prevent code rot.
|
2021-02-04 02:04:22 +00:00
|
|
|
# However, it is unweildy and slow to run tests with them enabled, so we will build twice.
|
|
|
|
run: |
|
|
|
|
mkdir -p Build
|
|
|
|
cd Build
|
2021-06-21 20:52:57 +00:00
|
|
|
cmake .. -GNinja -DBUILD_LAGOM=ON -DENABLE_ALL_DEBUG_FACILITIES=ON -DENABLE_PCI_IDS_DOWNLOAD=OFF -DENABLE_USB_IDS_DOWNLOAD=OFF -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
|
2021-05-23 21:33:52 +00:00
|
|
|
if: ${{ matrix.debug-options == 'ALL_DEBUG' }}
|
2020-11-07 15:54:27 +00:00
|
|
|
- name: Create build environment
|
|
|
|
working-directory: ${{ github.workspace }}
|
2021-05-27 08:27:12 +00:00
|
|
|
# Note that we do not set BUILD_LAGOM for the normal debug build
|
|
|
|
# We build and run the Lagom tests in a separate job, and sanitizer builds take a good while longer than non-sanitized.
|
2020-11-07 15:54:27 +00:00
|
|
|
run: |
|
|
|
|
mkdir -p Build
|
|
|
|
cd Build
|
2021-06-21 20:52:57 +00:00
|
|
|
cmake .. -GNinja -DENABLE_UNDEFINED_SANITIZER=ON -DENABLE_PCI_IDS_DOWNLOAD=OFF -DENABLE_USB_IDS_DOWNLOAD=OFF -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
|
2021-05-23 21:33:52 +00:00
|
|
|
if: ${{ matrix.debug-options == 'NORMAL_DEBUG' }}
|
2020-11-07 15:54:27 +00:00
|
|
|
|
2021-02-04 02:04:22 +00:00
|
|
|
# === ACTUALLY BUILD ===
|
2020-11-07 15:54:27 +00:00
|
|
|
|
|
|
|
- name: Build Serenity and Tests
|
|
|
|
working-directory: ${{ github.workspace }}/Build
|
2020-12-02 09:45:16 +00:00
|
|
|
run: cmake --build .
|
2021-03-02 17:40:11 +00:00
|
|
|
- name: Show ccache stats after build
|
|
|
|
run: ccache -s
|
2020-11-07 15:54:27 +00:00
|
|
|
- name: Lint (Phase 2/2)
|
|
|
|
working-directory: ${{ github.workspace }}/Meta
|
|
|
|
run: ./check-symbols.sh
|
|
|
|
|
2021-02-04 02:04:22 +00:00
|
|
|
- name: Create Serenity Rootfs
|
2021-05-23 21:33:52 +00:00
|
|
|
if: ${{ matrix.debug-options == 'NORMAL_DEBUG'}}
|
2021-02-04 02:04:22 +00:00
|
|
|
working-directory: ${{ github.workspace }}/Build
|
|
|
|
run: ninja install && ninja image
|
2020-11-07 15:54:27 +00:00
|
|
|
|
2021-02-04 02:04:22 +00:00
|
|
|
- name: Run On-Target Tests
|
2021-05-23 21:33:52 +00:00
|
|
|
if: ${{ matrix.debug-options == 'NORMAL_DEBUG'}}
|
2021-02-04 02:04:22 +00:00
|
|
|
working-directory: ${{ github.workspace }}/Build
|
|
|
|
env:
|
2021-03-17 06:42:26 +00:00
|
|
|
SERENITY_QEMU_CPU: "max,vmx=off"
|
2021-02-04 02:04:22 +00:00
|
|
|
SERENITY_KERNEL_CMDLINE: "boot_mode=self-test"
|
|
|
|
SERENITY_RUN: "ci"
|
2021-03-12 20:53:06 +00:00
|
|
|
run: |
|
|
|
|
echo "::group::ninja run # Qemu output"
|
2021-03-17 06:42:26 +00:00
|
|
|
ninja run
|
2021-03-12 20:53:06 +00:00
|
|
|
echo "::endgroup::"
|
2021-05-21 11:30:00 +00:00
|
|
|
echo "::group::Verify Output File"
|
|
|
|
mkdir fsmount
|
|
|
|
sudo mount -t ext2 -o loop,rw _disk_image fsmount
|
|
|
|
echo "Results: "
|
|
|
|
sudo cat fsmount/home/anon/test-results.log
|
|
|
|
if ! sudo grep -q "Failed: 0" fsmount/home/anon/test-results.log
|
|
|
|
then
|
|
|
|
echo "::error :^( Tests failed, failing job"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "::endgroup::"
|
2021-06-26 11:40:59 +00:00
|
|
|
timeout-minutes: 60
|
2021-03-17 06:42:26 +00:00
|
|
|
|
|
|
|
- name: Print Target Logs
|
|
|
|
# Extremely useful if Serenity hangs trying to run one of the tests
|
2021-05-23 21:33:52 +00:00
|
|
|
if: ${{ !cancelled() && matrix.debug-options == 'NORMAL_DEBUG'}}
|
2021-03-17 06:42:26 +00:00
|
|
|
working-directory: ${{ github.workspace }}/Build
|
|
|
|
run: '[ ! -e debug.log ] || cat debug.log'
|
2021-01-04 02:08:48 +00:00
|
|
|
|
2021-02-04 02:04:22 +00:00
|
|
|
build_and_test_lagom:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- with-fuzzers: FUZZ
|
|
|
|
os: ubuntu-20.04
|
|
|
|
allow-test-failure: false
|
|
|
|
- with-fuzzers: NO_FUZZ
|
|
|
|
os: ubuntu-20.04
|
|
|
|
allow-test-failure: false
|
|
|
|
- with-fuzzers: NO_FUZZ
|
|
|
|
os: macos-10.15
|
|
|
|
allow-test-failure: true
|
2020-11-29 19:01:40 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
# === OS SETUP ===
|
2020-12-02 09:45:16 +00:00
|
|
|
#
|
2021-02-04 02:04:22 +00:00
|
|
|
- name: Install Ubuntu dependencies
|
2021-04-16 19:16:03 +00:00
|
|
|
run: |
|
2021-05-29 16:07:32 +00:00
|
|
|
sudo apt-get purge -y clang-11
|
2021-04-16 19:16:03 +00:00
|
|
|
sudo apt-get update
|
2021-06-21 16:34:15 +00:00
|
|
|
sudo apt-get install ninja-build wabt
|
2021-05-20 22:03:30 +00:00
|
|
|
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 100
|
|
|
|
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-12 100
|
2021-02-04 02:04:22 +00:00
|
|
|
if: ${{ runner.os == 'Linux' }}
|
|
|
|
- name: Install macOS dependencies
|
2021-06-21 16:34:15 +00:00
|
|
|
run: brew install ninja wabt
|
2021-02-04 02:04:22 +00:00
|
|
|
if: ${{ runner.os == 'macOS' }}
|
2020-11-29 19:01:40 +00:00
|
|
|
- name: Check versions
|
2021-06-21 16:34:15 +00:00
|
|
|
run: set +e; clang --version; clang++ --version; ninja --version; wat2wasm --version
|
2020-11-29 19:01:40 +00:00
|
|
|
|
|
|
|
# === PREPARE FOR BUILDING ===
|
|
|
|
|
|
|
|
# TODO: ccache
|
|
|
|
# https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/
|
|
|
|
# https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml
|
2021-03-02 17:40:11 +00:00
|
|
|
# Ignore for now, since the other step dominates
|
2021-02-04 02:04:22 +00:00
|
|
|
- name: Create build environment (fuzz)
|
2020-11-29 19:01:40 +00:00
|
|
|
working-directory: ${{ github.workspace }}/Meta/Lagom
|
|
|
|
run: |
|
|
|
|
mkdir -p Build
|
|
|
|
cd Build
|
2021-06-21 20:52:57 +00:00
|
|
|
cmake -GNinja -DBUILD_LAGOM=ON -DENABLE_FUZZER_SANITIZER=ON -DENABLE_ADDRESS_SANITIZER=ON -DENABLE_PCI_IDS_DOWNLOAD=OFF -DENABLE_USB_IDS_DOWNLOAD=OFF -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
|
2021-02-04 02:04:22 +00:00
|
|
|
if: ${{ matrix.with-fuzzers == 'FUZZ' }}
|
2020-11-29 19:01:40 +00:00
|
|
|
|
2021-02-04 02:04:22 +00:00
|
|
|
- name: Create build environment (no fuzz)
|
|
|
|
working-directory: ${{ github.workspace }}/Meta/Lagom
|
|
|
|
run: |
|
|
|
|
mkdir -p Build
|
|
|
|
cd Build
|
2021-06-21 20:52:57 +00:00
|
|
|
cmake -GNinja -DBUILD_LAGOM=ON -DINCLUDE_WASM_SPEC_TESTS=ON -DWASM_SPEC_TEST_SKIP_FORMATTING=ON -DENABLE_UNDEFINED_SANITIZER=ON -DENABLE_ADDRESS_SANITIZER=ON -DENABLE_PCI_IDS_DOWNLOAD=OFF -DENABLE_USB_IDS_DOWNLOAD=OFF -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 ..
|
2021-02-04 02:04:22 +00:00
|
|
|
if: ${{ matrix.with-fuzzers == 'NO_FUZZ' }}
|
|
|
|
|
|
|
|
# === ACTUALLY BUILD AND TEST ===
|
2020-11-29 19:01:40 +00:00
|
|
|
|
2021-02-04 02:04:22 +00:00
|
|
|
- name: Build Lagom
|
2020-11-29 19:01:40 +00:00
|
|
|
working-directory: ${{ github.workspace }}/Meta/Lagom/Build
|
2020-12-02 09:45:16 +00:00
|
|
|
run: cmake --build .
|
2021-02-04 02:04:22 +00:00
|
|
|
|
|
|
|
- name: Run CMake tests
|
|
|
|
working-directory: ${{ github.workspace }}/Meta/Lagom/Build
|
2021-05-15 21:50:24 +00:00
|
|
|
run: ninja test || ${{ matrix.allow-test-failure }}
|
2021-02-28 22:06:42 +00:00
|
|
|
timeout-minutes: 4
|
2021-05-15 21:50:24 +00:00
|
|
|
env:
|
|
|
|
CTEST_OUTPUT_ON_FAILURE: 1
|
2021-05-23 17:40:13 +00:00
|
|
|
# FIXME: enable detect_stack_use_after_return=1 #7420
|
|
|
|
ASAN_OPTIONS: "strict_string_checks=1:check_initialization_order=1:strict_init_order=1"
|
|
|
|
UBSAN_OPTIONS: "print_stacktrace=1:print_summary=1:halt_on_error=1"
|
2021-02-04 02:04:22 +00:00
|
|
|
if: ${{ matrix.with-fuzzers == 'NO_FUZZ' }}
|