1
1
name : build-and-test-differential
2
2
3
3
on :
4
- pull_request :
5
- types :
6
- - opened
7
- - synchronize
8
- - reopened
9
- - labeled
10
-
11
- concurrency :
12
- group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
13
- cancel-in-progress : true
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
14
24
15
25
env :
16
26
CC : /usr/lib/ccache/gcc
17
27
CXX : /usr/lib/ccache/g++
18
28
19
29
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
-
51
30
build-and-test-differential :
52
- runs-on : ubuntu-latest
53
- container : ghcr.io/autowarefoundation/autoware:universe-devel
54
- needs : prepare-build-and-test-differential
31
+ runs-on : ${{ inputs.runner }}
32
+ container : ${{ inputs.container }}${{ inputs.container-suffix }}
55
33
steps :
56
34
- name : Set PR fetch depth
57
35
run : echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
@@ -63,61 +41,13 @@ jobs:
63
41
ref : ${{ github.event.pull_request.head.sha }}
64
42
fetch-depth : ${{ env.PR_FETCH_DEPTH }}
65
43
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
-
119
44
- name : Show disk space before the tasks
120
45
run : df -h
46
+ shell : bash
47
+
48
+ - name : Show machine specs
49
+ run : lscpu && free -h
50
+ shell : bash
121
51
122
52
- name : Remove exec_depend
123
53
uses : autowarefoundation/autoware-github-actions/remove-exec-depend@v1
@@ -126,66 +56,69 @@ jobs:
126
56
id : get-modified-packages
127
57
uses : autowarefoundation/autoware-github-actions/get-modified-packages@v1
128
58
129
- - name : Get changed files (existing files only)
130
- id : get-changed-files
59
+ - name : Create ccache directory
131
60
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
61
+ mkdir -p ${CCACHE_DIR}
62
+ du -sh ${CCACHE_DIR} && ccache -s
133
63
shell : bash
134
64
135
- - name : Run clang-tidy
136
- if : ${{ steps.get-changed-files.outputs.changed-files != '' }}
137
- uses : autowarefoundation/autoware-github-actions/clang-tidy@v1
65
+ - name : Attempt to restore ccache
66
+ uses : actions/cache/restore@v4
138
67
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
68
+ path : |
69
+ /root/.ccache
70
+ key : ccache-main-${{ runner.arch }}-${{ inputs.rosdistro }}-${{ github.event.pull_request.base.sha }}
71
+ restore-keys : |
72
+ ccache-main-${{ runner.arch }}-${{ inputs.rosdistro }}-
145
73
146
- - name : Show disk space after the tasks
147
- run : df -h
74
+ - name : Show ccache stats before build and reset stats
75
+ run : |
76
+ du -sh ${CCACHE_DIR} && ccache -s
77
+ ccache --zero-stats
78
+ shell : bash
148
79
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}"
80
+ - name : Export CUDA state as a variable for adding to cache key
81
+ run : |
82
+ build_type_cuda_state=nocuda
83
+ if [[ "${{ inputs.container-suffix }}" == "-cuda" ]]; then
84
+ build_type_cuda_state=cuda
85
+ fi
86
+ echo "BUILD_TYPE_CUDA_STATE=$build_type_cuda_state" >> "${GITHUB_ENV}"
87
+ echo "::notice::BUILD_TYPE_CUDA_STATE=$build_type_cuda_state"
88
+ shell : bash
156
89
157
- - name : Checkout PR branch and all PR commits
158
- uses : actions/checkout@v4
90
+ - name : Build
91
+ if : ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
92
+ uses : autowarefoundation/autoware-github-actions/colcon-build@v1
159
93
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
94
+ rosdistro : ${{ inputs.rosdistro }}
95
+ target-packages : ${{ steps.get-modified-packages.outputs.modified-packages }}
96
+ build-depends-repos : build_depends.repos
97
+ cache-key-element : ${{ env.BUILD_TYPE_CUDA_STATE }}
172
98
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
99
+ - name : Show ccache stats after build
100
+ run : du -sh ${CCACHE_DIR} && ccache -s
177
101
shell : bash
178
102
179
- - name : Run clang-tidy
180
- if : ${{ steps.get-changed-files.outputs.changed-files != '' }}
181
- uses : autowarefoundation/autoware-github-actions/clang-tidy@v1
103
+ - name : Test
104
+ id : test
105
+ if : ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
106
+ uses : autowarefoundation/autoware-github-actions/colcon-test@v1
182
107
with :
183
- rosdistro : humble
108
+ rosdistro : ${{ inputs.rosdistro }}
184
109
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
187
110
build-depends-repos : build_depends.repos
188
- cache-key-element : cuda
111
+
112
+ - name : Upload coverage to CodeCov
113
+ if : ${{ steps.test.outputs.coverage-report-files != '' }}
114
+ uses : codecov/codecov-action@v4
115
+ with :
116
+ files : ${{ steps.test.outputs.coverage-report-files }}
117
+ fail_ci_if_error : false
118
+ verbose : true
119
+ flags : differential${{ inputs.container-suffix }}
120
+ token : ${{ secrets.codecov-token }}
189
121
190
122
- name : Show disk space after the tasks
191
123
run : df -h
124
+ shell : bash
0 commit comments