Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9712cb1

Browse files
authored
Merge pull request #388 from pennam/ci-unit-test
CI Add unit test workflow
2 parents 7a039d7 + ee05fe6 commit 9712cb1

File tree

15 files changed

+314
-17808
lines changed

15 files changed

+314
-17808
lines changed

‎.github/workflows/unit-tests.yml‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Unit Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/unit-tests.yml"
7+
- 'extras/test/**'
8+
- 'src/**'
9+
10+
push:
11+
paths:
12+
- ".github/workflows/unit-tests.yml"
13+
- 'extras/test/**'
14+
- 'src/**'
15+
16+
jobs:
17+
test:
18+
name: Run unit tests
19+
runs-on: ubuntu-latest
20+
21+
env:
22+
COVERAGE_DATA_PATH: extras/coverage-data/coverage.info
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- uses: arduino/cpp-test-action@main
29+
with:
30+
runtime-paths: |
31+
- extras/test/build/bin/TEST_TARGET_UUID
32+
- extras/test/build/bin/TEST_TARGET_DISC_DEVICE
33+
- extras/test/build/bin/TEST_TARGET_ADVERTISING_DATA
34+
coverage-exclude-paths: |
35+
- '*/extras/test/*'
36+
- '/usr/*'
37+
coverage-data-path: ${{ env.COVERAGE_DATA_PATH }}
38+
39+
# A token is used to avoid intermittent spurious job failures caused by rate limiting.
40+
- name: Set up Codecov upload token
41+
run: |
42+
if [[ "${{ github.repository }}" == "arduino-libraries/ArduinoBLE" ]]; then
43+
# In order to avoid uploads of data from forks, only use the token for runs in the parent repo.
44+
# Token is intentionally exposed.
45+
# See: https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
46+
CODECOV_TOKEN="8118de48-b2af-48b4-a66a-26026847bfc5"
47+
else
48+
# codecov/codecov-action does unauthenticated upload if empty string is passed via the `token` input.
49+
CODECOV_TOKEN=""
50+
fi
51+
echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> "$GITHUB_ENV"
52+
53+
- name: Upload coverage report to Codecov
54+
uses: codecov/codecov-action@v3
55+
with:
56+
file: "${{ env.COVERAGE_DATA_PATH }}"
57+
fail_ci_if_error: true
58+
token: ${{ env.CODECOV_TOKEN }}

‎extras/test/.gitignore‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
build
1+
build
2+
### CMake ###
3+
CMakeLists.txt.user
4+
CMakeCache.txt
5+
CMakeFiles
6+
CMakeScripts
7+
Testing
8+
Makefile
9+
cmake_install.cmake
10+
install_manifest.txt
11+
compile_commands.json
12+
CTestTestfile.cmake
13+
_deps
14+
15+
### CMake Patch ###
16+
# External projects
17+
*-prefix/

‎extras/test/CMakeLists.txt‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
##########################################################################
22

33
set(CMAKE_VERBOSE_MAKEFILE ON)
4-
cmake_minimum_required(VERSION 2.8)
4+
cmake_minimum_required(VERSION 3.5)
55

66
##########################################################################
77

88
project(testArduinoBLE)
99

10+
Include(FetchContent)
11+
12+
FetchContent_Declare(
13+
Catch2
14+
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
15+
GIT_TAG v3.4.0
16+
)
17+
18+
FetchContent_MakeAvailable(Catch2)
19+
1020
##########################################################################
1121

1222
set(CMAKE_CXX_STANDARD 11)
@@ -35,6 +45,9 @@ set(DUT_SRCS
3545
../../src/utility/HCI.cpp
3646
../../src/utility/GATT.cpp
3747
../../src/utility/L2CAPSignaling.cpp
48+
../../src/utility/keyDistribution.cpp
49+
../../src/utility/bitDescriptions.cpp
50+
../../src/utility/btct.cpp
3851
../../src/local/BLELocalAttribute.cpp
3952
../../src/local/BLELocalCharacteristic.cpp
4053
../../src/local/BLELocalDescriptor.cpp
@@ -102,7 +115,6 @@ include_directories(../../src)
102115
include_directories(../../src/local)
103116
include_directories(../../src/remote)
104117
include_directories(../../src/utility)
105-
include_directories(external/catch/v2.12.1/include)
106118

107119
target_include_directories(TEST_TARGET_DISC_DEVICE PUBLIC include/test_discovered_device)
108120
target_include_directories(TEST_TARGET_ADVERTISING_DATA PUBLIC include/test_advertising_data)
@@ -124,3 +136,7 @@ add_custom_command(TARGET TEST_TARGET_DISC_DEVICE POST_BUILD
124136
add_custom_command(TARGET TEST_TARGET_ADVERTISING_DATA POST_BUILD
125137
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/TEST_TARGET_ADVERTISING_DATA
126138
)
139+
140+
target_link_libraries( TEST_TARGET_UUID Catch2WithMain )
141+
target_link_libraries( TEST_TARGET_DISC_DEVICE Catch2WithMain )
142+
target_link_libraries( TEST_TARGET_ADVERTISING_DATA Catch2WithMain )

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /