mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
397b798235
Add CODE_COVERAGE option to enable coverage instrumentation in builds. Add new CI job to upload coverage reports to CodeCov.io. Reports can be found by navigating the codecov.io UI, or by going to the URL printed at the end of the "Code Coverage" CI job. More CodeCov integration could be set up later once we have coverage reporting on the main branch.
204 lines
5.8 KiB
YAML
204 lines
5.8 KiB
YAML
version: 2.1
|
|
|
|
workflows:
|
|
object-introspection:
|
|
jobs:
|
|
- lint
|
|
|
|
- build:
|
|
name: build-gcc
|
|
cc: /usr/bin/gcc
|
|
cxx: /usr/bin/g++
|
|
- test:
|
|
name: test-gcc
|
|
requires:
|
|
- build-gcc
|
|
- coverage:
|
|
requires:
|
|
- test-gcc
|
|
|
|
- build:
|
|
name: build-clang
|
|
cc: /usr/bin/clang-12
|
|
cxx: /usr/bin/clang++-12
|
|
- test:
|
|
name: test-clang
|
|
requires:
|
|
- build-clang
|
|
|
|
executors:
|
|
ubuntu-docker:
|
|
docker:
|
|
- image: ubuntu:jammy
|
|
resource_class: small
|
|
big-boy:
|
|
machine:
|
|
image: ubuntu-2204:2022.10.2
|
|
resource_class: 2xlarge
|
|
|
|
jobs:
|
|
lint:
|
|
executor: ubuntu-docker
|
|
steps:
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
apt-get update
|
|
apt-get install -y \
|
|
clang-format \
|
|
git \
|
|
python3-pip
|
|
# click broke semver with 8.1.0, causing issues for black
|
|
pip install click==8.0.0 black isort
|
|
- checkout
|
|
- run:
|
|
name: clang-format
|
|
command: |
|
|
git ls-files '*.cpp' '*.h' | xargs clang-format --fallback-style=Google -i
|
|
git ls-files '*.py' | xargs black
|
|
git ls-files '*.py' | xargs isort
|
|
git diff --exit-code
|
|
- run:
|
|
name: python linting
|
|
command: |
|
|
black --check --diff test/
|
|
isort --check --diff test/
|
|
|
|
build:
|
|
# TODO this job could be run in Docker
|
|
executor: big-boy
|
|
parameters:
|
|
cc:
|
|
type: string
|
|
cxx:
|
|
type: string
|
|
environment:
|
|
CC: << parameters.cc >>
|
|
CXX: << parameters.cxx >>
|
|
working_directory:
|
|
/tmp/object-introspection
|
|
steps:
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
bison \
|
|
build-essential \
|
|
clang-12 \
|
|
cmake \
|
|
flex \
|
|
gawk \
|
|
libboost-all-dev \
|
|
libbz2-dev \
|
|
libcap2-bin \
|
|
libclang-12-dev \
|
|
libcurl4-gnutls-dev \
|
|
libdouble-conversion-dev \
|
|
libdw-dev \
|
|
libfmt-dev \
|
|
libgflags-dev \
|
|
libgmock-dev \
|
|
libgoogle-glog-dev \
|
|
libgtest-dev \
|
|
libjemalloc-dev \
|
|
libmsgpack-dev \
|
|
libzstd-dev \
|
|
llvm-12-dev \
|
|
ninja-build \
|
|
pkg-config \
|
|
python3-setuptools
|
|
pip3 install toml
|
|
environment:
|
|
DEBIAN_FRONTEND: noninteractive
|
|
- checkout
|
|
- run:
|
|
name: Build
|
|
command: |
|
|
cmake -G Ninja -B build/ -DWITH_TESTS=On -DCODE_COVERAGE=On
|
|
cmake --build build/
|
|
# Testing rubbish:
|
|
cp test/ci.oid.toml build/testing.oid.toml
|
|
- persist_to_workspace:
|
|
root: .
|
|
paths:
|
|
- build/*
|
|
- extern/*
|
|
- types/*
|
|
|
|
test:
|
|
executor: big-boy
|
|
working_directory:
|
|
/tmp/object-introspection
|
|
steps:
|
|
- attach_workspace:
|
|
at: .
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
clang-12 \
|
|
libgflags-dev \
|
|
llvm-12-dev
|
|
- run:
|
|
name: Test
|
|
environment:
|
|
# disable drgn multithreading as tests are already run in parallel
|
|
OMP_NUM_THREADS: 1
|
|
command: |
|
|
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
|
|
ctest --test-dir build/test/ --test-action Test -j 4 \
|
|
--no-compress-output --output-on-failure \
|
|
--schedule-random --timeout 30 --repeat until-pass:2 \
|
|
--output-junit results.xml
|
|
- store_test_results:
|
|
path: build/test/results.xml
|
|
- persist_to_workspace:
|
|
# Save code coverage data
|
|
root: .
|
|
paths:
|
|
- build/*
|
|
|
|
coverage:
|
|
executor: ubuntu-docker
|
|
working_directory:
|
|
/tmp/object-introspection
|
|
steps:
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
apt-get update
|
|
apt-get install -y \
|
|
curl \
|
|
git \
|
|
gpg \
|
|
lcov
|
|
- attach_workspace:
|
|
at: .
|
|
- run:
|
|
name: Code Coverage
|
|
when: always
|
|
command: |
|
|
lcov --directory . --capture --rc lcov_branch_coverage=1 --output-file coverage.info
|
|
lcov --extract coverage.info '/tmp/object-introspection/src/*' '/tmp/object-introspection/include/*' --rc lcov_branch_coverage=1 --output-file coverage.info
|
|
lcov --list --rc lcov_branch_coverage=1 coverage.info
|
|
|
|
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
|
|
curl -Os https://uploader.codecov.io/latest/linux/codecov
|
|
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
|
|
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
|
|
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
|
|
shasum -a 256 -c codecov.SHA256SUM
|
|
chmod +x codecov
|
|
|
|
# It appears that codecov wants to scan through all directories
|
|
# other than "build", looking for files to upload, even if we
|
|
# specify a file name on the command line.
|
|
#
|
|
# "extern" is huge and makes uploading the coverage report take
|
|
# forever. Delete it for a speedup.
|
|
rm -rf extern
|
|
|
|
./codecov -Z -f coverage.info
|