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 }}
|
2022-03-14 13:40:14 +00:00
|
|
|
if: github.repository == 'SerenityOS/serenity'
|
2021-01-04 02:08:48 +00:00
|
|
|
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-07-01 13:03:13 +00:00
|
|
|
arch: ['i686', 'x86_64']
|
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]
|
2021-07-01 13:03:13 +00:00
|
|
|
exclude:
|
|
|
|
# We currently manually disable the ALL_DEBUG build on x86_64 for sake of saving CI time, as it is not our main target right now
|
|
|
|
- debug-options: 'ALL_DEBUG'
|
|
|
|
arch: 'x86_64'
|
2020-11-07 15:54:27 +00:00
|
|
|
|
|
|
|
steps:
|
2021-08-08 17:16:49 +00:00
|
|
|
- uses: actions/checkout@v2
|
|
|
|
# Set default Python to python 3.x, and set Python path such that pip install works properly
|
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
|
|
|
|
# === OS SETUP ===
|
|
|
|
|
|
|
|
# Do we need to update the package cache first?
|
|
|
|
# sudo apt-get update -qq
|
|
|
|
- name: "Install Ubuntu dependencies"
|
|
|
|
# These packages are already part of the ubuntu-20.04 image:
|
2022-02-06 19:05:35 +00:00
|
|
|
# cmake libgmp-dev npm shellcheck
|
2021-08-08 17:16:49 +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
|
2022-01-07 06:27:53 +00:00
|
|
|
# We add the ubuntu-toolchain-r/test PPA to get gcc-11 on 20.04
|
2021-08-08 17:16:49 +00:00
|
|
|
run: |
|
|
|
|
sudo add-apt-repository ppa:canonical-server/server-backports
|
2022-01-07 06:27:53 +00:00
|
|
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
2022-02-06 19:05:35 +00:00
|
|
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
|
|
|
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'
|
2021-08-08 17:16:49 +00:00
|
|
|
sudo apt-get update
|
2022-02-06 19:05:35 +00:00
|
|
|
sudo apt-get install -y clang-format-14 ccache e2fsprogs gcc-11 g++-11 libstdc++-11-dev libmpfr-dev libmpc-dev ninja-build qemu-utils qemu-system-i386 unzip
|
2021-08-08 17:16:49 +00:00
|
|
|
- name: Install JS dependencies
|
2022-01-11 21:15:45 +00:00
|
|
|
run: sudo npm install -g prettier@2.5.1
|
2021-08-08 17:16:49 +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
|
|
|
|
- name: Check versions
|
2022-02-06 19:05:35 +00:00
|
|
|
run: set +e; g++ --version; g++-11 --version; clang-format --version; clang-format-14 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version
|
2021-08-08 17:16:49 +00:00
|
|
|
|
|
|
|
# === PREPARE FOR BUILDING ===
|
|
|
|
|
|
|
|
- name: Lint (Phase 1/2)
|
|
|
|
run: ${{ github.workspace }}/Meta/lint-ci.sh
|
|
|
|
- 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}")
|
2022-05-19 18:18:33 +00:00
|
|
|
message(" set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch', 'Toolchain/BuildIt.sh') }}")
|
|
|
|
message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch', 'Toolchain/BuildIt.sh') }}")
|
2021-08-08 17:16:49 +00:00
|
|
|
|
|
|
|
- name: Toolchain cache
|
|
|
|
# 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' }}
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/Toolchain/Cache/
|
|
|
|
# This assumes that *ALL* LibC and LibPthread headers have an impact on the Toolchain.
|
|
|
|
# This is wrong, and causes more Toolchain rebuilds than necessary.
|
|
|
|
# However, we want to avoid false cache hits at all costs.
|
|
|
|
key: ${{ runner.os }}-toolchain-${{ matrix.arch }}-${{ steps.stamps.outputs.libc_headers }}
|
|
|
|
|
|
|
|
- name: Restore or regenerate Toolchain
|
|
|
|
run: TRY_USE_LOCAL_TOOLCHAIN=y ARCH="${{ matrix.arch }}" ${{ github.workspace }}/Toolchain/BuildIt.sh
|
|
|
|
|
|
|
|
- name: ccache(1) cache
|
|
|
|
# Pull the ccache *after* building the toolchain, in case building the Toolchain somehow interferes.
|
|
|
|
# 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' }}
|
|
|
|
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'.
|
|
|
|
key: ${{ runner.os }}-ccache-${{ matrix.arch }}-v${{ matrix.ccache-mark }}-D${{ matrix.debug-options }}-toolchain_${{steps.stamps.outputs.libc_headers}}-time${{ steps.stamps.outputs.time }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-ccache-${{ matrix.arch }}-v${{ matrix.ccache-mark }}-D${{ matrix.debug-options }}-toolchain_${{steps.stamps.outputs.libc_headers}}-
|
|
|
|
|
|
|
|
- name: Show ccache stats before build and configure
|
|
|
|
run: |
|
|
|
|
# We only have 5 GiB of cache available *in total*. Beyond that, GitHub deletes caches.
|
2021-08-21 20:20:50 +00:00
|
|
|
# Currently, we use about 130 MB for the two toolchains (i686 & x86_64), and three ccache caches:
|
|
|
|
# One with ALL_DEBUG (i686) and two with NORMAL_DEBUG (i686 & x86_64).
|
|
|
|
# Therefore, using 1.6 GB or more per cache causes disaster.
|
2021-08-08 17:16:49 +00:00
|
|
|
# Building from scratch fills the ccache cache from 0 to about 0.7 GB, and after compression it comes out to
|
2021-08-21 20:20:50 +00:00
|
|
|
# about 0.25 GB, so 3 GB (1GB after compression) should be plenty, all while comfortably fitting in the cache.
|
|
|
|
ccache -M 3000M
|
2021-08-08 17:16:49 +00:00
|
|
|
ccache -s
|
|
|
|
- name: Create build directory
|
|
|
|
run: |
|
2021-12-22 21:43:05 +00:00
|
|
|
mkdir -p ${{ github.workspace }}/Build/${{ matrix.arch }}/TZDB
|
2021-09-07 08:21:36 +00:00
|
|
|
mkdir -p ${{ github.workspace }}/Build/${{ matrix.arch }}/UCD
|
|
|
|
mkdir -p ${{ github.workspace }}/Build/${{ matrix.arch }}/CLDR
|
2021-12-22 21:43:05 +00:00
|
|
|
- name: TimeZoneData cache
|
|
|
|
# TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged.
|
|
|
|
uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/Build/${{ matrix.arch }}/TZDB
|
|
|
|
key: TimeZoneData-${{ hashFiles('Meta/CMake/time_zone_data.cmake') }}
|
2021-08-08 17:16:49 +00:00
|
|
|
- name: UnicodeData cache
|
|
|
|
# TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged.
|
|
|
|
uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b
|
|
|
|
with:
|
2021-09-07 08:21:36 +00:00
|
|
|
path: ${{ github.workspace }}/Build/${{ matrix.arch }}/UCD
|
2021-08-08 06:06:55 +00:00
|
|
|
key: UnicodeData-${{ hashFiles('Meta/CMake/unicode_data.cmake') }}
|
2021-08-25 03:31:21 +00:00
|
|
|
- name: UnicodeLocale Cache
|
|
|
|
# TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged.
|
|
|
|
uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b
|
|
|
|
with:
|
2021-10-21 15:19:16 +00:00
|
|
|
path: ${{ github.workspace }}/Build/${{ matrix.arch }}/CLDR
|
2021-08-08 06:06:55 +00:00
|
|
|
key: UnicodeLocale-${{ hashFiles('Meta/CMake/unicode_data.cmake') }}
|
2021-08-08 17:16:49 +00:00
|
|
|
- name: Create build environment with extra debug options
|
|
|
|
# Build the entire project with all available debug options turned on, to prevent code rot.
|
2021-09-07 08:21:36 +00:00
|
|
|
# However, it is unwieldy and slow to run tests with them enabled, so we will build twice.
|
|
|
|
run: |
|
|
|
|
cmake -S Meta/CMake/Superbuild -B Build/superbuild -GNinja \
|
|
|
|
-DSERENITY_ARCH=${{ matrix.arch }} \
|
|
|
|
-DSERENITY_TOOLCHAIN=GNU \
|
|
|
|
-DBUILD_LAGOM=ON \
|
2022-01-07 06:27:53 +00:00
|
|
|
-DCMAKE_C_COMPILER=gcc-11 \
|
|
|
|
-DCMAKE_CXX_COMPILER=g++-11 \
|
2021-09-07 08:21:36 +00:00
|
|
|
-DENABLE_ALL_DEBUG_FACILITIES=ON \
|
|
|
|
-DENABLE_PCI_IDS_DOWNLOAD=OFF \
|
|
|
|
-DENABLE_USB_IDS_DOWNLOAD=OFF
|
2021-08-08 17:16:49 +00:00
|
|
|
if: ${{ matrix.debug-options == 'ALL_DEBUG' }}
|
|
|
|
- name: Create build environment
|
2021-09-07 08:21:36 +00:00
|
|
|
working-directory: ${{ github.workspace }}
|
2021-08-08 17:16:49 +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.
|
2021-09-07 08:21:36 +00:00
|
|
|
run: |
|
|
|
|
cmake -S Meta/CMake/Superbuild -B Build/superbuild -GNinja \
|
|
|
|
-DSERENITY_ARCH=${{ matrix.arch }} \
|
|
|
|
-DSERENITY_TOOLCHAIN=GNU \
|
2022-01-07 06:27:53 +00:00
|
|
|
-DCMAKE_C_COMPILER=gcc-11 \
|
|
|
|
-DCMAKE_CXX_COMPILER=g++-11 \
|
2021-09-07 08:21:36 +00:00
|
|
|
-DENABLE_UNDEFINED_SANITIZER=ON \
|
|
|
|
-DENABLE_PCI_IDS_DOWNLOAD=OFF \
|
|
|
|
-DENABLE_USB_IDS_DOWNLOAD=OFF
|
2021-08-08 17:16:49 +00:00
|
|
|
if: ${{ matrix.debug-options == 'NORMAL_DEBUG' }}
|
|
|
|
|
|
|
|
# === ACTUALLY BUILD ===
|
|
|
|
|
|
|
|
- name: Build Serenity and Tests
|
2021-09-07 08:21:36 +00:00
|
|
|
working-directory: ${{ github.workspace }}/Build/superbuild
|
2021-08-08 17:16:49 +00:00
|
|
|
run: cmake --build .
|
|
|
|
- name: Show ccache stats after build
|
|
|
|
run: ccache -s
|
|
|
|
- name: Lint (Phase 2/2)
|
|
|
|
working-directory: ${{ github.workspace }}/Meta
|
2022-01-14 12:26:23 +00:00
|
|
|
env:
|
|
|
|
SERENITY_ARCH: ${{ matrix.arch }}
|
2021-08-08 17:16:49 +00:00
|
|
|
run: ./check-symbols.sh
|
|
|
|
|
|
|
|
- name: Create Serenity Rootfs
|
|
|
|
if: ${{ matrix.debug-options == 'NORMAL_DEBUG'}}
|
2021-09-07 08:21:36 +00:00
|
|
|
working-directory: ${{ github.workspace }}/Build/${{ matrix.arch }}
|
2021-08-08 17:16:49 +00:00
|
|
|
run: ninja install && ninja image
|
|
|
|
|
|
|
|
- name: Run On-Target Tests
|
|
|
|
if: ${{ matrix.debug-options == 'NORMAL_DEBUG'}}
|
2021-09-07 08:21:36 +00:00
|
|
|
working-directory: ${{ github.workspace }}/Build/${{ matrix.arch }}
|
2021-08-08 17:16:49 +00:00
|
|
|
env:
|
|
|
|
SERENITY_QEMU_CPU: "max,vmx=off"
|
2021-10-23 16:26:50 +00:00
|
|
|
SERENITY_KERNEL_CMDLINE: "fbdev=off panic=shutdown system_mode=self-test"
|
2021-08-08 17:16:49 +00:00
|
|
|
SERENITY_RUN: "ci"
|
|
|
|
run: |
|
|
|
|
echo "::group::ninja run # Qemu output"
|
|
|
|
ninja run
|
|
|
|
echo "::endgroup::"
|
|
|
|
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::"
|
|
|
|
timeout-minutes: 60
|
|
|
|
|
|
|
|
- name: Print Target Logs
|
|
|
|
# Extremely useful if Serenity hangs trying to run one of the tests
|
|
|
|
if: ${{ !cancelled() && matrix.debug-options == 'NORMAL_DEBUG'}}
|
2021-09-07 08:21:36 +00:00
|
|
|
working-directory: ${{ github.workspace }}/Build/${{ matrix.arch }}
|
2021-08-08 17:16:49 +00:00
|
|
|
run: '[ ! -e debug.log ] || cat debug.log'
|
2021-10-26 20:41:31 +00:00
|
|
|
|
|
|
|
- name: Check manpages for completeness
|
|
|
|
if: ${{ matrix.debug-options == 'NORMAL_DEBUG' && matrix.arch == 'i686'}}
|
|
|
|
working-directory: ${{ github.workspace }}/Build/${{ matrix.arch }}
|
|
|
|
env:
|
|
|
|
# The script already sets the correct SERENITY_RUN and SERENITY_KERNEL_CMDLINE envvars.
|
|
|
|
SERENITY_ARCH: ${{ matrix.arch }}
|
|
|
|
SERENITY_QEMU_CPU: "max,vmx=off"
|
|
|
|
run: |
|
|
|
|
# Running the tests apparently leaves the image sufficiently broken
|
|
|
|
rm _disk_image
|
|
|
|
ninja image
|
|
|
|
/usr/bin/time ../../Meta/export-argsparser-manpages.sh --verify-git-state
|
|
|
|
timeout-minutes: 10
|