Skip to content

Build and Test

Build and Test #120

Workflow file for this run

name: Build and Test
on:
schedule:
- cron: "0 0 * * 1"
# push:
# branches:
# - master
jobs:
build-and-test:
runs-on: ubuntu-22.04
env:
SONAR_SCANNER_VERSION: 4.7.0.2747
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: /home/runner/target_ws/
ISOLATION: "shell"
steps:
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: ""
# required-ros-distributions: rolling
- name: creating_folder
run : |
mkdir -p /home/runner/target_ws/src/ || true
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Download and set up sonar-scanner
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
run: |
curl -sSLo /home/runner/target_ws/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o /home/runner/target_ws/sonar-scanner.zip -d /home/runner/target_ws/
echo "/home/runner/target_ws/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
- name: Download and set up build-wrapper
env:
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
run: |
curl -sSLo /home/runner/target_ws/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o /home/runner/target_ws/build-wrapper-linux-x86.zip -d /home/runner/target_ws/
echo "/home/runner/target_ws/build-wrapper-linux-x86" >> $GITHUB_PATH
- name: Checking out
uses: actions/[email protected]
with:
submodules: recursive
- name: Run build-wrapper
run: |
cd /home/runner/target_ws/
wget https://raw.githubusercontent.com/ros2/ros2/rolling/ros2.repos
vcs import src < ros2.repos
vcs import src < /home/runner/work/ros2_sonarcloud/ros2_sonarcloud/extra_repo.repos
rosdep update && rosdep install -y --rosdistro "rolling" --from-paths src --ignore-src || true
./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir . colcon build --executor parallel --continue-on-error || true
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
cd /home/runner/target_ws/
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
-Dsonar.projectKey=muttistefano_ros2_sonarcloud \
-Dsonar.organization=muttistefano \
-Dsonar.cfamily.threads=2 \
-Dsonar.projectBaseDir=/home/runner/target_ws/ \
-Dsonar.sources=src
cd /home/runner/target_ws/src/
# - name: cccc action step
# uses: sarnold/cccc-action@main
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# - name: upload metrics report
# uses: actions/upload-artifact@v2
# with:
# name: metrics
# path: ./metrics
# - name: cppcheck
# uses: deep5050/cppcheck-action@main
# with:
# github_token: ${{ secrets.GITHUB_TOKEN}}
- name: execute py script
run: |
cd /home/runner/work/ros2_sonarcloud/ros2_sonarcloud/
ls -al
python3 run.py
ls -al
- name: Commit files
run: |
pwd
ls -al
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add . -A
git commit -m "push README.md"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}