-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Clang sanitizer checks in CI #711
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,70 @@ on: | |
branches: [master, stable-*] | ||
|
||
jobs: | ||
tests: | ||
name: Test Compile ${{ matrix.compiler }} | ||
gcc-tests: | ||
name: Test Compile gcc | ||
runs-on: ubuntu-latest | ||
env: | ||
CC: ${{ matrix.compiler }} | ||
CC: gcc | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Install Doxygen | ||
run: | | ||
sudo apt update | ||
sudo apt-get install doxygen graphviz clang-format-9 | ||
|
||
- name: Configure build | ||
run: cmake -Bbuild -DWARNINGS_AS_ERRORS=ON . | ||
|
||
- name: Formatting check | ||
working-directory: build | ||
run: | | ||
clang-format-9 --version | ||
make format | ||
git diff --exit-code | ||
|
||
- name: Build | ||
working-directory: build | ||
run: make | ||
|
||
- name: binding-functions | ||
working-directory: build | ||
run: | | ||
make binding-functions | ||
test -s binding-functions | ||
|
||
- name: Tests | ||
working-directory: build | ||
run: | | ||
make test | ||
sudo make install | ||
|
||
# Note the packages aren't used to test the examples below | ||
- name: Test packaging | ||
working-directory: build | ||
run: cpack -D CPACK_PACKAGE_CONTACT="Test build in CI" | ||
|
||
- name: Examples | ||
run: | | ||
mkdir build/examples | ||
cd build/examples | ||
cmake ../../examples | ||
make | ||
make test | ||
|
||
clang-tests: | ||
name: Test Compile clang ${{ matrix.compile_opt }} | ||
runs-on: ubuntu-latest | ||
env: | ||
CC: clang | ||
|
||
strategy: | ||
matrix: | ||
compiler: [clang, gcc] | ||
# See Clang docs for more information on the sanitizers: | ||
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html | ||
compile_opt: ["", "-fsanitize=undefined,float-divide-by-zero -fno-sanitize-recover=undefined,float-divide-by-zero", "-fsanitize=memory -fno-sanitize-recover=memory", "-fsanitize=address -fno-sanitize-recover=address"] | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
@@ -26,7 +81,7 @@ jobs: | |
sudo apt-get install doxygen graphviz clang-format-9 | ||
|
||
- name: Configure build | ||
run: cmake -Bbuild -DWARNINGS_AS_ERRORS=ON . | ||
run: cmake -Bbuild -DWARNINGS_AS_ERRORS=ON -DCMAKE_C_FLAGS="${{ matrix.compile_opt }}" . | ||
|
||
- name: Formatting check | ||
working-directory: build | ||
|
@@ -60,7 +115,7 @@ jobs: | |
run: | | ||
mkdir build/examples | ||
cd build/examples | ||
cmake ../../examples | ||
cmake -DCMAKE_C_FLAGS="${{ matrix.compile_opt }}" ../../examples | ||
make | ||
make test | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,7 +123,12 @@ H3Error bboxHexEstimate(const BBox *bbox, int res, int64_t *out) { | |
double d = H3_EXPORT(greatCircleDistanceKm)(&p1, &p2); | ||
// Derived constant based on: https://math.stackexchange.com/a/1921940 | ||
// Clamped to 3 as higher values tend to rapidly drag the estimate to zero. | ||
double a = d * d / fmin(3.0, fabs((p1.lng - p2.lng) / (p1.lat - p2.lat))); | ||
double lngDiff = p1.lng - p2.lng; | ||
double latDiff = p1.lat - p2.lat; | ||
if (lngDiff == 0 || latDiff == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my info, how are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isfinite is checked below |
||
return E_FAILED; | ||
} | ||
double a = d * d / fmin(3.0, fabs(lngDiff / latDiff)); | ||
|
||
// Divide the two to get an estimate of the number of hexagons needed | ||
double estimateDouble = ceil(a / pentagonAreaKm2); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did these need to be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly they didn't need to - I was trying to adjust some test cases to get better coverage although I don't think I really accomplished that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, they do need to be changed because as defined this is a straight line. polygonToCells will reject straight lines now - even if a cell centroid is along the line - because it would have attempted to divide by zero when estimating.