Skip to content

Commit

Permalink
ci: update build-and-test-differential workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Ryohsuke Mitsudome <[email protected]>
  • Loading branch information
mitsudome-r committed Nov 6, 2024
1 parent 48aaf07 commit d2be15e
Showing 1 changed file with 75 additions and 48 deletions.
123 changes: 75 additions & 48 deletions .github/workflows/build-and-test-differential.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,93 @@ name: build-and-test-differential

on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

env:
CC: /usr/lib/ccache/gcc
CXX: /usr/lib/ccache/g++

jobs:
make-sure-label-is-present:
uses: autowarefoundation/autoware-github-actions/.github/workflows/make-sure-label-is-present.yaml@v1
with:
label: tag:run-build-and-test-differential

make-sure-require-cuda-label-is-present:
uses: autowarefoundation/autoware-github-actions/.github/workflows/make-sure-label-is-present.yaml@v1
with:
label: tag:require-cuda-build-and-test

build-and-test-differential:
runs-on: ubuntu-latest
container: ${{ matrix.container }}
needs: [make-sure-label-is-present, make-sure-require-cuda-label-is-present]
if: ${{ needs.make-sure-label-is-present.outputs.result == 'true' }}
runs-on: ${{ matrix.runner }}
container: ${{ matrix.container }}${{ matrix.container-suffix }}
strategy:
fail-fast: false
matrix:
rosdistro:
- humble
container-suffix:
- ""
- -cuda
include:
- rosdistro: humble
container: ros:humble
container: ghcr.io/autowarefoundation/autoware:latest-autoware-universe
build-depends-repos: build_depends.repos
- container-suffix: -cuda
runner: codebuild-autoware-us-east-1-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-large
build-pre-command: taskset --cpu-list 0-6
- container-suffix: ""
runner: ubuntu-latest
build-pre-command: ""
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Remove exec_depend
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1

- name: Get modified packages
id: get-modified-packages
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1
- name: Set PR fetch depth
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
shell: bash

- name: Build
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
- name: Checkout PR branch and all PR commits
uses: actions/checkout@v4
with:
rosdistro: ${{ matrix.rosdistro }}
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }}
build-depends-repos: ${{ matrix.build-depends-repos }}
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}

- name: Test
id: test
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
uses: autowarefoundation/autoware-github-actions/colcon-test@v1
- name: Run build-and-test-differential action
if: ${{ !(matrix.container-suffix == '-cuda') || needs.make-sure-require-cuda-label-is-present.outputs.result == 'true' }}
uses: ./.github/actions/build-and-test-differential
with:
rosdistro: ${{ matrix.rosdistro }}
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }}
container: ${{ matrix.container }}
container-suffix: ${{ matrix.container-suffix }}
runner: ${{ matrix.runner }}
build-depends-repos: ${{ matrix.build-depends-repos }}

- name: Upload coverage to CodeCov
if: ${{ steps.test.outputs.coverage-report-files != '' }}
uses: codecov/codecov-action@v4
with:
files: ${{ steps.test.outputs.coverage-report-files }}
fail_ci_if_error: false
verbose: true
flags: differential
build-pre-command: ${{ matrix.build-pre-command }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}

clang-tidy-differential:
runs-on: ubuntu-latest
container: ros:humble
needs: build-and-test-differential
runs-on: ubuntu-22.04
container: ghcr.io/autowarefoundation/autoware:latest-autoware-universe-cuda
steps:
- name: Check out repository
- name: Set PR fetch depth
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"

- name: Checkout PR branch and all PR commits
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}

- name: Show disk space before the tasks
run: df -h

- name: Remove exec_depend
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1
Expand All @@ -72,20 +97,22 @@ jobs:
id: get-modified-packages
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1

- name: Get modified files
id: get-modified-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.cpp
**/*.hpp
- name: Get changed files (existing files only)
id: get-changed-files
run: |
echo "changed-files=$(git diff --name-only "origin/${{ github.base_ref }}"...HEAD | grep -E '\.(cpp|hpp)$' | while read -r file; do [ -e "$file" ] && echo -n "$file "; done)" >> $GITHUB_OUTPUT
shell: bash

- name: Run clang-tidy
if: ${{ steps.get-modified-files.outputs.all_changed_files != '' }}
if: ${{ steps.get-changed-files.outputs.changed-files != '' }}
uses: autowarefoundation/autoware-github-actions/clang-tidy@v1
with:
rosdistro: humble
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }}
target-files: ${{ steps.get-modified-files.outputs.all_changed_files }}
clang-tidy-config-url: https://raw.githubusercontent.com/autowarefoundation/autoware/main/.clang-tidy
target-files: ${{ steps.get-changed-files.outputs.changed-files }}
clang-tidy-config-url: https://raw.githubusercontent.com/autowarefoundation/autoware/main/.clang-tidy-ci
build-depends-repos: build_depends.repos
cache-key-element: cuda

- name: Show disk space after the tasks
run: df -h

0 comments on commit d2be15e

Please sign in to comment.