Skip to content

Commit 0dad983

Browse files
committed
ci: update build-and-test workflows
Signed-off-by: Ryohsuke Mitsudome <ryohsuke.mitsudome@tier4.jp>
1 parent d02c63c commit 0dad983

File tree

2 files changed

+159
-7
lines changed

2 files changed

+159
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: build-and-test-daily
2+
3+
on:
4+
schedule:
5+
- cron: 0 0 * * *
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-test-daily:
10+
runs-on: [self-hosted, linux, X64, gpu]
11+
container: ${{ matrix.container }}${{ matrix.container-suffix }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
rosdistro:
16+
- humble
17+
container-suffix:
18+
- ""
19+
- -cuda
20+
include:
21+
- rosdistro: humble
22+
container: ghcr.io/autowarefoundation/autoware:latest-autoware-universe
23+
build-depends-repos: build_depends.repos
24+
steps:
25+
- name: Check out repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 1
29+
30+
- name: Show disk space before the tasks
31+
run: df -h
32+
33+
- name: Remove exec_depend
34+
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1
35+
36+
- name: Get self packages
37+
id: get-self-packages
38+
uses: autowarefoundation/autoware-github-actions/get-self-packages@v1
39+
40+
- name: Export CUDA state as a variable for adding to cache key
41+
run: |
42+
build_type_cuda_state=nocuda
43+
if [[ "${{ matrix.container-suffix }}" == "-cuda" ]]; then
44+
build_type_cuda_state=cuda
45+
fi
46+
echo "BUILD_TYPE_CUDA_STATE=$build_type_cuda_state" >> "${GITHUB_ENV}"
47+
echo "::notice::BUILD_TYPE_CUDA_STATE=$build_type_cuda_state"
48+
shell: bash
49+
50+
- name: Build
51+
if: ${{ steps.get-self-packages.outputs.self-packages != '' }}
52+
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
53+
with:
54+
rosdistro: ${{ matrix.rosdistro }}
55+
target-packages: ${{ steps.get-self-packages.outputs.self-packages }}
56+
build-depends-repos: ${{ matrix.build-depends-repos }}
57+
cache-key-element: ${{ env.BUILD_TYPE_CUDA_STATE }}
58+
59+
- name: Test
60+
if: ${{ steps.get-self-packages.outputs.self-packages != '' }}
61+
id: test
62+
uses: autowarefoundation/autoware-github-actions/colcon-test@v1
63+
with:
64+
rosdistro: ${{ matrix.rosdistro }}
65+
target-packages: ${{ steps.get-self-packages.outputs.self-packages }}
66+
build-depends-repos: ${{ matrix.build-depends-repos }}
67+
68+
- name: Upload coverage to CodeCov
69+
if: ${{ steps.test.outputs.coverage-report-files != '' }}
70+
uses: codecov/codecov-action@v4
71+
with:
72+
files: ${{ steps.test.outputs.coverage-report-files }}
73+
fail_ci_if_error: false
74+
verbose: true
75+
flags: total
76+
token: ${{ secrets.CODECOV_TOKEN }}
77+
78+
- name: Show disk space after the tasks
79+
run: df -h

.github/workflows/build-and-test.yaml

+80-7
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,44 @@ name: build-and-test
22

33
on:
44
push:
5-
schedule:
6-
- cron: 0 0 * * *
5+
branches:
6+
- main
77
workflow_dispatch:
88

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+
917
jobs:
1018
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 }}
1421
strategy:
1522
fail-fast: false
1623
matrix:
1724
rosdistro:
1825
- humble
26+
container-suffix:
27+
- -cuda
1928
include:
2029
- rosdistro: humble
21-
container: ros:humble
30+
container: ghcr.io/autowarefoundation/autoware:latest-autoware-universe
2231
build-depends-repos: build_depends.repos
2332
steps:
2433
- name: Check out repository
2534
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
2643

2744
- name: Remove exec_depend
2845
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1
@@ -31,13 +48,65 @@ jobs:
3148
id: get-self-packages
3249
uses: autowarefoundation/autoware-github-actions/get-self-packages@v1
3350

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+
3488
- name: Build
3589
if: ${{ steps.get-self-packages.outputs.self-packages != '' }}
3690
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
3791
with:
3892
rosdistro: ${{ matrix.rosdistro }}
3993
target-packages: ${{ steps.get-self-packages.outputs.self-packages }}
4094
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 }}
41110

42111
- name: Test
43112
if: ${{ steps.get-self-packages.outputs.self-packages != '' }}
@@ -50,9 +119,13 @@ jobs:
50119

51120
- name: Upload coverage to CodeCov
52121
if: ${{ steps.test.outputs.coverage-report-files != '' }}
53-
uses: codecov/codecov-action@v3
122+
uses: codecov/codecov-action@v4
54123
with:
55124
files: ${{ steps.test.outputs.coverage-report-files }}
56125
fail_ci_if_error: false
57126
verbose: true
58127
flags: total
128+
token: ${{ secrets.CODECOV_TOKEN }}
129+
130+
- name: Show disk space after the tasks
131+
run: df -h

0 commit comments

Comments
 (0)