Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add colcon-build and colcon-test actions #49

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
3f04028
feat: add colcon-labeled-test workflow
KeisukeShima Jan 31, 2022
3698bd6
ci(pre-commit): autofix
pre-commit-ci[bot] Feb 4, 2022
b2cbdc7
add colcon-build workflow
KeisukeShima Feb 4, 2022
8497527
change colcon-test workflow
KeisukeShima Feb 4, 2022
9b5c275
ci(pre-commit): autofix
pre-commit-ci[bot] Feb 4, 2022
039edb4
add test for colcon-test
KeisukeShima Feb 4, 2022
adadc2a
add deprecated message
KeisukeShima Feb 4, 2022
3360d04
fix
KeisukeShima Feb 4, 2022
483bf5b
fix
KeisukeShima Feb 4, 2022
5c811ea
fix test
KeisukeShima Feb 4, 2022
f224afc
modify message
KeisukeShima Feb 4, 2022
674d5c1
Update colcon-build/README.md
KeisukeShima Feb 7, 2022
792f979
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
3ae9058
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
aa6ce16
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
b766323
Update colcon-build/README.md
KeisukeShima Feb 7, 2022
3758a35
ci(pre-commit): autofix
pre-commit-ci[bot] Feb 7, 2022
ae4411e
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
9be2776
add git-config action
KeisukeShima Feb 7, 2022
0f5d1a3
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
61b1daa
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
8afb09c
ci(pre-commit): autofix
pre-commit-ci[bot] Feb 7, 2022
35d94f4
use check-file-existence action
KeisukeShima Feb 7, 2022
aa07142
Update colcon-build/README.md
KeisukeShima Feb 7, 2022
fabc1c8
ci(pre-commit): autofix
pre-commit-ci[bot] Feb 7, 2022
8fc45ad
ci: remove automatic-rebase.yaml (#50)
kenji-miyake Feb 4, 2022
6a0d39a
fix(sync-files): fix bugs (#51)
kenji-miyake Feb 6, 2022
b7661d1
feat(sync-files): add body (#52)
kenji-miyake Feb 6, 2022
f59601d
ci: add actions-tagger.yaml (#53)
kenji-miyake Feb 6, 2022
fc5af4e
style: fix styles of descriptions
Feb 6, 2022
83f3c1f
feat: add generate-changelog action (#54)
kenji-miyake Feb 6, 2022
ead1927
feat(sync-branches): add changelog to body (#55)
kenji-miyake Feb 6, 2022
63a9626
fix(generate-changelog): remove CHANGELOG.md (#56)
kenji-miyake Feb 6, 2022
bc130b0
ci: add GitHub release workflow (#38)
kenji-miyake Feb 7, 2022
a3529d2
Update colcon-build/README.md
KeisukeShima Feb 7, 2022
143cb3d
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
b1de609
Update colcon-build/action.yaml
KeisukeShima Feb 7, 2022
ec086a1
Update colcon-build/action.yaml
KeisukeShima Feb 7, 2022
15f26a0
Update colcon-test/action.yaml
KeisukeShima Feb 7, 2022
f719f48
Update colcon-test/action.yaml
KeisukeShima Feb 7, 2022
0a6229c
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
91fd4b9
ci(pre-commit): autofix
pre-commit-ci[bot] Feb 7, 2022
9fe89e8
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
c5db608
fix directory name of the result
KeisukeShima Feb 7, 2022
c2a55bf
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
d62d628
Update colcon-test/README.md
KeisukeShima Feb 7, 2022
ee28477
modify argument name
KeisukeShima Feb 7, 2022
000879c
change if statement
KeisukeShima Feb 7, 2022
ff50b8a
change output name
KeisukeShima Feb 7, 2022
fdb25cf
ci(pre-commit): autofix
pre-commit-ci[bot] Feb 7, 2022
3f55ed7
Merge branch 'tier4/proposal' into feature/coverage-flags
KeisukeShima Feb 7, 2022
0529210
fix for pre-commit
KeisukeShima Feb 7, 2022
0b32214
Merge branch 'feature/coverage-flags' of github.com:KeisukeShima/auto…
KeisukeShima Feb 7, 2022
9db61ff
Merge branch 'tier4/proposal' into feature/coverage-flags
KeisukeShima Feb 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/test-composite-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,33 @@ jobs:
- name: Check result
run: |
[[ "${{ steps.check-file-existence4.outputs.exists }}" == "true" ]]

test-colcon-build-and-colcon-test:
runs-on: ubuntu-latest
container: ros:${{ matrix.rosdistro }}
strategy:
fail-fast: false
matrix:
rosdistro:
- galactic
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Create a package with no source files
run: |
. /opt/ros/${{ matrix.rosdistro }}/setup.sh
ros2 pkg create --build-type ament_cmake empty_target_cmake
ros2 pkg create --build-type ament_python empty_target_python

- name: Run colcon-build
uses: ./colcon-build
with:
rosdistro: ${{ matrix.rosdistro }}
target-packages: empty_target_cmake empty_target_python

- name: Run colcon-test
uses: ./colcon-test
with:
rosdistro: ${{ matrix.rosdistro }}
target-packages: empty_target_cmake empty_target_python
2 changes: 1 addition & 1 deletion colcon-build-and-test/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# colcon-build-and-test
# DEPRECATED: colcon-build-and-test

This action runs `colcon build` and `colcon test`.

Expand Down
4 changes: 4 additions & 0 deletions colcon-build-and-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ inputs:
runs:
using: composite
steps:
- name: Show deprecated warning
run: echo "::warning title=DEPRECATED::colcon-build-and-test action will no longer be available in future releases. Please consider using colcon-build and colcon-test workflows instead."
shell: bash

- name: Show target packages
run: |
echo "target packages: ${{ inputs.target-packages }}"
Expand Down
42 changes: 42 additions & 0 deletions colcon-build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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@v2
with:
fetch-depth: 0

- name: Get modified packages
id: get-modified-packages
uses: autowarefoundation/autoware-github-actions/get-modified-packages@tier4/proposal

- name: Build
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
uses: autowarefoundation/autoware-github-actions/colcon-build@tier4/proposal
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. |
| token | false | The token for build dependencies. |

## Outputs

None.
74 changes: 74 additions & 0 deletions colcon-build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: colcon-build
description: ""

inputs:
rosdistro:
description: ""
required: true
target-packages:
description: ""
required: true
build-depends-repos:
description: ""
required: false
token:
description: ""
required: false
default: ${{ github.token }}

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@tier4/proposal
with:
token: ${{ inputs.token }}

- name: Clone dependency packages
if: ${{ inputs.build-depends-repos != '' }}
run: |
mkdir dependency_ws
vcs import dependency_ws < ${{ inputs.build-depends-repos }}
shell: bash

- name: Run rosdep install
run: |
sudo apt-get -yqq update
rosdep update
DEBIAN_FRONTEND=noninteractive rosdep install -yqq --from-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
colcon build --event-handlers console_cohesion+ \
--packages-above-and-dependencies ${{ inputs.target-packages }} \
--cmake-args -DCMAKE_BUILD_TYPE=Release \
--mixin coverage-gcc coverage-pytest compile-commands
shell: bash

- name: Cache build artifacts
uses: actions/cache@v2
with:
path: |
./build
./install
key: build-${{ github.sha }}
86 changes: 86 additions & 0 deletions colcon-test/README.md
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@v2
with:
fetch-depth: 0

- name: Get modified packages
id: get-modified-packages
uses: autowarefoundation/autoware-github-actions/get-modified-packages@tier4/proposal

- name: Build
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
uses: autowarefoundation/autoware-github-actions/colcon-build@tier4/proposal
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@v2
with:
fetch-depth: 0

- name: Get modified packages
id: get-modified-packages
uses: autowarefoundation/autoware-github-actions/get-modified-packages@tier4/proposal

- name: Test
id: test
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
uses: autowarefoundation/autoware-github-actions/colcon-test@tier4/proposal
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. |
134 changes: 134 additions & 0 deletions colcon-test/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
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 }}
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
pip3 install colcon-lcov-result colcon-coveragepy-result
shell: bash

- name: Set git config
if: ${{ inputs.build-depends-repos != '' }}
uses: autowarefoundation/autoware-github-actions/set-git-config@tier4/proposal
with:
token: ${{ inputs.token }}

- name: Clone dependency packages
if: ${{ inputs.build-depends-repos != '' }}
run: |
mkdir dependency_ws
vcs import dependency_ws < ${{ inputs.build-depends-repos }}
shell: bash

- name: Run rosdep install
run: |
sudo apt-get -yqq update
rosdep update
DEBIAN_FRONTEND=noninteractive rosdep install -yqq --from-paths . --ignore-src --rosdistro ${{ inputs.rosdistro }}
shell: bash

- name: Restore build files from cache
id: restore-build-files
uses: actions/cache@v2
with:
path: |
./build
./install
key: build-${{ 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 }}" \
--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 lcov coverage file exists
id: lcov-coverage-file-existence
uses: autowarefoundation/autoware-github-actions/check-file-existence@tier4/proposal
with:
files: lcov/total_coverage.info
condition: and

- name: Check coveragepy coverage file exists
id: coveragepy-coverage-file-existence
uses: autowarefoundation/autoware-github-actions/check-file-existence@tier4/proposal
with:
files: coveragepy/.coverage
condition: and

- 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 ::set-output name=coverage-reports::$coverage_files_str
shell: bash