Skip to content

Commit 52a2670

Browse files
committed
ci: introduce build-test-tidy-pr a
Signed-off-by: M. Fatih Cırıt <mfc@autoware.org>
1 parent b107ac7 commit 52a2670

File tree

4 files changed

+257
-250
lines changed

4 files changed

+257
-250
lines changed

.github/actions/build-and-test-differential/action.yaml

-111
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
name: build-and-test-differential
22

33
on:
4-
pull_request:
5-
types:
6-
- opened
7-
- synchronize
8-
- reopened
9-
- labeled
4+
workflow_call:
5+
inputs:
6+
container:
7+
required: true
8+
type: string
9+
runner:
10+
default: ubuntu-24.04
11+
required: false
12+
type: string
13+
rosdistro:
14+
default: humble
15+
required: false
16+
type: string
17+
container-suffix:
18+
required: false
19+
default: ""
20+
type: string
21+
secrets:
22+
codecov-token:
23+
required: true
1024

1125
concurrency:
1226
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
@@ -17,41 +31,9 @@ env:
1731
CXX: /usr/lib/ccache/g++
1832

1933
jobs:
20-
make-sure-label-is-present:
21-
uses: autowarefoundation/autoware-github-actions/.github/workflows/make-sure-label-is-present.yaml@v1
22-
with:
23-
label: tag:run-build-and-test-differential
24-
25-
make-sure-require-cuda-label-is-present:
26-
uses: autowarefoundation/autoware-github-actions/.github/workflows/make-sure-label-is-present.yaml@v1
27-
with:
28-
label: tag:require-cuda-build-and-test
29-
30-
prepare-build-and-test-differential:
31-
runs-on: ubuntu-latest
32-
needs: [make-sure-label-is-present, make-sure-require-cuda-label-is-present]
33-
outputs:
34-
cuda_build: ${{ steps.check-if-cuda-build-is-required.outputs.cuda_build }}
35-
steps:
36-
- name: Check if cuda-build is required
37-
id: check-if-cuda-build-is-required
38-
run: |
39-
if ${{ needs.make-sure-require-cuda-label-is-present.outputs.result == 'true' }}; then
40-
echo "cuda-build is required"
41-
echo "cuda_build=true" >> $GITHUB_OUTPUT
42-
else
43-
echo "cuda-build is not required"
44-
echo "cuda_build=false" >> $GITHUB_OUTPUT
45-
fi
46-
shell: bash
47-
- name: Fail if the tag:run-build-and-test-differential is missing
48-
if: ${{ needs.make-sure-label-is-present.outputs.result != 'true' }}
49-
run: exit 1
50-
5134
build-and-test-differential:
52-
runs-on: ubuntu-latest
53-
container: ghcr.io/autowarefoundation/autoware:universe-devel
54-
needs: prepare-build-and-test-differential
35+
runs-on: ${{ inputs.runner }}
36+
container: ${{ inputs.container }}
5537
steps:
5638
- name: Set PR fetch depth
5739
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
@@ -63,61 +45,13 @@ jobs:
6345
ref: ${{ github.event.pull_request.head.sha }}
6446
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
6547

66-
- name: Run build-and-test-differential action
67-
uses: ./.github/actions/build-and-test-differential
68-
with:
69-
rosdistro: humble
70-
container: ghcr.io/autowarefoundation/autoware:universe-devel
71-
container-suffix: ""
72-
runner: ubuntu-latest
73-
build-depends-repos: build_depends.repos
74-
build-pre-command: ""
75-
codecov-token: ${{ secrets.CODECOV_TOKEN }}
76-
77-
build-and-test-differential-cuda:
78-
runs-on: codebuild-autoware-us-east-1-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-large
79-
container: ghcr.io/autowarefoundation/autoware:universe-devel-cuda
80-
needs: prepare-build-and-test-differential
81-
if: ${{ needs.prepare-build-and-test-differential.outputs.cuda_build == 'true' }}
82-
steps:
83-
- name: Set PR fetch depth
84-
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
85-
shell: bash
86-
87-
- name: Checkout PR branch and all PR commits
88-
uses: actions/checkout@v4
89-
with:
90-
ref: ${{ github.event.pull_request.head.sha }}
91-
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
92-
93-
- name: Run build-and-test-differential action
94-
uses: ./.github/actions/build-and-test-differential
95-
with:
96-
rosdistro: humble
97-
container: ghcr.io/autowarefoundation/autoware:universe-devel
98-
container-suffix: -cuda
99-
runner: codebuild-autoware-us-east-1-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-large
100-
build-depends-repos: build_depends.repos
101-
build-pre-command: taskset --cpu-list 0-5
102-
codecov-token: ${{ secrets.CODECOV_TOKEN }}
103-
104-
clang-tidy-differential:
105-
needs: [build-and-test-differential, prepare-build-and-test-differential]
106-
if: ${{ needs.prepare-build-and-test-differential.outputs.cuda_build == 'false' }}
107-
runs-on: ubuntu-latest
108-
container: ghcr.io/autowarefoundation/autoware:universe-devel
109-
steps:
110-
- name: Set PR fetch depth
111-
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
112-
113-
- name: Checkout PR branch and all PR commits
114-
uses: actions/checkout@v4
115-
with:
116-
ref: ${{ github.event.pull_request.head.sha }}
117-
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
118-
11948
- name: Show disk space before the tasks
12049
run: df -h
50+
shell: bash
51+
52+
- name: Show machine specs
53+
run: lscpu && free -h
54+
shell: bash
12155

