Skip to content

Commit ee063f1

Browse files
RomainNaourtpetazzoni
authored andcommitted
Completely rewrite the build logic, using a 3 stage pipeline
Signed-off-by: Romain Naour <[email protected]> Signed-off-by: Thomas Petazzoni <[email protected]>
1 parent 09e96f2 commit ee063f1

19 files changed

+1116
-747
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
buildroot/
22
builds
3-
.gitlab-ci.yml
3+
build
4+
test

.gitlab-ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Configuration for Gitlab-CI.
2+
# Builds appear on https://gitlab.com/kubu93/toolchains-builder/pipelines
3+
4+
image: buildroot/base:20200814.2228
5+
6+
stages:
7+
- generate-gitlab-ci
8+
- build
9+
10+
generate-gitlab-ci-yml:
11+
stage: generate-gitlab-ci
12+
script: .gitlab-ci/generate-gitlab-ci-yml .gitlab-ci/gitlab-ci.yml.in > generated-gitlab-ci.yml
13+
artifacts:
14+
paths:
15+
- generated-gitlab-ci.yml
16+
17+
buildroot-pipeline:
18+
stage: build
19+
trigger:
20+
include:
21+
- artifact: generated-gitlab-ci.yml
22+
job: generate-gitlab-ci-yml
23+
strategy: depend

.gitlab-ci.yml.in

Lines changed: 0 additions & 19 deletions
This file was deleted.

.gitlab-ci/generate-gitlab-ci-yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -o pipefail
4+
5+
main() {
6+
local template="${1}"
7+
8+
preamble "${template}"
9+
gen_tests
10+
}
11+
12+
preamble() {
13+
local template="${1}"
14+
15+
cat - "${template}" <<-_EOF_
16+
# This file is generated; do not edit!
17+
# Builds appear on https://gitlab.com/kubu93/toolchains-builder/pipelines
18+
19+
stages:
20+
- toolchain_build
21+
- toolchain_test
22+
- toolchain_upload
23+
24+
variables:
25+
TOOLCHAIN_BUILDER_TARGET: "${TOOLCHAIN_BUILDER_TARGET}"
26+
TOOLCHAIN_BUILDER_BRTREE: "${TOOLCHAIN_BUILDER_BRTREE}"
27+
TOOLCHAIN_BUILDER_VERSION: "${TOOLCHAIN_BUILDER_VERSION}"
28+
29+
_EOF_
30+
}
31+
32+
gen_tests() {
33+
local -a toolchain_jobs
34+
local cfg
35+
36+
toolchain_jobs=( $(cd frags; LC_ALL=C ls -1 *.config | sed 's/\.config$//') )
37+
38+
for cfg in "${toolchain_jobs[@]}"; do
39+
printf '%s_build: { extends: .toolchain_build }\n' "${cfg}"
40+
printf '%s_test: { extends: .toolchain_test, needs: ["%s_build"] }\n' \
41+
"${cfg}" "${cfg}"
42+
printf '%s_upload: { extends: .toolchain_upload, needs: ["%s_build", "%s_test"] }\n' \
43+
"${cfg}" "${cfg}" "${cfg}"
44+
done
45+
}
46+
47+
main "${@}"

.gitlab-ci/gitlab-ci.yml.in

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.toolchain_build:
2+
stage: toolchain_build
3+
image: kubu93/toolchain-builder:20210227.0043
4+
before_script:
5+
- DEFCONFIG_FRAG_NAME=$(echo ${CI_JOB_NAME} | sed -e 's,_build$,,g')
6+
script:
7+
- echo "Start building toolchain for ${DEFCONFIG_FRAG_NAME}"
8+
- |
9+
./build-toolchain.sh ${DEFCONFIG_FRAG_NAME} ${TOOLCHAIN_BUILDER_TARGET} ${TOOLCHAIN_BUILDER_BRTREE} ${TOOLCHAIN_BUILDER_VERSION} 2>&1 || {
10+
echo 'Failed build last output'
11+
tail -200 build/*-build.log
12+
exit 1
13+
}
14+
artifacts:
15+
when: always
16+
expire_in: 2 weeks
17+
paths:
18+
- build/*.config
19+
- build/*-build.log
20+
- build/*.tar.bz2
21+
- build/*.sha256
22+
- build/README.txt
23+
- build/summary.csv
24+
- build/output/.config
25+
- build/output/defconfig
26+
- build/output/legal-info/
27+
- build/br_fragment
28+
29+
.toolchain_test:
30+
stage: toolchain_test
31+
image: buildroot/base:20200814.2228
32+
before_script:
33+
- DEFCONFIG_FRAG_NAME=$(echo ${CI_JOB_NAME} | sed -e 's,_test$,,g')
34+
script:
35+
- echo "Start testing toolchain for ${DEFCONFIG_FRAG_NAME}"
36+
- |
37+
./test-toolchain.sh ${DEFCONFIG_FRAG_NAME} ${TOOLCHAIN_BUILDER_TARGET} ${TOOLCHAIN_BUILDER_BRTREE} ${TOOLCHAIN_BUILDER_VERSION} 2>&1 || {
38+
echo 'Failed test last output'
39+
tail -200 test/*-test-build.log
40+
tail -200 test/*-test-boot.log
41+
exit 1
42+
}
43+
artifacts:
44+
when: always
45+
expire_in: 2 weeks
46+
paths:
47+
- test/*.config
48+
- test/*.tar.bz2
49+
- test/*.sha256
50+
- test/*-test-result.txt
51+
- test/*-test-build.log
52+
- test/*-test-boot.log
53+
- test/output/.config
54+
- test/output/images
55+
56+
.toolchain_upload:
57+
stage: toolchain_upload
58+
image: tpetazzoni/toolchain-upload:20211224.1113
59+
before_script:
60+
- DEFCONFIG_FRAG_NAME=$(echo ${CI_JOB_NAME} | sed -e 's,_upload,,g')
61+
- eval $(ssh-agent -s)
62+
- ssh-add <(echo "$SSH_PRIVATE_KEY")
63+
- mkdir -p ~/.ssh
64+
- '[[ -f /.dockerenv ]] && echo "$SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts'
65+
script:
66+
- echo "Uploading toolchain for ${DEFCONFIG_FRAG_NAME}"
67+
- ./upload-toolchain.sh ${DEFCONFIG_FRAG_NAME} ${TOOLCHAIN_BUILDER_TARGET} ${TOOLCHAIN_BUILDER_BRTREE} ${TOOLCHAIN_BUILDER_VERSION}

0 commit comments

Comments
 (0)