chore(ci): job dependency
[KDIS.git] / .github / workflows / check.yaml
blobb5ea463e994401d593dedae75e7e338eaea18b93
1 name: check
3 on:
4     push:
5         branches:
6             - master
7         tags:
8             - v*
9     pull_request:
10         branches:
11             - master
13 concurrency:
14     group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15     cancel-in-progress: true
17 jobs:
18     version:
19         name: Version
20         if: startsWith(github.ref_name, 'v')
21         runs-on: ubuntu-latest
22         steps:
23             - name: Checkout
24               uses: actions/checkout@v4
25               with:
26                   fetch-depth: 0
28             - name: Check Git tag format
29               run: |
30                   _tag="${{ github.ref_name }}"
31                   if ! printf "%s\n" "$_tag" | grep -q -P '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(alpha|beta|rc)\.(0|[1-9][0-9]*))?$'; then
32                     printf '[ERROR]: Git tag (%s) wrong format\n' "$_tag"
33                     exit 1
34                   fi
36     code:
37         name: Code
38         needs: version
39         if: always() && (needs.version.result == 'success' || needs.version.result == 'skipped')
40         runs-on: ubuntu-latest
41         steps:
42             - name: Checkout
43               uses: actions/checkout@v4
44               with:
45                   fetch-depth: 0
47             - name: Setup Python
48               uses: actions/setup-python@v4
50             - name: Install cmakelang
51               run: pip install cmakelang[YAML]
53             - name: Clang Format
54               run: |
55                   find . \
56                       -not -path './build/*' \
57                       -type f \( \
58                       -name '*.hpp' \
59                       -o -name '*.hpp.in' \
60                       -o -name '*.cpp' \
61                       \) \
62                       -print0 |
63                       xargs -0 -n1 \
64                           clang-format \
65                           -Werror \
66                           --dry-run \
67                           --style=file
69             # TODO(carlocorradini) Clang Tidy
71             - name: CMake Format
72               run: |
73                   find . \
74                       -not -path './build/*' \
75                       -not -path './cmake/CPM.cmake' \
76                       -type f \( \
77                       -name 'CMakeLists.txt' \
78                       -o -name '*.cmake' \
79                       \) \
80                       -print0 |
81                       xargs -0 -n1 \
82                           cmake-format --check
84             - name: CMake Lint
85               run: |
86                   find . \
87                       -not -path './build/*' \
88                       -not -path './cmake/CPM.cmake' \
89                       -type f \( \
90                       -name 'CMakeLists.txt' \
91                       -o -name '*.cmake' \
92                       \) \
93                       -print0 |
94                       xargs -0 -n1 \
95                           cmake-lint
97             # TODO(carlocorradini) Cppcheck
99             # TODO(carlocorradini) Cpplint
101     build:
102         name: Build
103         needs: code
104         if: needs.code.result == 'success'
105         strategy:
106             fail-fast: true
107             matrix:
108                 # TODO(carlocorradini) Add macos-latest
109                 os: [ubuntu-latest, windows-latest]
110                 build: [Debug, Release]
111                 dis: [5, 6, 7]
112         runs-on: ${{ matrix.os }}
113         steps:
114             - name: Checkout
115               uses: actions/checkout@v4
116               with:
117                   fetch-depth: 0
119             - name: Install Doxygen
120               uses: ssciwr/doxygen-install@v1
122             - name: Configure CMake
123               run: cmake -S . -B ./build -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DDIS_VERSION=${{ matrix.dis }} -DBUILD_SHARED_LIBS=OFF -DBUILD_DOCS=ON -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON
125             - name: Build
126               run: cmake --build ./build --config ${{ matrix.build }}
128             - name: Test
129               run: ctest --verbose --test-dir ./build/tests --build-config ${{ matrix.build }}
131             # TODO(carlocorradini) Code coverage