-
Notifications
You must be signed in to change notification settings - Fork 664
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: M. Fatih Cırıt <[email protected]>
- Loading branch information
M. Fatih Cırıt
committed
Jun 25, 2024
1 parent
7dc71d5
commit f34a09e
Showing
8 changed files
with
577 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# colcon-build | ||
|
||
This action runs `colcon build`. | ||
|
||
## Usage | ||
|
||
```yaml | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: ros:galactic | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get modified packages | ||
id: get-modified-packages | ||
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1 | ||
|
||
- name: Build | ||
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }} | ||
uses: autowarefoundation/autoware-github-actions/colcon-build@v1 | ||
with: | ||
rosdistro: galactic | ||
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} | ||
build-depends-repos: build_depends.repos | ||
``` | ||
## Inputs | ||
| Name | Required | Description | | ||
| ------------------- | -------- | --------------------------------------------------- | | ||
| rosdistro | true | ROS distro. | | ||
| target-packages | true | The target packages to build. | | ||
| build-depends-repos | false | The `.repos` file that includes build dependencies. | | ||
| cmake-build-type | false | The value for `CMAKE_BUILD_TYPE`. | | ||
| token | false | The token for build dependencies. | | ||
|
||
## Outputs | ||
|
||
None. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: colcon-build-docker | ||
description: "" | ||
|
||
inputs: | ||
rosdistro: | ||
description: "" | ||
required: true | ||
target-packages: | ||
description: "" | ||
required: true | ||
build-depends-repos: | ||
description: "" | ||
required: false | ||
cmake-build-type: | ||
description: "" | ||
required: false | ||
default: Release | ||
token: | ||
description: "" | ||
required: false | ||
default: ${{ github.token }} | ||
include-eol-distros: | ||
description: "" | ||
required: false | ||
cache-build-artifacts: | ||
description: "Caches the build and install folders for clang-tidy to use" | ||
required: false | ||
default: "false" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Show target packages | ||
run: | | ||
echo "target packages: ${{ inputs.target-packages }}" | ||
shell: bash | ||
|
||
- name: Install pip for rosdep | ||
run: | | ||
sudo apt-get -yqq update | ||
sudo apt-get -yqq install python3-pip | ||
shell: bash | ||
|
||
- name: Set git config | ||
if: ${{ inputs.build-depends-repos != '' }} | ||
uses: autowarefoundation/autoware-github-actions/set-git-config@v1 | ||
with: | ||
token: ${{ inputs.token }} | ||
|
||
- name: Clone dependency packages | ||
if: ${{ inputs.build-depends-repos != '' }} | ||
run: | | ||
mkdir -p dependency_ws | ||
vcs import dependency_ws < ${{ inputs.build-depends-repos }} | ||
shell: bash | ||
|
||
- name: Run rosdep install | ||
run: | | ||
package_paths=$(colcon list -p --packages-above-and-dependencies ${{ inputs.target-packages }} --base-paths . dependency_ws) | ||
sudo apt-get -yqq update | ||
if [ "${{ inputs.include-eol-distros }}" = "true" ]; then | ||
rosdep update --include-eol-distros | ||
else | ||
rosdep update | ||
fi | ||
DEBIAN_FRONTEND=noninteractive rosdep install -yqq --from-paths ${package_paths} --ignore-src --rosdistro ${{ inputs.rosdistro }} | ||
shell: bash | ||
|
||
- name: Set up colcon-mixin | ||
run: | | ||
colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml || true | ||
colcon mixin update default | ||
shell: bash | ||
|
||
- name: Build | ||
run: | | ||
. /opt/ros/${{ inputs.rosdistro }}/setup.sh | ||
# Cannot use unshare inside a Docker container, so we just disable | ||
# DNS lookups instead. | ||
cat /etc/nsswitch.conf | ||
sed -e 's#hosts:\(.*\)dns\(.*\)#hosts:\1\2#g' -i.bak /etc/nsswitch.conf | ||
cat /etc/nsswitch.conf | ||
colcon build --event-handlers console_cohesion+ \ | ||
--packages-above-and-dependencies ${{ inputs.target-packages }} \ | ||
--cmake-args -DCMAKE_BUILD_TYPE=${{ inputs.cmake-build-type }} \ | ||
--mixin coverage-gcc coverage-pytest compile-commands | ||
mv /etc/nsswitch.conf.bak /etc/nsswitch.conf | ||
cat /etc/nsswitch.conf | ||
shell: bash | ||
|
||
- name: Cache build artifacts | ||
if: ${{ inputs.cache-build-artifacts == 'true' }} | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
./build | ||
./install | ||
key: build-${{ inputs.rosdistro }}-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cmake-build-type }}-${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# colcon-test | ||
|
||
This action runs `colcon test` with labels specified in a regex format. | ||
Note that you need to build target packages before running this action. | ||
|
||
## Usage | ||
|
||
```yaml | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: ros:galactic | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get modified packages | ||
id: get-modified-packages | ||
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1 | ||
|
||
- name: Build | ||
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }} | ||
uses: autowarefoundation/autoware-github-actions/colcon-build@v1 | ||
with: | ||
rosdistro: galactic | ||
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} | ||
build-depends-repos: build_depends.repos | ||
|
||
test: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
container: ros:galactic | ||
strategy: | ||
matrix: | ||
include: | ||
- test-label: gtest | ||
codecov-flags: gtest | ||
- test-label: launch_test | ||
codecov-flags: launch_test | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get modified packages | ||
id: get-modified-packages | ||
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1 | ||
|
||
- name: Test | ||
id: test | ||
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }} | ||
uses: autowarefoundation/autoware-github-actions/colcon-test@v1 | ||
with: | ||
rosdistro: galactic | ||
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} | ||
build-depends-repos: build_depends.repos | ||
label-regex: ${{ matrix.test-label }} | ||
|
||
- name: Upload coverage to Codecov | ||
if: ${{ steps.test.outputs.coverage-report-files != '' }} | ||
uses: codecov/codecov-action@v2 | ||
with: | ||
files: ${{ steps.test.outputs.coverage-report-files }} | ||
fail_ci_if_error: false | ||
verbose: true | ||
flags: ${{ matrix.codecov-flags }} | ||
``` | ||
## Inputs | ||
| Name | Required | Description | | ||
| ------------------- | -------- | --------------------------------------------------- | | ||
| rosdistro | true | ROS distro. | | ||
| target-packages | true | The target packages to test. | | ||
| build-depends-repos | false | The `.repos` file that includes build dependencies. | | ||
| label-regex | false | The regex pattern of test labels to be run. | | ||
| token | false | The token for build dependencies. | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
| --------------------- | -------------------------------- | | ||
| coverage-report-files | Generated coverage report files. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
name: colcon-test | ||
description: "" | ||
|
||
inputs: | ||
rosdistro: | ||
description: "" | ||
required: true | ||
target-packages: | ||
description: "" | ||
required: true | ||
build-depends-repos: | ||
description: "" | ||
required: false | ||
label-regex: | ||
description: "" | ||
required: false | ||
default: .* # Run all tests | ||
token: | ||
description: "" | ||
required: false | ||
default: ${{ github.token }} | ||
include-eol-distros: | ||
description: "" | ||
required: false | ||
outputs: | ||
coverage-report-files: | ||
description: "" | ||
value: ${{ steps.test.outputs.coverage-reports }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Show target packages | ||
run: | | ||
echo "target packages: ${{ inputs.target-packages }}" | ||
shell: bash | ||
|
||
- name: Set up colcon-mixin | ||
run: | | ||
colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml || true | ||
colcon mixin update default | ||
shell: bash | ||
|
||
- name: Install packages for coverage commands | ||
run: | | ||
sudo apt-get -yqq update | ||
sudo apt-get -yqq install \ | ||
lcov \ | ||
python3-pip \ | ||
python3-colcon-coveragepy-result \ | ||
python3-colcon-lcov-result \ | ||
python3-pytest-cov | ||
shell: bash | ||
|
||
- name: Set git config | ||
if: ${{ inputs.build-depends-repos != '' }} | ||
uses: autowarefoundation/autoware-github-actions/set-git-config@v1 | ||
with: | ||
token: ${{ inputs.token }} | ||
|
||
- name: Clone dependency packages | ||
if: ${{ inputs.build-depends-repos != '' }} | ||
run: | | ||
mkdir -p dependency_ws | ||
vcs import dependency_ws < ${{ inputs.build-depends-repos }} | ||
shell: bash | ||
|
||
- name: Run rosdep install | ||
run: | | ||
package_paths=$(colcon list -p --packages-above-and-dependencies ${{ inputs.target-packages }} --base-paths . dependency_ws) | ||
sudo apt-get -yqq update | ||
if [ "${{ inputs.include-eol-distros }}" = "true" ]; then | ||
rosdep update --include-eol-distros | ||
else | ||
rosdep update | ||
fi | ||
DEBIAN_FRONTEND=noninteractive rosdep install -yqq --from-paths ${package_paths} --ignore-src --rosdistro ${{ inputs.rosdistro }} | ||
shell: bash | ||
|
||
- name: Restore build files from cache | ||
id: restore-build-files | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
./build | ||
./install | ||
key: build-${{ inputs.rosdistro }}-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cmake-build-type }}-${{ github.sha }} | ||
|
||
- name: Test | ||
run: | | ||
set -e | ||
. /opt/ros/${{ inputs.rosdistro }}/setup.sh | ||
colcon lcov-result --zero-counters \ | ||
--verbose \ | ||
--packages-above ${{ inputs.target-packages }} | ||
colcon lcov-result --initial \ | ||
--verbose \ | ||
--packages-above ${{ inputs.target-packages }} | ||
colcon test --event-handlers console_cohesion+ \ | ||
--mixin coverage-pytest \ | ||
--packages-above ${{ inputs.target-packages }} \ | ||
--ctest-args -L "${{ inputs.label-regex }}" \ | ||
--executor sequential \ | ||
--return-code-on-test-failure | ||
colcon lcov-result \ | ||
--verbose \ | ||
--packages-above ${{ inputs.target-packages }} || true | ||
colcon coveragepy-result \ | ||
--verbose \ | ||
--packages-above ${{ inputs.target-packages }} || true | ||
shell: bash | ||
|
||
- name: Check if the lcov coverage file exists | ||
id: lcov-coverage-file-existence | ||
uses: autowarefoundation/autoware-github-actions/check-file-existence@v1 | ||
with: | ||
files: lcov/total_coverage.info | ||
|
||
- name: Check if the coveragepy coverage file exists | ||
id: coveragepy-coverage-file-existence | ||
uses: autowarefoundation/autoware-github-actions/check-file-existence@v1 | ||
with: | ||
files: coveragepy/.coverage | ||
|
||
- name: Generate output | ||
id: test | ||
run: | | ||
coverage_files=() | ||
if [[ "${{ steps.lcov-coverage-file-existence.outputs.exists }}" == "true" ]]; then | ||
coverage_files+=("lcov/total_coverage.info") | ||
fi | ||
if [[ "${{ steps.coveragepy-coverage-file-existence.outputs.exists}}" == "true" ]]; then | ||
coverage_files+=("coveragepy/.coverage") | ||
fi | ||
# Join coverage file names | ||
coverage_files_str="$(IFS=,; echo "${coverage_files[*]}")" | ||
echo "coverage-reports=$coverage_files_str" >> $GITHUB_OUTPUT | ||
shell: bash |
Oops, something went wrong.