Skip to content

Commit d4bddce

Browse files
committed
.github/ci.yaml: Added initial CI workflow
Also removed duplicate lines in README.md
1 parent 08ac24c commit d4bddce

File tree

7 files changed

+234
-4
lines changed

7 files changed

+234
-4
lines changed

.github/ci.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Continuous integration for chrony-dbus-service
2+
3+
name: chrony-dbus-service-ci
4+
on: workflow_dispatch
5+
jobs:
6+
setup:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v4
11+
build-release-tests-gcc:
12+
needs: setup
13+
uses: ./.github/workflows/cmake-gcc.yaml
14+
with:
15+
CMAKE_PARAMS: -DCMAKE_BUILD_TYPE=Release -DAPS_CHRONY_DBUS_SERVICE_BUILD_TESTS=ON
16+
build-rpm:
17+
needs: release-tests
18+
uses: ./.github/workflows/rpm.yaml
19+
tests:
20+
needs: setup
21+
uses: ./.github/workflows/tests.yaml
22+
build-doxygen:
23+
needs: setup
24+
uses: ./.github/workflows/doxygen.yaml
25+
cppcheck:
26+
needs: release-tests
27+
uses: ./.github/workflows/cppcheck.yaml
28+
clang-tidy:
29+
needs: setup
30+
uses: ./.github/workflows/cmake-gcc.yaml
31+
with:
32+
CMAKE_PARAMS: -DCMAKE_BUILD_TYPE=Debug -DAPS_CHRONY_DBUS_SERVICE_BUILD_TESTS=ON -DAPS_CHRONY_DBUS_SERVICE_ENABLE_CLANG_TIDY=ON
33+
clang-format:
34+
needs: setup
35+
runs-on: ubuntu-latest
36+
container:
37+
image: fedora:40
38+
env:
39+
PROJECT_NAME: ${GITHUB_REPOSITORY}
40+
BUILD_WORKSPACE: build
41+
volumes:
42+
- ${GITHUB_WORKSPACE}:/workspaces/${GITHUB_REPOSITORY}
43+
steps:
44+
- name: clang-format-run
45+
run: |
46+
dnf install -y clang-tools-extra
47+
cd /workspaces/$PROJECT_NAME
48+
clang-format --version
49+
./scripts/check_clang_format.sh tests src

.github/workflows/cmake-gcc.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Builds a cmake project in a fedora:40 docker image with installed gcc toolchain
2+
3+
name: build-gcc
4+
on:
5+
workflow_call:
6+
inputs:
7+
CMAKE_PARAMS:
8+
description: Parameters passed to cmake
9+
required: true
10+
type: string
11+
jobs:
12+
build-gcc:
13+
runs-on: ubuntu-latest
14+
container:
15+
image: fedora:40
16+
env:
17+
PROJECT_NAME: ${GITHUB_REPOSITORY}
18+
BUILD_WORKSPACE: build
19+
PARALLEL: 16
20+
volumes:
21+
- ${GITHUB_WORKSPACE}:/workspaces/${GITHUB_REPOSITORY}
22+
steps:
23+
- name: build cmake gcc
24+
run: |
25+
dnf install -y cmake clang clang-tools-extra gcc gcc-c++ pkgconf-pkg-config dbus-libs
26+
cd /workspaces/$PROJECT_NAME
27+
rm -rf $BUILD_WORKSPACE # Ensure we start clean
28+
cmake . -B $BUILD_WORKSPACE ${{ inputs.CMAKE_PARAMS }}
29+
cmake --build $BUILD_WORKSPACE --parallel $PARALLEL
30+
31+