12256
- name: Remove exec_depend
12357
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1
@@ -126,66 +60,69 @@ jobs:
12660
id: get-modified-packages
12761
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1
12862

129-
- name: Get changed files (existing files only)
130-
id: get-changed-files
63+
- name: Create ccache directory
13164
run: |
132-
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
65+
mkdir -p ${CCACHE_DIR}
66+
du -sh ${CCACHE_DIR} && ccache -s
13367
shell: bash
13468

135-
- name: Run clang-tidy
136-
if: ${{ steps.get-changed-files.outputs.changed-files != '' }}
137-
uses: autowarefoundation/autoware-github-actions/clang-tidy@v1
69+
- name: Attempt to restore ccache
70+
uses: actions/cache/restore@v4
13871
with:
139-
rosdistro: humble
140-
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }}
141-
clang-tidy-config-url: https://raw.githubusercontent.com/autowarefoundation/autoware/main/.clang-tidy-ci
142-
clang-tidy-ignore-path: .clang-tidy-ignore
143-
build-depends-repos: build_depends.repos
144-
cache-key-element: cuda
72+
path: |
73+
/root/.ccache
74+
key: ccache-main-${{ runner.arch }}-${{ inputs.rosdistro }}-${{ github.event.pull_request.base.sha }}
75+
restore-keys: |
76+
ccache-main-${{ runner.arch }}-${{ inputs.rosdistro }}-
14577
146-
- name: Show disk space after the tasks
147-
run: df -h
78+
- name: Show ccache stats before build and reset stats
79+
run: |
80+
du -sh ${CCACHE_DIR} && ccache -s
81+
ccache --zero-stats
82+
shell: bash
14883

149-
clang-tidy-differential-cuda:
150-
needs: build-and-test-differential-cuda
151-
runs-on: codebuild-autoware-us-east-1-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-large
152-
container: ghcr.io/autowarefoundation/autoware:universe-devel-cuda
153-
steps:
154-
- name: Set PR fetch depth
155-
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
84+
- name: Export CUDA state as a variable for adding to cache key
85+
run: |
86+
build_type_cuda_state=nocuda
87+
if [[ "${{ inputs.container-suffix }}" == "-cuda" ]]; then
88+
build_type_cuda_state=cuda
89+
fi
90+
echo "BUILD_TYPE_CUDA_STATE=$build_type_cuda_state" >> "${GITHUB_ENV}"
91+
echo "::notice::BUILD_TYPE_CUDA_STATE=$build_type_cuda_state"
92+
shell: bash
15693

157-
- name: Checkout PR branch and all PR commits
158-
uses: actions/checkout@v4
94+
- name: Build
95+
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
96+
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
15997
with:
160-
ref: ${{ github.event.pull_request.head.sha }}
161-
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
162-
163-
- name: Show disk space before the tasks
164-
run: df -h
165-
166-
- name: Remove exec_depend
167-
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1
168-
169-
- name: Get modified packages
170-
id: get-modified-packages
171-
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1
98+
rosdistro: ${{ inputs.rosdistro }}
99+
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }}
100+
build-depends-repos: build_depends.repos
101+
cache-key-element: ${{ env.BUILD_TYPE_CUDA_STATE }}
172102

173-
- name: Get changed files (existing files only)
174-
id: get-changed-files
175-
run: |
176-
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
103+
- name: Show ccache stats after build
104+
run: du -sh ${CCACHE_DIR} && ccache -s
177105
shell: bash
178106

179-
- name: Run clang-tidy
180-
if: ${{ steps.get-changed-files.outputs.changed-files != '' }}
181-
uses: autowarefoundation/autoware-github-actions/clang-tidy@v1
107+
- name: Test
108+
id: test
109+
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
110+
uses: autowarefoundation/autoware-github-actions/colcon-test@v1
182111
with:
183-
rosdistro: humble
112+
rosdistro: ${{ inputs.rosdistro }}
184113
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }}
185-
clang-tidy-config-url: https://raw.githubusercontent.com/autowarefoundation/autoware/main/.clang-tidy-ci
186-
clang-tidy-ignore-path: .clang-tidy-ignore
187114
build-depends-repos: build_depends.repos
188-
cache-key-element: cuda
115+
116+
- name: Upload coverage to CodeCov
117+
if: ${{ steps.test.outputs.coverage-report-files != '' }}
118+
uses: codecov/codecov-action@v4
119+
with:
120+
files: ${{ steps.test.outputs.coverage-report-files }}
121+
fail_ci_if_error: false
122+
verbose: true
123+
flags: differential
124+
token: ${{ inputs.codecov-token }}
189125

190126
- name: Show disk space after the tasks
191127
run: df -h
128+
shell: bash

0 commit comments

Comments
 (0)