From 6f88dc72abd5c6004a5758cb28c1853239edfaa0 Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Fri, 21 Jul 2023 09:05:54 -0700 Subject: [PATCH] ci, fix: compilation fix-up + add colcon CI check (#39) --- .github/CODEOWNERS | 1 + .github/workflows/build.yml | 15 +++++++++++++-- Dockerfile | 32 +++++++++++++++----------------- src/logging/sbp_file_logger.cpp | 6 +++--- 4 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..865c1d7a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @swift-nav/platform @switanis diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ffe4dfe..c07a9219 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,8 +25,8 @@ jobs: docker run --rm -v $PWD:/mnt/workspace/src/swiftnav-ros2 swiftnav-ros2:latest /bin/bash ./code_coverage.sh $GITHUB_TOKEN \ $SONAR_TOKEN \ $PARALLEL_THREADS - build-pr: - name: Build pull request + build-pr-codecov: + name: Build pull request (code coverage) runs-on: ubuntu-latest if: github.ref != 'refs/heads/master' steps: @@ -44,3 +44,14 @@ jobs: $PARALLEL_THREADS \ $PR_BRANCH_NAME \ $PR_NUMBER + + build-pr-colcon: + name: Build pull request (colcon) + runs-on: ubuntu-latest + if: github.ref != 'refs/heads/master' + steps: + - uses: actions/checkout@v2 + - name: colcon build + run: | + docker build -t swiftnav-ros2 --build-arg UID=$UID --build-arg SONAR_SCANNER_VERSION=$SONAR_SCANNER_VERSION - < Dockerfile + docker run --rm -v $PWD:/mnt/workspace/src/swiftnav-ros2 swiftnav-ros2:latest colcon build diff --git a/Dockerfile b/Dockerfile index b049124a..97f61c5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,34 +23,32 @@ RUN apt-get update && apt-get install --yes \ # Add a "dockerdev" user with sudo capabilities # 1000 is the first user ID issued on Ubuntu; might # be different for Mac users. Might need to add more. -RUN \ - useradd -u ${UID} -ms /bin/bash -G sudo dockerdev \ - && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers +RUN useradd -u ${UID} -ms /bin/bash -G sudo dockerdev && \ + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers && \ + chown -R dockerdev:dockerdev $HOME/ -RUN chown -R dockerdev:dockerdev $HOME/ USER dockerdev WORKDIR $HOME/ -RUN git clone https://github.com/swift-nav/libsbp.git && cd libsbp && git checkout v4.11.0 -WORKDIR $HOME/libsbp/c -RUN git submodule update --init --recursive -RUN mkdir build && \ - cd build && \ - cmake DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_EXTENSIONS=OFF ../ && \ - make && \ + +RUN git clone --depth=1 --branch v4.11.0 --single-branch --recursive --jobs=4 https://github.com/swift-nav/libsbp.git && \ + mkdir -p libsbp/c/build && \ + cd libsbp/c/build && \ + cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_EXTENSIONS=OFF ../ && \ + make -j4 && \ sudo make install # Install code coverage tool RUN sudo apt-get -y install gcovr # Download and set up sonar-scanner -RUN sudo apt-get -y install unzip -RUN mkdir -p $HOME/.sonar -RUN curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip -RUN unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ +RUN sudo apt-get -y install unzip && \ + mkdir -p $HOME/.sonar && \ + curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip && \ + unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + ENV PATH="${PATH}:/home/dockerdev/.sonar/sonar-scanner-${SONAR_SCANNER_VERSION}-linux/bin" WORKDIR /mnt/workspace/src/swiftnav-ros2 -RUN sudo chown -R dockerdev:dockerdev /mnt/workspace/ -#CMD ["make", "all"] +RUN sudo chown -R dockerdev:dockerdev /mnt/workspace/ diff --git a/src/logging/sbp_file_logger.cpp b/src/logging/sbp_file_logger.cpp index de14566d..9f86360d 100644 --- a/src/logging/sbp_file_logger.cpp +++ b/src/logging/sbp_file_logger.cpp @@ -25,7 +25,7 @@ SbpFileLogger::SbpFileLogger(const std::string& file_path, : state_(nullptr, this), logger_(logger) { std::string file_name(file_path); time_t now = time(nullptr); - std::array fname = ""; + std::array fname{""}; // Create dir if (!FileSystem::createDir(file_path)) { @@ -41,7 +41,7 @@ SbpFileLogger::SbpFileLogger(const std::string& file_path, localtime_r(&now, &local_time); #endif // _WIN32 - std::snprintf(fname, FNAME_MAX_LEN, + std::snprintf(fname.data(), FNAME_MAX_LEN, "/swiftnav-%d%02d%02d-%02d%02d%02d.sbp", local_time.tm_year + 1900, local_time.tm_mon + 1, @@ -50,7 +50,7 @@ SbpFileLogger::SbpFileLogger(const std::string& file_path, local_time.tm_min, local_time.tm_sec); - file_name += std::string(fname); + file_name += std::string(fname.data()); std::filesystem::path path(file_name); file_name = path.lexically_normal().string();