Skip to content

Commit 3af5629

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

File tree

8 files changed

+282
-4
lines changed

8 files changed

+282
-4
lines changed

.github/ci.yaml

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

.github/workflows/cmake-gcc.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
options: --cpus 1
23+
steps:
24+
- name: build cmake gcc
25+
run: |
26+
dnf install -y cmake clang clang-tools-extra gcc gcc-c++ pkgconf-pkg-config dbus-libs
27+
cd /workspaces/$PROJECT_NAME
28+
rm -rf $BUILD_WORKSPACE # Ensure we start clean
29+
cmake . -B $BUILD_WORKSPACE ${{ inputs.CMAKE_PARAMS }}
30+
cmake --build $BUILD_WORKSPACE --parallel $PARALLEL
31+
32+

.github/workflows/cppcheck.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
needs: run-cppcheck
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: cppcheck
37+
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: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
options: --cpus 1
15+
steps:
16+
- name: build-rpm
17+
run: |
18+
dnf install -y rpmdevtools cmake gcc gcc-c++ pkgconf-pkg-config dbus-libs
19+
cd /workspaces/$PROJECT_NAME
20+
rm -rf $BUILD_WORKSPACE # Ensure we start clean
21+
sed -i "s/set(CPACK_RPM_PACKAGE_RELEASE \"[0-9]\+\")/set(CPACK_RPM_PACKAGE_RELEASE \"${GITHUB_RUN_ID}\")/" packaging/rpm/cpack_config.cmake
22+
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
23+
cmake --build $BUILD_WORKSPACE --parallel $PARALLEL
24+
pushd $BUILD_WORKSPACE
25+
../scripts/build_rpm.sh
26+
popd
27+
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
28+
cmake --build $BUILD_WORKSPACE --parallel $PARALLEL
29+
pushd $BUILD_WORKSPACE
30+
../scripts/build_rpm.sh
31+
popd
32+
mkdir -p $BUILD_WORKSPACE/RPM
33+
rm -rf $BUILD_WORKSPACE/RPM/*
34+
mv $BUILD_WORKSPACE/*.rpm $BUILD_WORKSPACE/RPM
35+
- name: rpm-artifacts
36+
needs: build-rpm
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: rpm
40+
path: ${GITHUB_WORKSPACE}/build/RPM/*.rpm
41+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
options: --cpus 1
15+
steps:
16+
- name: build-rpm
17+
run: |
18+
dnf install -y rpmdevtools cmake gcc gcc-c++ pkgconf-pkg-config dbus-libs
19+
cd /workspaces/$PROJECT_NAME
20+
rm -rf $BUILD_WORKSPACE # Ensure we start clean
21+
sed -i "s/set(CPACK_RPM_PACKAGE_RELEASE \"[0-9]\+\")/set(CPACK_RPM_PACKAGE_RELEASE \"${GITHUB_RUN_ID}\")/" packaging/rpm/cpack_config.cmake
22+
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
23+
cmake --build $BUILD_WORKSPACE --parallel $PARALLEL
24+
pushd $BUILD_WORKSPACE
25+
../scripts/build_rpm.sh
26+
popd
27+
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
28+
cmake --build $BUILD_WORKSPACE --parallel $PARALLEL
29+
pushd $BUILD_WORKSPACE
30+
../scripts/build_rpm.sh
31+
popd
32+
mkdir -p $BUILD_WORKSPACE/RPM
33+
rm -rf $BUILD_WORKSPACE/RPM/*
34+
mv $BUILD_WORKSPACE/*.rpm $BUILD_WORKSPACE/RPM
35+
- name: rpm-artifacts
36+
needs: build-rpm
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: rpm
40+
path: ${GITHUB_WORKSPACE}/build/RPM/*.rpm
41+

.github/workflows/tests.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
needs: setup
14+
uses: ./.github/workflows/cmake-gcc.yaml
15+
with:
16+
CMAKE_PARAMS: -DCMAKE_BUILD_TYPE=Release -DAPS_CHRONY_DBUS_SERVICE_BUILD_TESTS=ON
17+
ctest:
18+
needs: build-tests
19+
runs-on: ubuntu-latest
20+
container:
21+
image: fedora:40
22+
env:
23+
PROJECT_NAME: ${GITHUB_REPOSITORY}
24+
BUILD_WORKSPACE: build
25+
CTEST: ${{ input.TEST_PARAMS }}
26+
volumes:
27+
- ${GITHUB_WORKSPACE}:/workspaces/${GITHUB_REPOSITORY}
28+
options: --cpus 1
29+
steps:
30+
- name: run-ctest
31+
run: |
32+
dnf install -y freeradius gtest ctest chrony dbus-libs dbus-daemon
33+
cd /workspaces/$PROJECT_NAME/$BUILD_WORKSPACE
34+
. ../tests/setupenv.sh # start chrony, dbus and set the DBUS_SESSION_BUS_ADDRESS
35+
./src/chrony-dbus-service &
36+
ctest $CTEST
37+
38+

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)