.github/workflows/cppcheck.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Builds the cmake project with CPPCHECK_EXHAUSTIVE=ON and runs cppcheck-codequality
2+
3+
name: run-tests
4+
on:
5+
workflow_call:
6+
jobs:
7+
cppcheck-build:
8+
runs-on: ubuntu-latest
9+
uses: ./.github/workflows/cmake-gcc.yaml
10+
with:
11+
CMAKE_PARAMS: -DCMAKE_BUILD_TYPE=Debug -DAPS_CHRONY_DBUS_SERVICE_ENABLE_CPPCHECK=ON -DAPS_CHRONY_DBUS_SERVICE_ENABLE_CPPCHECK_EXHAUSTIVE=ON
12+
cppcheck-run:
13+
needs: cppcheck-build
14+
runs-on: ubuntu-latest
15+
container:
16+
image: fedora:40
17+
env:
18+
PROJECT_NAME: ${GITHUB_REPOSITORY}
19+
BUILD_WORKSPACE: build
20+
volumes:
21+
- ${GITHUB_WORKSPACE}:/workspaces/${GITHUB_REPOSITORY}
22+
steps:
23+
- name: run-cppcheck
24+
run: |
25+
dnf install -y cppcheck
26+
cd /workspace/$PROJECT_NAME
27+
cppcheck-codequality --input-file $BUILD_WORKSPACE/cppcheck.xml --output-file $BUILD_WORKSPACE/cppcheck_report.json
28+
# Fix the file path references so they are relative to the blob and not the buildspace. We use ; as the substitute so don't have to escape every forwardslash
29+
sed -i "s;${GITHUB_REPOSITORY}/src;src;g" $BUILD_WORKSPACE/cppcheck_report.json
30+
sed -i "s;${GITHUB_REPOSITORY}/test;test;g" $BUILD_WORKSPACE/cppcheck_report.json
31+
if [ $(grep -ic "<error " $BUILD_WORKSPACE/cppcheck.xml) -gt 0 ]; then exit 1; fi
32+
- name: cppcheck-artifacts
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: cppcheck
36+
path: $BUILD_WORKSPACE/cppcheck_report.json

