Skip to content

Commit ec3cdf3

Browse files
authored
Merge pull request #431 from secure-software-engineering/f-AddCIPipelilne
Adds github CI setup for phasar
2 parents fb560cf + e92f578 commit ec3cdf3

9 files changed

Lines changed: 189 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Phasar CI
2+
3+
on:
4+
push:
5+
branches: [ master, development ]
6+
pull_request:
7+
branches: [ master, development ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-20.04
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
compiler: [ [clang++-12, clang-12] ]
16+
build: [ Debug, Release ]
17+
18+
continue-on-error: false
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
submodules: recursive
25+
26+
- name: Install Basic Dependencies
27+
shell: bash
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get -y install --no-install-recommends \
31+
cmake \
32+
ninja-build \
33+
libstdc++6 \
34+
libboost-all-dev
35+
36+
- name: Install Phasar Dependencies
37+
shell: bash
38+
run: |
39+
./utils/InstallAptDependencies.sh
40+
41+
- name: Install Strategy Dependencies
42+
shell: bash
43+
run: |
44+
sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
45+
sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main'
46+
sudo apt-get update
47+
sudo apt-get -y install --no-install-recommends \
48+
${{ matrix.compiler[1] }} \
49+
llvm-12-dev \
50+
libllvm12 \
51+
libclang-common-12-dev \
52+
libclang-12-dev \
53+
libclang-cpp12-dev \
54+
clang-tidy-12
55+
56+
- name: Building Phasar in ${{ matrix.build }} with ${{ matrix.compiler[0] }}
57+
env:
58+
BUILD_TYPE: ${{ matrix.build }}
59+
CXX: ${{ matrix.compiler[0] }}
60+
CC: ${{ matrix.compiler[1] }}
61+
shell: bash
62+
run: |
63+
mkdir build
64+
cd build
65+
cmake .. \
66+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
67+
-DCMAKE_CXX_COMPILER=$CXX \
68+
-G Ninja
69+
cmake --build .
70+
71+
- name: Run Unittests
72+
shell: bash
73+
run: |
74+
cd build
75+
cmake --build . --target check-phasar-unittests

.github/workflows/pre-commit.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
pre-commit:
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- uses: actions/checkout@v2
11+
with:
12+
fetch-depth: 0
13+
14+
- uses: actions/setup-python@v2
15+
16+
- uses: pre-commit/action@v2.0.0
17+
with:
18+
extra_args: --from-ref origin/development --to-ref HEAD
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Phasar clang-format review runner
2+
3+
on:
4+
pull_request:
5+
branches: [ master, development ]
6+
7+
jobs:
8+
format:
9+
runs-on: ubuntu-20.04
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
tool: [ clang-format ]
14+
include:
15+
- tool: clang-format
16+
install: |
17+
sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
18+
sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main'
19+
sudo apt-get update
20+
sudo apt-get -y install --no-install-recommends clang-format-12
21+
regex: \.(h|c|hpp|cpp)$
22+
command: clang-format-12 --style=file -i
23+
24+
continue-on-error: false
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
with:
29+
submodules: recursive
30+
31+
- name: Install Dependencies
32+
shell: bash
33+
run: ${{ matrix.install }}
34+
35+
- name: Fetch Base Branch
36+
shell: bash
37+
run: |
38+
git fetch --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
39+
40+
- name: Run Tool
41+
shell: bash
42+
run: |
43+
FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }} HEAD | egrep "${{ matrix.regex }}" || true)
44+
[ -z "$FILES" ] || (${{ matrix.command }} $FILES && git diff --diff-filter=M $FILES)
45+
46+
- name: Add Suggestions
47+
uses: reviewdog/action-suggester@v1
48+
with:
49+
tool_name: ${{ matrix.tool }}
50+
filter_mode: diff_context
51+
level: warning

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v2.4.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- id: requirements-txt-fixer
12+
- repo: https://github.com/pre-commit/mirrors-clang-format
13+
rev: 'v12.0.1'
14+
hooks:
15+
- id: clang-format

