Skip to content

Commit

Permalink
ci, fix: compilation fix-up + add colcon CI check (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Mobarak authored Jul 21, 2023
1 parent 109508c commit 6f88dc7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @swift-nav/platform @switanis
15 changes: 13 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
32 changes: 15 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
6 changes: 3 additions & 3 deletions src/logging/sbp_file_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char, FNAME_MAX_LEN> fname = "";
std::array<char, FNAME_MAX_LEN> fname{""};

// Create dir
if (!FileSystem::createDir(file_path)) {
Expand All @@ -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,
Expand All @@ -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();
Expand Down

0 comments on commit 6f88dc7

Please sign in to comment.