Skip to content

Commit f40a5b9

Browse files
khancyrtridge
authored andcommitted
.github: reduce duplicate for GCC and Clang build
1 parent d1983b0 commit f40a5b9

File tree

6 files changed

+114
-302
lines changed

6 files changed

+114
-302
lines changed

.github/workflows/test_sitl_copter.yml

Lines changed: 24 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ on: [push, pull_request]
66
# - "!README.md" <-- don't rebuild on doc change
77

88
jobs:
9-
build-gcc:
9+
build:
1010
runs-on: ubuntu-20.04
11-
container: khancyr/ardupilot-dev-base:latest
11+
container: khancyr/ardupilot-dev-${{ matrix.toolchain }}:latest
12+
strategy:
13+
fail-fast: false # don't cancel if a job from the matrix fails
14+
matrix:
15+
toolchain: [
16+
base, # GCC
17+
clang,
18+
]
1219
steps:
1320
# git checkout the PR
1421
- uses: actions/checkout@v2
@@ -24,8 +31,8 @@ jobs:
2431
uses: actions/cache@v2
2532
with:
2633
path: ~/.ccache
27-
key: ${{github.workflow}}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
28-
restore-keys: ${{github.workflow}}-ccache- # restore ccache from either previous build on this branch or on master
34+
key: ${{github.workflow}}-ccache-${{ matrix.toolchain }}-${{steps.ccache_cache_timestamp.outputs.timestamp}}
35+
restore-keys: ${{github.workflow}}-ccache-${{ matrix.toolchain }}- # restore ccache from either previous build on this branch or on master
2936
- name: setup ccache
3037
run: |
3138
mkdir -p ~/.ccache
@@ -35,57 +42,21 @@ jobs:
3542
echo "max_size = 400M" >> ~/.ccache/ccache.conf
3643
ccache -s
3744
ccache -z
38-
- name: build copter
45+
- name: build copter ${{ matrix.toolchain }}
3946
shell: bash
4047
run: |
48+
if [[ ${{ matrix.toolchain }} = "clang" ]]; then
49+
export CC=clang-7
50+
export CXX=clang++-7
51+
fi
4152
PATH="/github/home/.local/bin:$PATH"
4253
./waf configure --board sitl
4354
./waf build --target bin/arducopter
4455
ccache -s
4556
ccache -z
4657
47-
build-clang:
48-
runs-on: ubuntu-20.04
49-
container: khancyr/ardupilot-dev-clang:latest
50-
steps:
51-
# git checkout the PR
52-
- uses: actions/checkout@v2
53-
with:
54-
submodules: 'recursive'
55-
# Put ccache into github cache for faster build
56-
- name: Prepare ccache timestamp
57-
id: ccache_cache_timestamp
58-
run: |
59-
NOW=$(date -u +"%F-%T")
60-
echo "::set-output name=timestamp::${NOW}"
61-
- name: ccache cache files
62-
uses: actions/cache@v2
63-
with:
64-
path: ~/.ccache
65-
key: ${{github.workflow}}-ccache-clang-${{steps.ccache_cache_timestamp.outputs.timestamp}}
66-
restore-keys: ${{github.workflow}}-ccache-clang- # restore ccache from either previous build on this branch or on master
67-
- name: setup ccache
68-
run: |
69-
mkdir -p ~/.ccache
70-
echo "base_dir = ${GITHUB_WORKSPACE}" > ~/.ccache/ccache.conf
71-
echo "compression = true" >> ~/.ccache/ccache.conf
72-
echo "compression_level = 6" >> ~/.ccache/ccache.conf
73-
echo "max_size = 400M" >> ~/.ccache/ccache.conf
74-
ccache -s
75-
ccache -z
76-
- name: build copter
77-
shell: bash
78-
run: |
79-
export CC=clang-7
80-
export CXX=clang++-7
81-
PATH="/github/home/.local/bin:$PATH"
82-
./waf configure --board sitl --board sitl
83-
./waf build --target bin/arducopter
84-
ccache -s
85-
ccache -z
86-
8758
autotest:
88-
needs: build-gcc # don't try to launch the tests matrix if it doesn't build first, profit from caching for fast build
59+
needs: build # don't try to launch the tests matrix if it doesn't build first, profit from caching for fast build
8960
runs-on: ubuntu-20.04
9061
container: khancyr/ardupilot-dev-base:latest
9162
strategy:
@@ -116,8 +87,8 @@ jobs:
11687
uses: actions/cache@v2
11788
with:
11889
path: ~/.ccache
119-
key: ${{github.workflow}}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
120-
restore-keys: ${{github.workflow}}-ccache- # restore ccache from either previous build on this branch or on master
90+
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}
91+
restore-keys: ${{github.workflow}}-ccache-base- # restore ccache from either previous build on this branch or on master
12192
- name: setup ccache
12293
run: |
12394
mkdir -p ~/.ccache
@@ -151,7 +122,7 @@ jobs:
151122

