mirror of
https://git.yoctoproject.org/meta-zephyr
synced 2026-01-29 13:58:40 +01:00
CI: add Gitlab CI support
Mostly stolen from meta-arm Signed-off-by: Jon Mason <jon.mason@arm.com> Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
This commit is contained in:
101
.gitlab-ci.yml
Normal file
101
.gitlab-ci.yml
Normal file
@@ -0,0 +1,101 @@
|
||||
image: ghcr.io/siemens/kas/kas:latest-release
|
||||
|
||||
stages:
|
||||
- prep
|
||||
- build
|
||||
|
||||
# Common job fragment to get a worker ready
|
||||
.setup:
|
||||
stage: build
|
||||
interruptible: true
|
||||
variables:
|
||||
KAS_WORK_DIR: $CI_PROJECT_DIR/work
|
||||
KAS_REPO_REF_DIR: $CI_BUILDS_DIR/persist/repos
|
||||
SSTATE_DIR: $CI_BUILDS_DIR/persist/sstate
|
||||
DL_DIR: $CI_BUILDS_DIR/persist/downloads
|
||||
BB_LOGCONFIG: $CI_PROJECT_DIR/ci/logging.yml
|
||||
before_script:
|
||||
- echo KAS_WORK_DIR = $KAS_WORK_DIR
|
||||
- echo SSTATE_DIR = $SSTATE_DIR
|
||||
- echo DL_DIR = $DL_DIR
|
||||
- rm -rf $KAS_WORK_DIR
|
||||
- mkdir --verbose --parents $KAS_WORK_DIR $KAS_REPO_REF_DIR $SSTATE_DIR $DL_DIR
|
||||
|
||||
# Generalised fragment to do a Kas build
|
||||
.build:
|
||||
extends: .setup
|
||||
script:
|
||||
- KASFILES=$(./ci/jobs-to-kas "$CI_JOB_NAME")
|
||||
- kas shell --update --force-checkout $KASFILES -c 'cat conf/*.conf'
|
||||
- kas build $KASFILES
|
||||
- ./ci/check-warnings $KAS_WORK_DIR/build/warnings.log
|
||||
artifacts:
|
||||
name: "logs"
|
||||
when: on_failure
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/work/build/tmp/work*/**/temp/log.do_*.*
|
||||
|
||||
# Workaround for Zephyr not currectly handling TESTIMAGE_AUTO
|
||||
.build_and_test:
|
||||
extends: .setup
|
||||
script:
|
||||
- KASFILES=$(./ci/jobs-to-kas "$CI_JOB_NAME")
|
||||
- kas shell --update --force-checkout $KASFILES -c 'cat conf/*.conf'
|
||||
- kas build $KASFILES
|
||||
- kas build $KASFILES -c testimage
|
||||
- ./ci/check-warnings $KAS_WORK_DIR/build/warnings.log
|
||||
|
||||
|
||||
#
|
||||
# Prep stage, update repositories once
|
||||
#
|
||||
update-repos:
|
||||
extends: .setup
|
||||
stage: prep
|
||||
script:
|
||||
- flock --verbose --timeout 60 $KAS_REPO_REF_DIR ./ci/update-repos
|
||||
|
||||
|
||||
#
|
||||
# Bootstrap stage, machine coverage
|
||||
#
|
||||
|
||||
# What percentage of machines in the layer do we build
|
||||
machine-coverage:
|
||||
stage: prep
|
||||
interruptible: true
|
||||
script:
|
||||
- ./ci/check-machine-coverage
|
||||
coverage: '/Coverage: \d+/'
|
||||
|
||||
|
||||
#
|
||||
# Build stage, the actual build jobs
|
||||
#
|
||||
|
||||
96b-avenger96:
|
||||
extends: .build
|
||||
|
||||
96b-nitrogen:
|
||||
extends: .build
|
||||
|
||||
arduino-nano-33-ble:
|
||||
extends: .build
|
||||
|
||||
intel-x86-64:
|
||||
extends: .build
|
||||
|
||||
nrf52840dk-nrf52840:
|
||||
extends: .build
|
||||
|
||||
stm32mp157c-dk2:
|
||||
extends: .build
|
||||
|
||||
qemu-cortex-m3/testimage:
|
||||
extends: .build_and_test
|
||||
|
||||
qemu-nios2/testimage:
|
||||
extends: .build
|
||||
|
||||
qemu-x86/testimage:
|
||||
extends: .build_and_test
|
||||
6
ci/96b-avenger96.yml
Normal file
6
ci/96b-avenger96.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
header:
|
||||
version: 9
|
||||
includes:
|
||||
- base.yml
|
||||
|
||||
machine: 96b-avenger96
|
||||
6
ci/96b-nitrogen.yml
Normal file
6
ci/96b-nitrogen.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
header:
|
||||
version: 9
|
||||
includes:
|
||||
- base.yml
|
||||
|
||||
machine: 96b-nitrogen
|
||||
6
ci/arduino-nano-33-ble.yml
Normal file
6
ci/arduino-nano-33-ble.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
header:
|
||||
version: 9
|
||||
includes:
|
||||
- base.yml
|
||||
|
||||
machine: arduino-nano-33-ble
|
||||
36
ci/base.yml
Normal file
36
ci/base.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
header:
|
||||
version: 11
|
||||
includes:
|
||||
- meta-openembedded.yml
|
||||
|
||||
distro: zephyr
|
||||
|
||||
defaults:
|
||||
repos:
|
||||
refspec: master
|
||||
|
||||
repos:
|
||||
meta-zephyr:
|
||||
layers:
|
||||
meta-zephyr-core:
|
||||
meta-zephyr-bsp:
|
||||
|
||||
poky:
|
||||
url: https://git.yoctoproject.org/git/poky
|
||||
layers:
|
||||
meta:
|
||||
meta-poky:
|
||||
|
||||
env:
|
||||
BB_LOGCONFIG: ""
|
||||
|
||||
local_conf_header:
|
||||
base: |
|
||||
BB_SERVER_TIMEOUT = "60"
|
||||
CONF_VERSION = "2"
|
||||
INHERIT += "rm_work"
|
||||
|
||||
machine: unset
|
||||
|
||||
target:
|
||||
- zephyr-kernel-test-all
|
||||
26
ci/check-machine-coverage
Executable file
26
ci/check-machine-coverage
Executable file
@@ -0,0 +1,26 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
metazephyr = Path.cwd()
|
||||
|
||||
if metazephyr.name != "meta-zephyr":
|
||||
print("Not running inside meta-zephyr")
|
||||
sys.exit(1)
|
||||
|
||||
# All machine configurations
|
||||
machines = metazephyr.glob("meta-zephyr-bsp/conf/machine/*.conf")
|
||||
machines = set(p.stem for p in machines)
|
||||
|
||||
# All kas files
|
||||
kas = metazephyr.glob("ci/*.yml")
|
||||
kas = set(p.stem for p in kas)
|
||||
|
||||
missing = machines - kas
|
||||
print(f"The following machines are missing: {', '.join(sorted(missing))}.")
|
||||
|
||||
covered = len(machines) - len(missing)
|
||||
total = len(machines)
|
||||
percent = int(covered / total * 100)
|
||||
print(f"Coverage: {percent}%")
|
||||
19
ci/check-warnings
Executable file
19
ci/check-warnings
Executable file
@@ -0,0 +1,19 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Expects the path to a log file as $1, and if this file has any content
|
||||
# then display the contents and exit with an error code.
|
||||
|
||||
set -e -u
|
||||
|
||||
LOGFILE=$1
|
||||
|
||||
LINES=$(grep --invert-match "relocations in \.text" $LOGFILE | wc -l)
|
||||
if test "$LINES" -ne 0; then
|
||||
echo ==============================
|
||||
echo The build had warnings/errors:
|
||||
echo ==============================
|
||||
cat $LOGFILE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
6
ci/intel-x86-64.yml
Normal file
6
ci/intel-x86-64.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
header:
|
||||
version: 9
|
||||
includes:
|
||||
- base.yml
|
||||
|
||||
machine: intel-x86-64
|
||||
19
ci/jobs-to-kas
Executable file
19
ci/jobs-to-kas
Executable file
@@ -0,0 +1,19 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Read a GitLab CI job name on $1 and transform it to a
|
||||
# list of Kas yaml files
|
||||
|
||||
set -e -u
|
||||
|
||||
# Read Job namne from $1 and split on /
|
||||
IFS=/ read -r -a PARTS<<<$1
|
||||
|
||||
# Prefix each part with ci/
|
||||
PARTS=("${PARTS[@]/#/ci/}")
|
||||
|
||||
# Suffix each part with .yml
|
||||
PARTS=("${PARTS[@]/%/.yml}")
|
||||
|
||||
# Print colon-separated
|
||||
IFS=":"
|
||||
echo "${PARTS[*]}"
|
||||
13
ci/logging.yml
Normal file
13
ci/logging.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
# Python logging configuration to write all warnings to a separate file
|
||||
version: 1
|
||||
|
||||
handlers:
|
||||
warnings:
|
||||
class: logging.FileHandler
|
||||
level: WARNING
|
||||
filename: warnings.log
|
||||
formatter: BitBake.logfileFormatter
|
||||
|
||||
loggers:
|
||||
BitBake:
|
||||
handlers: [warnings]
|
||||
11
ci/meta-openembedded.yml
Normal file
11
ci/meta-openembedded.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
header:
|
||||
version: 11
|
||||
|
||||
repos:
|
||||
meta-openembedded:
|
||||
url: https://git.openembedded.org/meta-openembedded
|
||||
layers:
|
||||
meta-filesystems:
|
||||
meta-networking:
|
||||
meta-oe:
|
||||
meta-python:
|
||||
6
ci/nrf52840dk-nrf52840.yml
Normal file
6
ci/nrf52840dk-nrf52840.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
header:
|
||||
version: 9
|
||||
includes:
|
||||
- base.yml
|
||||
|
||||
machine: nrf52840dk-nrf52840
|
||||
12
ci/qemu-cortex-m3.yml
Normal file
12
ci/qemu-cortex-m3.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
header:
|
||||
version: 11
|
||||
includes:
|
||||
- ci/base.yml
|
||||
|
||||
local_conf_header:
|
||||
nonbuilding_tests: |
|
||||
ZEPHYRTESTS:remove = "common context pending poll sleep"
|
||||
qemu_opts: |
|
||||
QB_OPT_APPEND = "-icount shift=3,align=off,sleep=on -rtc clock=vm"
|
||||
|
||||
machine: qemu-cortex-m3
|
||||
10
ci/qemu-nios2.yml
Normal file
10
ci/qemu-nios2.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
header:
|
||||
version: 9
|
||||
includes:
|
||||
- base.yml
|
||||
|
||||
local_conf_header:
|
||||
nonbuilding_tests: |
|
||||
ZEPHYRTESTS:remove = "interrupt"
|
||||
|
||||
machine: qemu-nios2
|
||||
10
ci/qemu-x86.yml
Normal file
10
ci/qemu-x86.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
header:
|
||||
version: 9
|
||||
includes:
|
||||
- base.yml
|
||||
|
||||
local_conf_header:
|
||||
failing_tests: |
|
||||
ZEPHYRTESTS:remove = "pending"
|
||||
|
||||
machine: qemu-x86
|
||||
6
ci/stm32mp157c-dk2.yml
Normal file
6
ci/stm32mp157c-dk2.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
header:
|
||||
version: 9
|
||||
includes:
|
||||
- base.yml
|
||||
|
||||
machine: stm32mp157c-dk2
|
||||
8
ci/testimage.yml
Normal file
8
ci/testimage.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
header:
|
||||
version: 11
|
||||
|
||||
local_conf_header:
|
||||
testimage: |
|
||||
IMAGE_CLASSES += "testimage"
|
||||
TEST_TARGET = "QemuTargetZephyr"
|
||||
TEST_SUITES = "zephyr"
|
||||
40
ci/update-repos
Executable file
40
ci/update-repos
Executable file
@@ -0,0 +1,40 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
# Update clones of the repositories we need in KAS_REPO_REF_DIR to speed up fetches
|
||||
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import pathlib
|
||||
|
||||
def repo_shortname(url):
|
||||
# Taken from Kas (Repo.__getattr__) to ensure the logic is right
|
||||
from urllib.parse import urlparse
|
||||
url = urlparse(url)
|
||||
return ('{url.netloc}{url.path}'
|
||||
.format(url=url)
|
||||
.replace('@', '.')
|
||||
.replace(':', '.')
|
||||
.replace('/', '.')
|
||||
.replace('*', '.'))
|
||||
|
||||
repositories = (
|
||||
"https://git.yoctoproject.org/git/poky",
|
||||
"https://git.openembedded.org/meta-openembedded",
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if "KAS_REPO_REF_DIR" not in os.environ:
|
||||
print("KAS_REPO_REF_DIR needs to be set")
|
||||
sys.exit(1)
|
||||
|
||||
base_repodir = pathlib.Path(os.environ["KAS_REPO_REF_DIR"])
|
||||
|
||||
for repo in repositories:
|
||||
repodir = base_repodir / repo_shortname(repo)
|
||||
if repodir.exists():
|
||||
print("Updating %s..." % repo)
|
||||
subprocess.run(["git", "-C", repodir, "fetch"], check=True)
|
||||
else:
|
||||
print("Cloning %s..." % repo)
|
||||
subprocess.run(["git", "clone", "--bare", repo, repodir], check=True)
|
||||
Reference in New Issue
Block a user