Skip to content

Commit c030568

Browse files
authored
Merge 5bb873f into 32025fb
2 parents 32025fb + 5bb873f commit c030568

File tree

5 files changed

+111
-22
lines changed

5 files changed

+111
-22
lines changed

.github/actions/publish-coverage/report/report.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ def post_report(coverage, args):
5858
"""Post coverage report to coveralls.io."""
5959
response = requests.post(URL, files={'json_file': json.dumps(coverage)},
6060
verify=(not args.skip_ssl_verify))
61+
6162
try:
6263
result = response.json()
64+
result['status'] = response.status_code
6365
except ValueError:
6466
result = {'error': 'Failure to submit data. '
6567
'Response [%(status)s]: %(text)s' % {
@@ -86,16 +88,10 @@ def main():
8688
print("Environment variable COVERALLS_REPO_TOKEN is required to upload coverage information")
8789
exit(-1)
8890

89-
# Consume Codefresh CI specific environment variables _(if available)_
90-
json_coverage_details['service_job_id'] = os.environ.get('CF_BUILD_ID')
91-
if (json_coverage_details['service_job_id'] is not None):
92-
json_coverage_details['service_name'] = "codefresh"
93-
else:
94-
json_coverage_details['service_name'] = ""
95-
del json_coverage_details['service_job_id']
96-
9791
# Post report to Coveralls.io
98-
post_report(json_coverage_details, args)
92+
if post_report(json_coverage_details, args)!=0:
93+
exit(-2)
94+
9995

10096
if __name__ == '__main__':
10197
main()

.github/workflows/coverage.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
12+
jobs:
13+
coverage:
14+
name: coverage (ubuntu-18.04)
15+
runs-on: ubuntu-18.04
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
submodules: recursive
20+
- name: Install dependencies
21+
run: sudo apt-get update && sudo apt-get install -y lcov g++ valgrind
22+
- name: test
23+
run: ./test/run_all_tests.sh
24+
- name: run lcov
25+
run: lcov --capture --directory . --output-file lcov-all.info && lcov --remove lcov-all.info "*test*" "*mock*" -o lcov.info
26+
- name: Coveralls
27+
uses: coverallsapp/github-action@master
28+
with:
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
path-to-lcov: "./lcov.info"
31+

.github/workflows/note-arduino-ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,4 @@ jobs:
2020
uses: ./.github/actions/run-tests-in-container
2121
env:
2222
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
23-
- name: Publish Test Coverage
24-
id: publish_coverage
25-
uses: ./.github/actions/publish-coverage
2623

src/Not_Covered.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// This file is deliberately not covered. The PR can be thrown away once we validate that coveralls rejects it and accepts it when the code is removed.
2+
3+
#if 0
4+
5+
unsigned int crc32b(unsigned char *message) {
6+
int i, j;
7+
unsigned int byte, crc, mask;
8+
9+
i = 0;
10+
crc = 0xFFFFFFFF;
11+
while (message[i] != 0) {
12+
byte = message[i]; // Get next byte.
13+
crc = crc ^ byte;
14+
for (j = 7; j >= 0; j--) { // Do eight times.
15+
mask = -(crc & 1);
16+
crc = (crc >> 1) ^ (0xEDB88320 & mask);
17+
}
18+
i = i + 1;
19+
}
20+
return ~crc;
21+
}
22+
23+
24+
unsigned int crc32b_2(unsigned char *message) {
25+
int i, j;
26+
unsigned int byte, crc, mask;
27+
28+
i = 0;
29+
crc = 0xFFFFFFFF;
30+
while (message[i] != 0) {
31+
byte = message[i]; // Get next byte.
32+
crc = crc ^ byte;
33+
for (j = 7; j >= 0; j--) { // Do eight times.
34+
mask = -(crc & 1);
35+
crc = (crc >> 1) ^ (0xEDB88320 & mask);
36+
}
37+
i = i + 1;
38+
}
39+
return ~crc;
40+
}
41+
42+
unsigned int crc32b_3(unsigned char *message) {
43+
int i, j;
44+
unsigned int byte, crc, mask;
45+
46+
i = 0;
47+
crc = 0xFFFFFFFF;
48+
while (message[i] != 0) {
49+
byte = message[i]; // Get next byte.
50+
crc = crc ^ byte;
51+
for (j = 7; j >= 0; j--) { // Do eight times.
52+
mask = -(crc & 1);
53+
crc = (crc >> 1) ^ (0xEDB88320 & mask);
54+
}
55+
i = i + 1;
56+
}
57+
return ~crc;
58+
}
59+
60+
void f(void) {
61+
62+
}
63+
64+
#endif

test/run_all_tests.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ all_tests_result=0
55
if [ 0 -eq $all_tests_result ]; then
66
echo && echo 'Compiling and running Notecard Test Suite...'
77
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
8+
src/Not_Covered.cpp \
89
src/Notecard.cpp \
910
test/Notecard.test.cpp \
1011
test/mock/mock-arduino.cpp \
@@ -32,6 +33,7 @@ fi
3233
if [ 0 -eq $all_tests_result ]; then
3334
echo && echo 'Compiling and running NoteI2c_Arduino Test Suite (no flags)...'
3435
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
36+
src/Not_Covered.cpp \
3537
src/NoteI2c_Arduino.cpp \
3638
test/NoteI2c_Arduino.test.cpp \
3739
test/mock/mock-arduino.cpp \
@@ -56,6 +58,7 @@ fi
5658
if [ 0 -eq $all_tests_result ]; then
5759
echo && echo 'Compiling and running NoteI2c_Arduino Test Suite (-DWIRE_HAS_END)...'
5860
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
61+
src/Not_Covered.cpp \
5962
src/NoteI2c_Arduino.cpp \
6063
test/NoteI2c_Arduino.test.cpp \
6164
test/mock/mock-arduino.cpp \
@@ -81,6 +84,7 @@ fi
8184
if [ 0 -eq $all_tests_result ]; then
8285
echo && echo 'Compiling and running NoteLog_Arduino Test Suite...'
8386
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
87+
src/Not_Covered.cpp \
8488
src/NoteLog_Arduino.cpp \
8589
test/NoteLog_Arduino.test.cpp \
8690
test/mock/mock-arduino.cpp \
@@ -104,6 +108,7 @@ fi
104108
if [ 0 -eq $all_tests_result ]; then
105109
echo && echo 'Compiling and running NoteSerial_Arduino Test Suite...'
106110
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
111+
src/Not_Covered.cpp \
107112
src/NoteSerial_Arduino.cpp \
108113
test/NoteSerial_Arduino.test.cpp \
109114
test/mock/mock-arduino.cpp \
@@ -129,20 +134,16 @@ if [ 0 -eq ${all_tests_result} ]; then
129134
echo && echo 'All tests have passed!'
130135
# Run coverage if available
131136
if [ $(which gcovr) ]; then
132-
gcovr --print-summary --sort-percentage --exclude-throw-branches --delete \
137+
echo "GITHUB_ACTIONS $GITHUB_ACTIONS"
138+
echo "GITHUB_WORKFLOW $GITHUB_WORKFLOW"
139+
echo "GITHUB_RUN_ID $GITHUB_RUN_ID"
140+
echo "GITHUB_SHA $GITHUB_SHA"
141+
gcovr --print-summary --sort-percentage --exclude-throw-branches \
133142
--object-directory . \
134143
--root src \
135144
--exclude .*_error.* \
136145
--exclude test \
137-
--coveralls coverage.json \
138-
--txt \
139-
&& rm ./a.out *.gcno
140-
if [ ! -f "coverage.json" ]; then
141-
echo "Coverage report not produced";
142-
all_tests_result=997
143-
fi
144-
else
145-
rm -f ./a.out *.gcda *.gcno
146+
--txt
146147
fi
147148
else
148149
echo && echo 'TESTS FAILED!!!' \

0 commit comments

Comments
 (0)