152123

153124
build-gcc-heli:
154-
needs: build-gcc # don't try to launch the tests matrix if it doesn't build first, profit from caching for fast build
125+
needs: build # don't try to launch the tests matrix if it doesn't build first, profit from caching for fast build
155126
runs-on: ubuntu-20.04
156127
container: khancyr/ardupilot-dev-base:latest
157128
steps:
@@ -169,8 +140,8 @@ jobs:
169140
uses: actions/cache@v2
170141
with:
171142
path: ~/.ccache
172-
key: ${{github.workflow}}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
173-
restore-keys: ${{github.workflow}}-ccache- # restore ccache from either previous build on this branch or on master
143+
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}
144+
restore-keys: ${{github.workflow}}-ccache-base- # restore ccache from either previous build on this branch or on master
174145
- name: setup ccache
175146
run: |
176147
mkdir -p ~/.ccache
@@ -215,8 +186,8 @@ jobs:
215186
uses: actions/cache@v2
216187
with:
217188
path: ~/.ccache
218-
key: ${{github.workflow}}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
219-
restore-keys: ${{github.workflow}}-ccache- # restore ccache from either previous build on this branch or on master
189+
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}
190+
restore-keys: ${{github.workflow}}-ccache-base- # restore ccache from either previous build on this branch or on master
220191
- name: setup ccache
221192
run: |
222193
mkdir -p ~/.ccache

.github/workflows/test_sitl_plane.yml

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,16 @@ on: [push, pull_request]
66
# - "!README.md" <-- don't rebuild on doc change
77

