Skip to content

Commit

Permalink
ci: Check and fix missing includes (#2248)
Browse files Browse the repository at this point in the history
This adds a simple script to check all main header files of ACTS for missing includes (like in #2247). This is done very simple: 
We try to compile (and not link)
```c++
#include <file>
int main() { return 0; }
```
If this succeeds, the compiler is able to parse the whole file sucessfully, and thus no include is missing.

This check takes about 10 minutes on my machine for the `Core` package... I think that is worth it.
  • Loading branch information
benjaminhuth authored Jul 14, 2023
1 parent 8fbbc46 commit 8833e70
Show file tree
Hide file tree
Showing 24 changed files with 84 additions and 8 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ jobs:
- name: Check
run: >
CI/check_spelling
missing_includes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install clang
run: >
sudo apt-get install -y clang libeigen3-dev libboost-dev
- name: Check
run: >
CI/missing_include_check.sh
fpe_masks:
runs-on: ubuntu-latest
steps:
Expand Down
26 changes: 26 additions & 0 deletions CI/missing_include_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

RET=0
ERRORS=0

FILES=$(find Core/include/ -name "*.hpp" | grep -v "/detail/")
N_FILES=$(echo "$FILES" | wc -l)
echo "Check $N_FILES files"

ITER=0

for file in $(find Core/include/ -name "*.hpp" | grep -v "/detail/"); do
ITER=$((ITER+1))
echo "$(date +%H:%M:%S) $((100*ITER/N_FILES))% check $file"
out=$(printf "#include <${file:13}>\nint main() { return 0; }" | clang++ -std=c++17 -O0 -c -I "Core/include" -I "/usr/include/eigen3" -x c++ - 2>&1)
if [[ "$?" -ne "0" ]]; then
echo "------------------------------------"
echo "$out"
echo "------------------------------------"
RET=1
ERRORS=$((ERRORS+1))
fi
done

echo "Total errors: $ERRORS"
exit $RET
2 changes: 2 additions & 0 deletions Core/include/Acts/EventData/SingleFreeTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Common.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/EventData/detail/PrintParameters.hpp"
#include "Acts/Utilities/UnitVectors.hpp"

Expand Down
2 changes: 2 additions & 0 deletions Core/include/Acts/EventData/TrackParametersConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

#include <optional>
#include <type_traits>

namespace Acts {
Expand Down
4 changes: 4 additions & 0 deletions Core/include/Acts/EventData/TrackStateType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
#pragma once

#include <bitset>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <ostream>

namespace Acts {

/// @enum TrackStateFlag
Expand Down
2 changes: 2 additions & 0 deletions Core/include/Acts/EventData/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#pragma once

#include <type_traits>

namespace Acts::detail {

template <template <typename...> class, template <typename...> class>
Expand Down
2 changes: 2 additions & 0 deletions Core/include/Acts/Geometry/GeometryObjectSorter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Utilities/VectorHelpers.hpp"

#include <functional>
#include <memory>

namespace Acts {

Expand Down
1 change: 1 addition & 0 deletions Core/include/Acts/Geometry/ITrackingVolumeHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Utilities/BinningType.hpp"

#include <memory>
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Material/MaterialComposition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include <algorithm>
#include <cassert>
#include <cstdint>
#include <vector>
Expand Down Expand Up @@ -123,7 +124,7 @@ class MaterialComposition {
/// Check if the composed material is valid, i.e. it is not vacuum.
operator bool() const { return !m_elements.empty(); }
/// Return the number of elements.
size_t size() const { return m_elements.size(); }
std::size_t size() const { return m_elements.size(); }

private:
std::vector<ElementFraction> m_elements;
Expand Down
1 change: 1 addition & 0 deletions Core/include/Acts/Navigation/NavigationStateFillers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Utilities/Intersection.hpp"

Expand Down
4 changes: 4 additions & 0 deletions Core/include/Acts/Propagator/StepperExtensionList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@

#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Propagator/detail/Auctioneer.hpp"
#include "Acts/Utilities/detail/Extendable.hpp"
#include "Acts/Utilities/detail/MPL/all_of.hpp"
#include "Acts/Utilities/detail/MPL/has_duplicates.hpp"

#include <array>

namespace Acts {

/// @brief Container of extensions used in the stepper of the propagation. This
Expand Down
1 change: 1 addition & 0 deletions Core/include/Acts/Propagator/detail/Auctioneer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <algorithm>
#include <array>

namespace Acts {
namespace detail {
Expand Down
1 change: 1 addition & 0 deletions Core/include/Acts/Seeding/CandidatesForMiddleSp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <algorithm>
#include <limits>
#include <memory>
#include <tuple>
#include <vector>
Expand Down
1 change: 1 addition & 0 deletions Core/include/Acts/Seeding/IExperimentCuts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Acts/Seeding/CandidatesForMiddleSp.hpp"
#include "Acts/Seeding/InternalSeed.hpp"

#include <limits>
#include <memory>

namespace Acts {
Expand Down
5 changes: 3 additions & 2 deletions Core/include/Acts/Seeding/SeedConfirmationRangeConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "Acts/Definitions/Units.hpp"

#include <cstdint>
#include <limits>

namespace Acts {
Expand All @@ -29,10 +30,10 @@ struct SeedConfirmationRangeConfig {

// number of compatible top SPs of seed if bottom radius is larger than
// rMaxSeedConf
size_t nTopForLargeR = 0;
std::size_t nTopForLargeR = 0;
// number of compatible top SPs of seed if bottom radius is smaller than
// rMaxSeedConf
size_t nTopForSmallR = 0;
std::size_t nTopForSmallR = 0;

// minimum radius for bottom SP in seed confirmation
float seedConfMinBottomRadius = 60. * Acts::UnitConstants::mm;
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Seeding/SeedFilterConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#include "Acts/Definitions/Units.hpp"
#include "Acts/Seeding/SeedConfirmationRangeConfig.hpp"

// System include(s).
#include <cstddef>
#include <cstdint>
#include <stdexcept>

namespace Acts {
struct SeedFilterConfig {
Expand Down
5 changes: 4 additions & 1 deletion Core/include/Acts/Utilities/Enumerate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#pragma once

#include <tuple>
#include <utility>

namespace Acts {
/// Helper utility to allow indexed enumeration with structured binding
///
Expand All @@ -23,7 +26,7 @@ template <typename container_type,
typename = decltype(std::end(std::declval<container_type>()))>
constexpr auto enumerate(container_type &&iterable) {
struct iterator {
size_t i;
std::size_t i;
container_type_iter iter;

bool operator!=(const iterator &rhs) const { return iter != rhs.iter; }
Expand Down
4 changes: 4 additions & 0 deletions Core/include/Acts/Utilities/KDTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <memory>
#include <string>
#include <vector>

namespace Acts {
/// @brief A general k-d tree with fast range search.
Expand Down
2 changes: 2 additions & 0 deletions Core/include/Acts/Utilities/RangeXD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <algorithm>
#include <array>
#include <limits>
#include <sstream>
#include <string>

namespace Acts {
/// @brief An orthogonal range in an arbitrary number of dimensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/Utilities/Result.hpp"
#include "Acts/Vertexing/AdaptiveGridTrackDensity.hpp"
#include "Acts/Vertexing/DummyVertexFitter.hpp"
#include "Acts/Vertexing/Vertex.hpp"
#include "Acts/Vertexing/VertexingOptions.hpp"

#include "DummyVertexFitter.hpp"
#include <map>

namespace Acts {

Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Vertexing/GridDensityVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/Utilities/Result.hpp"
#include "Acts/Vertexing/DummyVertexFitter.hpp"
#include "Acts/Vertexing/GaussianGridTrackDensity.hpp"
#include "Acts/Vertexing/Vertex.hpp"
#include "Acts/Vertexing/VertexingOptions.hpp"

#include "DummyVertexFitter.hpp"
#include <map>

namespace Acts {

Expand Down
2 changes: 2 additions & 0 deletions Core/include/Acts/Vertexing/LinearizedTrack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"

namespace Acts {

/// @class LinearizedTrack
Expand Down
2 changes: 2 additions & 0 deletions Core/include/Acts/Vertexing/LinearizerConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/Utilities/Result.hpp"
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Visualization/ViewConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <array>
#include <string>

namespace Acts {

Expand Down Expand Up @@ -44,4 +45,4 @@ struct ViewConfig {
std::string outputName = "";
};

} // namespace Acts
} // namespace Acts

0 comments on commit 8833e70

Please sign in to comment.