-
Notifications
You must be signed in to change notification settings - Fork 124
129 lines (111 loc) · 5.61 KB
/
Ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# GitHub Actions triggers based on the PR's and each commits on develop and master
name: "CI: Run tests"
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [develop, master]
jobs:
determine_docker_org_and_tag:
runs-on: ubuntu-latest
steps:
- name: Determine Docker organization and tag
id: docker-org-and-tag
uses: usdot-fhwa-stol/actions/docker-org-and-tag@main
outputs:
docker_org: ${{ steps.docker-org-and-tag.outputs.docker_organization }}
docker_tag: ${{ steps.docker-org-and-tag.outputs.docker_image_tag }}
build:
needs: determine_docker_org_and_tag
defaults:
run:
shell: bash
working-directory: "/opt/carma/"
# Specify the runner environment
runs-on: ubuntu-latest-16-cores
# Set up a Docker container for the job
container:
image: ${{ needs.determine_docker_org_and_tag.outputs.docker_org }}/autoware.ai:${{ needs.determine_docker_org_and_tag.outputs.docker_tag }}
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: Determine base branch
id: determine-base-branch
run: |
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
echo git_branch="$GITHUB_BASE_REF" >> $GITHUB_OUTPUT
else
echo git_branch="$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
fi
- name: Checkout ${{ github.event.repository.name }}
# Check out the repository code
uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
path: src/${{ github.event.repository.name }}
- name: Move source code
# Move the source code to the desired location
run: mv $GITHUB_WORKSPACE/src /opt/carma/
- name: Checkout dependencies
# Checkout project dependencies
run: |
source "$INIT_ENV"
./src/${{ github.event.repository.name }}/docker/checkout.bash -r /opt/carma/ -b ${{ steps.determine-base-branch.outputs.git_branch }}
- name: Install external dependencies
# Install the multiple object tracking deps
run: sudo bash /opt/carma/src/multiple_object_tracking/scripts/install_dependencies.sh
- name: Build ROS1
# Build ROS1 packages
# The skipped ROS 1 packages here should match the ROS 1 packages that are skipped during the build in docker/install.sh
run: |
source "$INIT_ENV"
PACKAGES=$(find . -maxdepth 2 -type f -name package.xml | sed 's/\.\///' | cut -d/ -f1) # maxdepth 2 Limits the search of package.xml to current directory and one level of subdirectories beneath it. find will not search beyond two levels deep from the starting point. Without this option, find would search the starting directory and all subdirectories recursively.
sed -i 's/colcon build /colcon build --packages-skip novatel_oem7_msgs tracetools tracetools_test /' /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 ROS1 C++ Tests
# Run ROS1 C++ tests
# The skipped ROS 1 packages here should match the ROS 1 packages that are skipped during the build in docker/install.sh"
# These tests has been temporarily disabled to support Continuous Improvement (CI) processes.
# Related GitHub Issue: <https://github.com/usdot-fhwa-stol/carma-platform/issues/2335>
# some ROS2 packages unit tests are triggered during ROS1 tests, so they are temporarily being skipped.
run: |
source "$INIT_ENV"
sed -i 's/colcon test /colcon test --packages-skip novatel_oem7_msgs tracetools tracetools_test carma_launch_testing carma_message_utilities ros2bag ros2trace tracetools_launch tracetools_read tracetools_trace rosbag2 carma_utils /' /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: Backup ROS1 compile_commands.json
# Backup the ROS1 compile_commands.json file for sonarcloud
run: |
mv /opt/carma/build/compile_commands.json /opt/carma/compile_commands.ros1.json
- name: Cleanup before ROS 2 build
# Clear the build and install folders before building ROS 2
run: |
rm -rf /opt/carma/install
rm -rf /opt/carma/build
- name: Build ROS2
# Build ROS2 packages
run: |
source "$INIT_ENV"
source "$ROS_2_ENV"
source /opt/autoware.ai/ros/install_ros2/setup.bash
make_with_coverage.bash -m -e /opt/carma/ -o ./coverage_reports/gcov
- name: Run ROS2 C++ Tests
# Run ROS2 C++ tests
run: |
source "$INIT_ENV"
source "$ROS_2_ENV"
source /opt/autoware.ai/ros/install_ros2/setup.bash
make_with_coverage.bash -t -e /opt/carma/ -o ./coverage_reports/gcov
- name: Combine ROS1 and ROS2 compile_commands.json files
# Combine the ROS1 and ROS2 compile_commands.json files for sonarscan
run: |
mv /opt/carma/build/compile_commands.json /opt/carma/compile_commands.ros2.json
jq -s add /opt/carma/compile_commands.ros1.json /opt/carma/compile_commands.ros2.json > /opt/carma/build/compile_commands.json
- name: Run SonarScanner
# Run SonarScanner for code analysis
uses: usdot-fhwa-stol/actions/sonar-scanner@main
with:
sonar-token: ${{ secrets.SONAR_TOKEN }}
working-dir: "/opt/carma/src/${{ github.event.repository.name }}"