.github/workflows/doxygen.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Builds the doxygen documentation, currently the doxygen_junit part is disabled
2+
3+
name: doxygen
4+
on:
5+
workflow_call:
6+
jobs:
7+
build-doxygen:
8+
runs-on: ubuntu-latest
9+
container:
10+
image: fedora:40
11+
env:
12+
PROJECT_NAME: ${GITHUB_REPOSITORY}
13+
BUILD_WORKSPACE: build
14+
volumes:
15+
- ${GITHUB_WORKSPACE}:/workspaces/${GITHUB_REPOSITORY}
16+
steps:
17+
- name: doxygen-build
18+
run: |
19+
dnf install -y doxygen gzip
20+
chmod 777 scripts/*.sh
21+
scripts/doxygen.sh
22+
cd $BUILD_WORKSPACE/doxygen/
23+
tar -zcf doxygen.tar.gz html/
24+
- name: doxygen-artifacts
25+
needs: doxygen-build
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: doxygen
29+
path: doxygen.tar.gz
30+
- name: doxygen-test
31+
if: false # what package provides doxygen_junit?
32+
run: |
33+
dnf install -y doxygen
34+
cd /workspaces/$PROJECT_NAME
35+
chmod 777 scripts/*.sh
36+
scripts/doxygen.sh || true
37+
# Fix the file path references so they are relative to the blob and not the buildspace. We use ; as the substitute so don't have to escape every forwardslash
38+
sed -i "s;${GITHUB_REPOSITORY}/src;src;g" $BUILD_WORKSPACE/doxygen/doxygen_warnings.log || exit 1
39+
sed -i "s;${GITHUB_REPOSITORY}/test;test;g" $BUILD_WORKSPACE/doxygen/doxygen_warnings.log || exit 1
40+
doxygen_junit --input $BUILD_WORKSPACE/doxygen/doxygen_warnings.log --output $BUILD_WORKSPACE/doxygen/doxygen_junit.xml || exit 1
41+
grep -iq "<error " "$BUILD_WORKSPACE/doxygen/doxygen_junit.xml" && exit 1 || exit 0
42+
43+

.github/workflows/rpm.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: run-tests
2+
on:
3+
workflow_call:
4+
jobs:
5+
build rpm:
6+
runs-on: ubuntu-latest
7+
container:
8+
image: fedora:40
9+
env:
10+
PROJECT_NAME: ${GITHUB_REPOSITORY}
11+
BUILD_WORKSPACE: build
12+
volumes:
13+
- ${GITHUB_WORKSPACE}:/workspaces/${GITHUB_REPOSITORY}
14+
steps:
15+
- name: build-rpm
16+
run: |
17+
dnf install -y rpmdevtools cmake gcc gcc-c++ pkgconf-pkg-config dbus-libs
18+
cd /workspaces/$PROJECT_NAME
19+
rm -rf $BUILD_WORKSPACE # Ensure we start clean
20+
sed -i "s/set(CPACK_RPM_PACKAGE_RELEASE \"[0-9]\+\")/set(CPACK_RPM_PACKAGE_RELEASE \"${GITHUB_RUN_ID}\")/" packaging/rpm/cpack_config.cmake
21+
cmake . -B $BUILD_WORKSPACE -DAPS_CHRONY_DBUS_SERVICE_FETCH_CONTENT_USE_GITLAB_CI_TOKEN=ON -DCMAKE_BUILD_TYPE=Release -DAPS_CHRONY_DBUS_SERVICE_BUILD_TESTS=OFF -DAPS_CHRONY_DBUS_SERVICE_CPACK_RPM_TYPE=RPM
22+
cmake --build $BUILD_WORKSPACE --parallel $PARALLEL
23+
pushd $BUILD_WORKSPACE
24+
../scripts/build_rpm.sh
25+
popd
26+
cmake . -B $BUILD_WORKSPACE -DAPS_CHRONY_DBUS_SERVICE_FETCH_CONTENT_USE_GITLAB_CI_TOKEN=ON -DCMAKE_BUILD_TYPE=Release -DAPS_CHRONY_DBUS_SERVICE_BUILD_TESTS=OFF -DAPS_CHRONY_DBUS_SERVICE_CPACK_RPM_TYPE=SRPM
27+
cmake --build $BUILD_WORKSPACE --parallel $PARALLEL
28+
pushd $BUILD_WORKSPACE
29+
../scripts/build_rpm.sh
30+
popd
31+
mkdir -p $BUILD_WORKSPACE/RPM
32+
rm -rf $BUILD_WORKSPACE/RPM/*
33+
mv $BUILD_WORKSPACE/*.rpm $BUILD_WORKSPACE/RPM
34+
- name: rpm-artifacts
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: rpm
38+
path: ${GITHUB_WORKSPACE}/build/RPM/*.rpm
39+

.github/workflows/tests.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Builds the cmake project with BUILD_TESTS=ON and runs the tests with ctest
2+
3+
name: run-tests
4+
on:
5+
workflow_call:
6+
inputs:
7+
TEST_PARAMS:
8+
description: Parameters passed to ctest
9+
type: string
10+
default: --parallel 16 --schedule-random
11+
jobs:
12+
build-tests:
13+
uses: ./.github/workflows/cmake-gcc.yaml
14+
with:
15+
CMAKE_PARAMS: -DCMAKE_BUILD_TYPE=Release -DAPS_CHRONY_DBUS_SERVICE_BUILD_TESTS=ON
16+
ctest:
17+
needs: build-tests
18+
runs-on: ubuntu-latest
19+
container:
20+
image: fedora:40
21+
env:
22+
PROJECT_NAME: ${GITHUB_REPOSITORY}
23+
BUILD_WORKSPACE: build
24+
CTEST: ${{ input.TEST_PARAMS }}
25+
volumes:
26+
- ${GITHUB_WORKSPACE}:/workspaces/${GITHUB_REPOSITORY}
27+
steps:
28+
- name: run-ctest
29+
run: |
30+
dnf install -y freeradius gtest ctest chrony dbus-libs dbus-daemon
31+
cd /workspaces/$PROJECT_NAME/$BUILD_WORKSPACE
32+
. ../tests/setupenv.sh # start chrony, dbus and set the DBUS_SESSION_BUS_ADDRESS
33+
./src/chrony-dbus-service &
34+
ctest $CTEST
35+
36+

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
# This is the README for chrony-dbus-service.
22

33
## What is chrony?
4-
---
54
chrony is a versatile implementation of the Network Time Protocol (NTP).
65

76
see [gitlab.com/chrony](https://gitlab.com/chrony/chrony)
87

98

109
## What is chrony-dbus-service?
11-
---
1210
To configure chronyd with the chronyc command line tool, each command has to written in a parseable line of text.
1311
Executing chronyc from within another application doesn't provide a good usability and in case that the chronyc parser is changed it will cause maintainability issues.
1412
The chrony-dbus-service provides partial functionality of configuring chornyd like it would be possible with chronyc, but instead this functionality is provided as an accessible DBus interface API.
1513

1614

1715
## Features
18-
---
1916
- ** getSources: ** Lists chronyd sources like calling `chronyc sources`
2017
- ** addServers: ** Adds NTP servers to chronyd like calling `chronyc add server`
2118
- ** deleteServers: ** Removes NTP servers from chronyd like calling `chronyc delete`
@@ -26,6 +23,5 @@ The chrony-dbus-service provides partial functionality of configuring chornyd li
2623

2724

2825
## How to use chrony-dbus-service?
29-
3026
You can use any DBus compatible library like e.g. libdbus-c++ or simppl.
3127
For an example see [chronydbustest.cpp](src/tests/chronydbustest.cpp).

0 commit comments

Comments
 (0)