CMakeLists.txt

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,30 @@ find_package(Boost 1.65.1 COMPONENTS filesystem graph system program_options log
117117
#find_package(Boost 1.72.0 COMPONENTS filesystem graph system program_options log ${BOOST_THREAD} REQUIRED)
118118
include_directories(${Boost_INCLUDE_DIRS})
119119

120-
# JSON library
121-
option(JSON_BuildTests OFF)
122-
add_subdirectory(external/json EXCLUDE_FROM_ALL)
120+
# We need to work around the behavior of nlohmann_json_schema_validator and nlohmann_json here
121+
# The validator needs the json part, but if you include it, the library of nlohmann_json_schema_validator
122+
# is not installed, leading to linker error. But just including nlohmann_json is not sufficient, as
123+
# in the installed state the nlohmann_json_schema_validator needs the nlohmann_json package which needs
124+
# to be installed.
125+
# The following workaround may collapse or become unnecessary once the issue is
126+
# changed or fixed in nlohmann_json_schema_validator.
127+
128+
#Override option of nlohmann_json_schema_validator to not build its tests
129+
set(BUILD_TESTS OFF CACHE BOOL "Build json-schema-validator-tests")
130+
131+
# Make nlohmann_json_schema_validator happy by telling it how to find the single include of nlohmann_json
123132
include_directories(external/json/single_include/)
133+
set(nlohmann_json_DIR ${PHASAR_SRC_DIR}/external/json/single_include/)
134+
135+
# Json Schema Validator
136+
set(JSON_VALIDATOR_INSTALL ON)
137+
add_subdirectory(external/json-schema-validator)
138+
include_directories(external/json-schema-validator/src/)
139+
140+
# now we finally add the subdirectory
141+
set(JSON_BuildTests OFF)
142+
set(JSON_Install ON)
143+
add_subdirectory(external/json)
124144

125145
# Googletest
126146
if (NOT PHASAR_IN_TREE)
@@ -159,7 +179,7 @@ endif()
159179
# Clang
160180
# The clang-cpp shared library is now the preferred way to link dynamically against libclang if we build out of tree.
161181
if(NOT PHASAR_IN_TREE)
162-
find_library(CLANG_LIBRARY NAMES clang-cpp REQUIRED HINTS ${LLVM_LIBRARY_DIRS})
182+
find_library(CLANG_LIBRARY NAMES clang-cpp libclang-cpp REQUIRED HINTS ${LLVM_LIBRARY_DIRS})
163183
if(${CLANG_LIBRARY} STREQUAL "CLANG_LIBRARY-NOTFOUND")
164184
set(NEED_LIBCLANG_COMPONENT_LIBS on)
165185
endif()

cmake/phasar_macros.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ function(add_phasar_unittest test_name)
2626
phasar_experimental
2727
# phasar_clang
2828
phasar_passes
29-
# FIXME: cmake variable ${PHASAR_PLUGINS_LIB} is empty although it should contain phasar_plugins
29+
# FIXME: cmake variable ${PHASAR_PLUGINS_LIB} is empty although it should contain phasar_plugins
3030
phasar_plugins
3131
# ${PHASAR_PLUGINS_LIB}
3232
phasar_pointer
3333
phasar_typehierarchy
34+
phasar_taintconfig
35+
nlohmann_json_schema_validator
3436
${SQLITE3_LIBRARY}
3537
${Boost_LIBRARIES}
3638
${CMAKE_DL_LIBS}

lib/PhasarLLVM/DataFlowSolver/IfdsIde/phasar_ifdside-config.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ list(APPEND
1616
controlflow
1717
phasarllvm_utils
1818
db
19+
taintconfig
1920
)
2021

2122
foreach(dep ${IFDSIDE_DEPS})

lib/PhasarLLVM/TaintConfig/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ endif()
1818

1919
target_link_libraries(phasar_taintconfig
2020
LINK_PUBLIC
21-
nlohmann_json::nlohmann_json
2221
nlohmann_json_schema_validator
2322
)
2423

lib/PhasarLLVM/TaintConfig/phasar_taintconfig-config.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ foreach(dep ${PHASAR_TAINTCONFIG_DEPS})
1515
endif()
1616
endforeach()
1717

18+
find_package(nlohmann_json_schema_validator REQUIRED)
19+
1820
list(APPEND
1921
PHASAR_NEEDED_LIBS
2022
phasar::phasar_taintconfig
21-
nlohmann_json::nlohmann_json
2223
nlohmann_json_schema_validator
2324
)

0 commit comments

Comments
 (0)