@@ -2,27 +2,44 @@ name: build-and-test
2
2
3
3
on :
4
4
push :
5
- schedule :
6
- - cron : 0 0 * * *
5
+ branches :
6
+ - main
7
7
workflow_dispatch :
8
8
9
+ concurrency :
10
+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
11
+ cancel-in-progress : true
12
+
13
+ env :
14
+ CC : /usr/lib/ccache/gcc
15
+ CXX : /usr/lib/ccache/g++
16
+
9
17
jobs :
10
18
build-and-test :
11
- if : ${{ github.event_name != 'push' || github.ref_name == github.event.repository.default_branch }}
12
- runs-on : ubuntu-latest
13
- container : ${{ matrix.container }}
19
+ runs-on : codebuild-autoware-us-east-1-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-large
20
+ container : ${{ matrix.container }}${{ matrix.container-suffix }}
14
21
strategy :
15
22
fail-fast : false
16
23
matrix :
17
24
rosdistro :
18
25
- humble
26
+ container-suffix :
27
+ - -cuda
19
28
include :
20
29
- rosdistro : humble
21
- container : ros:humble
30
+ container : ghcr.io/autowarefoundation/autoware:latest-autoware-universe
22
31
build-depends-repos : build_depends.repos
23
32
steps :
24
33
- name : Check out repository
25
34
uses : actions/checkout@v4
35
+ with :
36
+ fetch-depth : 1
37
+
38
+ - name : Show disk space before the tasks
39
+ run : df -h
40
+
41
+ - name : Show machine specs
42
+ run : lscpu && free -h
26
43
27
44
- name : Remove exec_depend
28
45
uses : autowarefoundation/autoware-github-actions/remove-exec-depend@v1
@@ -31,13 +48,65 @@ jobs:
31
48
id : get-self-packages
32
49
uses : autowarefoundation/autoware-github-actions/get-self-packages@v1
33
50
51
+ - name : Create ccache directory
52
+ run : |
53
+ mkdir -p ${CCACHE_DIR}
54
+ du -sh ${CCACHE_DIR} && ccache -s
55
+ shell : bash
56
+
57
+ - name : Attempt to restore ccache
58
+ uses : actions/cache/restore@v4
59
+ with :
60
+ path : |
61
+ /root/.ccache
62
+ key : ccache-main-${{ runner.arch }}-${{ matrix.rosdistro }}-${{ github.sha }}
63
+ restore-keys : |
64
+ ccache-main-${{ runner.arch }}-${{ matrix.rosdistro }}-
65
+
66
+ - name : Limit ccache size
67
+ run : |
68
+ rm -f "${CCACHE_DIR}/ccache.conf"
69
+ echo -e "# Set maximum cache size\nmax_size = 600MB" >> "${CCACHE_DIR}/ccache.conf"
70
+ shell : bash
71
+
72
+ - name : Show ccache stats before build and reset stats
73
+ run : |
74
+ du -sh ${CCACHE_DIR} && ccache -s
75
+ ccache --zero-stats
76
+ shell : bash
77
+
78
+ - name : Export CUDA state as a variable for adding to cache key
79
+ run : |
80
+ build_type_cuda_state=nocuda
81
+ if [[ "${{ matrix.container-suffix }}" == "-cuda" ]]; then
82
+ build_type_cuda_state=cuda
83
+ fi
84
+ echo "BUILD_TYPE_CUDA_STATE=$build_type_cuda_state" >> "${GITHUB_ENV}"
85
+ echo "::notice::BUILD_TYPE_CUDA_STATE=$build_type_cuda_state"
86
+ shell : bash
87
+
34
88
- name : Build
35
89
if : ${{ steps.get-self-packages.outputs.self-packages != '' }}
36
90
uses : autowarefoundation/autoware-github-actions/colcon-build@v1
37
91
with :
38
92
rosdistro : ${{ matrix.rosdistro }}
39
93
target-packages : ${{ steps.get-self-packages.outputs.self-packages }}
40
94
build-depends-repos : ${{ matrix.build-depends-repos }}
95
+ cache-key-element : ${{ env.BUILD_TYPE_CUDA_STATE }}
96
+ build-pre-command : taskset --cpu-list 0-6
97
+
98
+ - name : Show ccache stats after build
99
+ run : du -sh ${CCACHE_DIR} && ccache -s
100
+ shell : bash
101
+
102
+ # Only keep save the -cuda version because cuda packages covers non-cuda packages too
103
+ - name : Push the ccache cache
104
+ if : matrix.container-suffix == '-cuda'
105
+ uses : actions/cache/save@v4
106
+ with :
107
+ path : |
108
+ /root/.ccache
109
+ key : ccache-main-${{ runner.arch }}-${{ matrix.rosdistro }}-${{ github.sha }}
41
110
42
111
- name : Test
43
112
if : ${{ steps.get-self-packages.outputs.self-packages != '' }}
@@ -50,9 +119,13 @@ jobs:
50
119
51
120
- name : Upload coverage to CodeCov
52
121
if : ${{ steps.test.outputs.coverage-report-files != '' }}
53
- uses : codecov/codecov-action@v3
122
+ uses : codecov/codecov-action@v4
54
123
with :
55
124
files : ${{ steps.test.outputs.coverage-report-files }}
56
125
fail_ci_if_error : false
57
126
verbose : true
58
127
flags : total
128
+ token : ${{ secrets.CODECOV_TOKEN }}
129
+
130
+ - name : Show disk space after the tasks
131
+ run : df -h
0 commit comments