diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index d85aca6..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,97 +0,0 @@ -version: 2 -# Copyright (C) 2018-2021 LEIDOS. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -# - -# Configuration file for Circle CI -# CI will report failure if any executed command returns and error status -# Operations performed are as follows -# Build source code -# Run unit tests for C++ and Java -# Run static code analyzer for SourceCloud -# Upload test results -# Every run command should start with source ${INIT_ENV} to ensure all default dependancies are available - -jobs: - build: - # Pull docker image from docker hub - # XTERM used for better catkin_make output - docker: - - image: usdotfhwastol/carma-base:carma-system-4.4.0 - user: carma - environment: - TERM: xterm # use xterm to get full display output from build - INIT_ENV: /home/carma/.base-image/init-env.sh - ROS_2_ENV: /opt/ros/foxy/setup.bash - working_directory: "/opt/carma/" - resource_class: large - # Execution steps - steps: - - run: - name: Create src folder - command: | - source ${INIT_ENV} - mkdir src - cd src - mkdir CARMACohdaDsrcDriver - - checkout: - path: src/CARMACohdaDsrcDriver - - run: - name: Pull Deps - command: | - source ${INIT_ENV} - ./src/CARMACohdaDsrcDriver/docker/checkout.bash -r ${PWD} - - run: - name: Build Driver - command: | - source ${INIT_ENV} - source ${ROS_2_ENV} - make_with_coverage.bash -m -e /opt/carma/ -o ./coverage_reports/gcov - - run: - name: Run C++ Tests - command: | - source ${INIT_ENV} - source ${ROS_2_ENV} - make_with_coverage.bash -t -e /opt/carma/ -o ./coverage_reports/gcov - # Run SonarCloud analysis - # PR Branchs and number extracted from Circle variables and github api - # Circle CI seems to make a change to the base branch, so we must fetch --force to ensure correct git file change stats - # SONAR_SCANNER_TOKEN MUST be secured as an environment variable in Circle CI NOT in this file. - # The following sonar settings MUST be set in SonarCloud UI NOT in this file - # sonar.pullrequest.provider - # sonar.pullrequest.github.endpoint - # sonar.pullrequest.github.token.secured - # sonar.pullrequest.github.repository - # Use -X on sonar-scanner to enable debug output - - run: - name: Run Sonar Scanner - command: | - source ${INIT_ENV} - if [ -z "${CIRCLE_PULL_REQUEST}" ]; then - echo "Non-PR Build Detected. Running analysis on ${CIRCLE_BRANCH}" - cd src/CARMACohdaDsrcDriver - sonar-scanner -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN} - exit 0; - fi - echo "PR branch ${CIRCLE_BRANCH}" - echo "Repo name ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}" - echo "URL ${CIRCLE_PULL_REQUEST}" - export PR_NUM=`echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f7` - echo "PR number ${PR_NUM}" - export BASE_BRANCH_URL="https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${PR_NUM}" - export TARGET_BRANCH=$(curl "$BASE_BRANCH_URL" | jq '.base.ref' | tr -d '"') - echo "Target Branch = ${TARGET_BRANCH}" - cd src/CARMACohdaDsrcDriver - git fetch --force origin ${TARGET_BRANCH}:${TARGET_BRANCH} - sonar-scanner -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN} -Dsonar.pullrequest.base=${TARGET_BRANCH} -Dsonar.pullrequest.branch=${CIRCLE_BRANCH} -Dsonar.pullrequest.key=${PR_NUM} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e0de58c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: CI +on: + push: + pull_request: +jobs: + build: + defaults: + run: + shell: bash + working-directory: "/opt/carma/" + runs-on: ubuntu-latest + container: + image: usdotfhwastol/carma-base:carma-system-4.5.0 + env: + INIT_ENV: "/home/carma/.base-image/init-env.sh" + ROS_2_ENV: "/opt/ros/foxy/setup.bash" + TERM: xterm + options: "--user root" + steps: + - name: Checkout ${{ github.event.repository.name }} + uses: actions/checkout@v3.3.0 + with: + fetch-depth: 0 + path: src/${{ github.event.repository.name }} + - name: Move source code + run: mv $GITHUB_WORKSPACE/src /opt/carma/ + - name: Checkout dependencies + run: | + source "$INIT_ENV" + ./src/${{ github.event.repository.name }}/docker/checkout.bash -r /opt/carma/ + - name: Build + run: | + source "$INIT_ENV" + source "$ROS_2_ENV" + sed -i '/colcon build/ s/$/ --packages-up-to dsrc_driver/' /home/carma/.ci-image/engineering_tools/code_coverage/make_with_coverage.bash + make_with_coverage.bash -m -e /opt/carma/ -o ./coverage_reports/gcov + - name: Run C++ Tests + run: | + source "$INIT_ENV" + source "$ROS_2_ENV" + sed -i '/colcon test/ s/$/ --packages-above dsrc_driver/' /home/carma/.ci-image/engineering_tools/code_coverage/make_with_coverage.bash + make_with_coverage.bash -t -e /opt/carma/ -o ./coverage_reports/gcov + - name: Run SonarScanner + uses: usdot-fhwa-stol/actions/sonar-scanner@main + with: + sonar-token: ${{ secrets.SONAR_TOKEN }} + working-dir: "/opt/carma/src/${{ github.event.repository.name }}" diff --git a/.sonarqube/sonar-scanner.properties b/.sonarqube/sonar-scanner.properties index 2245536..04afb9e 100644 --- a/.sonarqube/sonar-scanner.properties +++ b/.sonarqube/sonar-scanner.properties @@ -16,7 +16,6 @@ sonar.projectKey=usdot-fhwa-stol_CARMACohdaDsrcDriver sonar.organization=usdot-fhwa-stol -sonar.cfamily.cache.enabled=false sonar.cfamily.compile-commands=/opt/carma/build/compile_commands.json sonar.host.url=https://sonarcloud.io sonar.sources=dsrc_driver/src/ diff --git a/Dockerfile b/Dockerfile index 28876bb..776e76e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations under # the License. -FROM usdotfhwastol/carma-base:carma-system-4.4.0 as setup +FROM usdotfhwastol/carma-base:carma-system-4.5.0 as setup ARG ROS1_PACKAGES="" ENV ROS1_PACKAGES=${ROS1_PACKAGES} @@ -24,7 +24,7 @@ COPY --chown=carma . /home/carma/src/ RUN ~/src/docker/checkout.bash RUN ~/src/docker/install.sh -FROM usdotfhwastol/carma-base:carma-system-4.4.0 +FROM usdotfhwastol/carma-base:carma-system-4.5.0 ARG BUILD_DATE="NULL" ARG VERSION="NULL" diff --git a/README.md b/README.md index b18d2ce..9df0817 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -| CicleCI Build Status | Sonar Code Quality | DockerHub Release | DockerHub Release Candidate | DockerHub Develop | +| CI Build Status | Sonar Code Quality | DockerHub Release | DockerHub Release Candidate | DockerHub Develop | |------|-----|-----|-----|-----| -[![CircleCI](https://img.shields.io/circleci/build/gh/usdot-fhwa-stol/carma-cohda-dsrc-driver/develop?label=CircleCI)](https://app.circleci.com/pipelines/github/usdot-fhwa-stol/carma-cohda-dsrc-driver?branch=develop) | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=usdot-fhwa-stol_CARMACohdaDsrcDriver&metric=alert_status)](https://sonarcloud.io/dashboard?id=usdot-fhwa-stol_CARMACohdaDsrcDriver) | [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastol/carma-cohda-dsrc-driver?label=carma-cohda-dsrc-driver)](https://hub.docker.com/repository/docker/usdotfhwastol/carma-cohda-dsrc-driver) | [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastolcandidate/carma-cohda-dsrc-driver?label=carma-cohda-dsrc-driver)](https://hub.docker.com/repository/docker/usdotfhwastolcandidate/carma-cohda-dsrc-driver) | [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastoldev/carma-cohda-dsrc-driver?label=carma-cohda-dsrc-driver)](https://hub.docker.com/repository/docker/usdotfhwastoldev/carma-cohda-dsrc-driver) +[![CI](https://github.com/usdot-fhwa-stol/carma-cohda-dsrc-driver/actions/workflows/ci.yml/badge.svg)](https://github.com/usdot-fhwa-stol/carma-cohda-dsrc-driver/actions/workflows/ci.yml) | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=usdot-fhwa-stol_CARMACohdaDsrcDriver&metric=alert_status)](https://sonarcloud.io/dashboard?id=usdot-fhwa-stol_CARMACohdaDsrcDriver) | [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastol/carma-cohda-dsrc-driver?label=carma-cohda-dsrc-driver)](https://hub.docker.com/repository/docker/usdotfhwastol/carma-cohda-dsrc-driver) | [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastolcandidate/carma-cohda-dsrc-driver?label=carma-cohda-dsrc-driver)](https://hub.docker.com/repository/docker/usdotfhwastolcandidate/carma-cohda-dsrc-driver) | [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastoldev/carma-cohda-dsrc-driver?label=carma-cohda-dsrc-driver)](https://hub.docker.com/repository/docker/usdotfhwastoldev/carma-cohda-dsrc-driver) diff --git a/docker/checkout.bash b/docker/checkout.bash index f519576..3d0cc24 100755 --- a/docker/checkout.bash +++ b/docker/checkout.bash @@ -39,6 +39,6 @@ if [[ "$BRANCH" = "develop" ]]; then git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/CARMAMsgs --branch $BRANCH git clone https://github.com/usdot-fhwa-stol/carma-utils.git ${dir}/src/CARMAUtils --branch $BRANCH else - git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/CARMAMsgs --branch carma-system-4.4.0 - git clone https://github.com/usdot-fhwa-stol/carma-utils.git ${dir}/src/CARMAUtils --branch carma-system-4.4.0 + git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/CARMAMsgs --branch carma-system-4.5.0 + git clone https://github.com/usdot-fhwa-stol/carma-utils.git ${dir}/src/CARMAUtils --branch carma-system-4.5.0 fi