88
jobs:
9-
build-gcc:
9+
build:
1010
runs-on: ubuntu-20.04
11-
container: khancyr/ardupilot-dev-base:latest
12-
steps:
13-
# git checkout the PR
14-
- uses: actions/checkout@v2
15-
with:
16-
submodules: 'recursive'
17-
# Put ccache into github cache for faster build
18-
- name: Prepare ccache timestamp
19-
id: ccache_cache_timestamp
20-
run: |
21-
NOW=$(date -u +"%F-%T")
22-
echo "::set-output name=timestamp::${NOW}"
23-
- name: ccache cache files
24-
uses: actions/cache@v2
25-
with:
26-
path: ~/.ccache
27-
key: ${{github.workflow}}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
28-
restore-keys: ${{github.workflow}}-ccache- # restore ccache from either previous build on this branch or on master
29-
- name: setup ccache
30-
run: |
31-
mkdir -p ~/.ccache
32-
echo "base_dir = ${GITHUB_WORKSPACE}" > ~/.ccache/ccache.conf
33-
echo "compression = true" >> ~/.ccache/ccache.conf
34-
echo "compression_level = 6" >> ~/.ccache/ccache.conf
35-
echo "max_size = 400M" >> ~/.ccache/ccache.conf
36-
ccache -s
37-
ccache -z
38-
- name: build plane gcc
39-
shell: bash
40-
run: |
41-
PATH="/github/home/.local/bin:$PATH"
42-
./waf configure --board sitl
43-
./waf build --target bin/arduplane
44-
ccache -s
45-
ccache -z
46-
47-
build-clang:
48-
runs-on: ubuntu-20.04
49-
container: khancyr/ardupilot-dev-clang:latest
11+
container: khancyr/ardupilot-dev-${{ matrix.toolchain }}:latest
12+
strategy:
13+
fail-fast: false # don't cancel if a job from the matrix fails
14+
matrix:
15+
toolchain: [
16+
base, # GCC
17+
clang,
18+
]
5019
steps:
5120
# git checkout the PR
5221
- uses: actions/checkout@v2
@@ -62,8 +31,8 @@ jobs:
6231
uses: actions/cache@v2
6332
with:
6433
path: ~/.ccache
65-
key: ${{github.workflow}}-ccache-clang-${{steps.ccache_cache_timestamp.outputs.timestamp}}
66-
restore-keys: ${{github.workflow}}-ccache-clang- # restore ccache from either previous build on this branch or on master
34+
key: ${{github.workflow}}-ccache-${{ matrix.toolchain }}-${{steps.ccache_cache_timestamp.outputs.timestamp}}
35+
restore-keys: ${{github.workflow}}-ccache-${{ matrix.toolchain }}- # restore ccache from either previous build on this branch or on master
6736
- name: setup ccache
6837
run: |
6938
mkdir -p ~/.ccache
@@ -73,19 +42,21 @@ jobs:
7342
echo "max_size = 400M" >> ~/.ccache/ccache.conf
7443
ccache -s
7544
ccache -z
76-
- name: build plane clang
45+
- name: build plane ${{ matrix.toolchain }}
7746
shell: bash
7847
run: |
79-
export CC=clang-7
80-
export CXX=clang++-7
48+
if [[ ${{ matrix.toolchain }} = "clang" ]]; then
49+
export CC=clang-7
50+
export CXX=clang++-7
51+
fi
8152
PATH="/github/home/.local/bin:$PATH"
8253
./waf configure --board sitl
8354
./waf build --target bin/arduplane
8455
ccache -s
8556
ccache -z
8657
8758
autotest:
88-
needs: build-gcc # don't try to launch the tests matrix if it doesn't build first, profit from caching for fast build
59+
needs: build # don't try to launch the tests matrix if it doesn't build first, profit from caching for fast build
8960
runs-on: ubuntu-20.04
9061
container: khancyr/ardupilot-dev-base:latest
9162
strategy:
@@ -111,8 +82,8 @@ jobs:
11182
uses: actions/cache@v2
11283
with:
11384
path: ~/.ccache
114-
key: ${{github.workflow}}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
115-
restore-keys: ${{github.workflow}}-ccache- # restore ccache from either previous build on this branch or on master
85+
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}
86+
restore-keys: ${{github.workflow}}-ccache-base- # restore ccache from either previous build on this branch or on master
11687
- name: setup ccache
11788
run: |
11889
mkdir -p ~/.ccache

.github/workflows/test_sitl_rover.yml

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,16 @@ on: [push, pull_request]
66
# - "!README.md" <-- don't rebuild on doc change
77

88
jobs:
9-
build-gcc:
9+
build:
1010
runs-on: ubuntu-20.04
11-
container: khancyr/ardupilot-dev-base:latest
12-
steps:
13-
# git checkout the PR
14-
- uses: actions/checkout@v2
15-
with:
16-
submodules: 'recursive'
17-
# Put ccache into github cache for faster build
18-
- name: Prepare ccache timestamp
19-
id: ccache_cache_timestamp
20-
run: |
21-
NOW=$(date -u +"%F-%T")
22-
echo "::set-output name=timestamp::${NOW}"
23-
- name: ccache cache files
24-
uses: actions/cache@v2
25-
with:
26-
path: ~/.ccache
27-
key: ${{github.workflow}}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
28-
restore-keys: ${{github.workflow}}-ccache- # restore ccache from either previous build on this branch or on master
29-
- name: setup ccache
30-
run: |
31-
mkdir -p ~/.ccache
32-
echo "base_dir = ${GITHUB_WORKSPACE}" > ~/.ccache/ccache.conf
33-
echo "compression = true" >> ~/.ccache/ccache.conf
34-
echo "compression_level = 6" >> ~/.ccache/ccache.conf
35-
echo "max_size = 400M" >> ~/.ccache/ccache.conf
36-
ccache -s
37-
ccache -z
38-
- name: build rover gcc
39-
shell: bash
40-
run: |
41-
PATH="/github/home/.local/bin:$PATH"
42-
./waf configure --board sitl
43-
./waf build --target bin/ardurover
44-
ccache -s
45-
ccache -z
46-
47-
build-clang:
48-
runs-on: ubuntu-20.04
49-
container: khancyr/ardupilot-dev-clang:latest
11+
container: khancyr/ardupilot-dev-${{ matrix.toolchain }}:latest
12+
strategy:
13+
fail-fast: false # don't cancel if a job from the matrix fails
14+
matrix:
15+
toolchain: [
16+
base, # GCC
17+
clang,
18+
]
5019
steps:
5120
# git checkout the PR
5221
- uses: actions/checkout@v2
@@ -62,8 +31,8 @@ jobs:
6231
uses: actions/cache@v2
6332
with:
6433
path: ~/.ccache
65-
key: ${{github.workflow}}-ccache-clang-${{steps.ccache_cache_timestamp.outputs.timestamp}}
66-
restore-keys: ${{github.workflow}}-ccache-clang- # restore ccache from either previous build on this branch or on master
34+
key: ${{github.workflow}}-ccache-${{ matrix.toolchain }}-${{steps.ccache_cache_timestamp.outputs.timestamp}}
35+
restore-keys: ${{github.workflow}}-ccache-${{ matrix.toolchain }}- # restore ccache from either previous build on this branch or on master
6736
- name: setup ccache
6837
run: |
6938
mkdir -p ~/.ccache
@@ -73,19 +42,21 @@ jobs:
7342
echo "max_size = 400M" >> ~/.ccache/ccache.conf
7443
ccache -s
7544
ccache -z
76-
- name: build rover clang
45+
- name: build rover ${{ matrix.toolchain }}
7746
shell: bash
7847
run: |
79-
export CC=clang-7
80-
export CXX=clang++-7
48+
if [[ ${{ matrix.toolchain }} = "clang" ]]; then
49+
export CC=clang-7
50+
export CXX=clang++-7
51+
fi
8152
PATH="/github/home/.local/bin:$PATH"
8253
./waf configure --board sitl
8354
./waf build --target bin/ardurover
8455
ccache -s
8556
ccache -z
8657
8758
autotest:
88-
needs: build-gcc # don't try to launch the tests matrix if it doesn't build first, profit from caching for fast build
59+
needs: build # don't try to launch the tests matrix if it doesn't build first, profit from caching for fast build
8960
runs-on: ubuntu-20.04
9061
container: khancyr/ardupilot-dev-base:latest
9162
strategy:
@@ -111,8 +82,8 @@ jobs:
11182
uses: actions/cache@v2
11283
with:
11384
path: ~/.ccache
114-
key: ${{github.workflow}}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
115-
restore-keys: ${{github.workflow}}-ccache- # restore ccache from either previous build on this branch or on master
85+
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}
86+
restore-keys: ${{github.workflow}}-ccache-base- # restore ccache from either previous build on this branch or on master
11687
- name: setup ccache
11788
run: |
11889
mkdir -p ~/.ccache

0 commit comments

Comments
 (0)