feat(ci): first version to run on gitlab

This commit is contained in:
genofire 2022-07-20 19:48:38 +02:00
parent eb9e6de0bf
commit ec5299ead8
3 changed files with 133 additions and 1 deletions

46
.ci/lint-targets.py Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env python3
from yaml import safe_load as yaml_load
import subprocess
from os import environ, chdir
targets_in_ci = []
targets_in_make = []
##
# Fetch data from .gitlab-ci.yml
##
with open('.gitlab-ci.yml', 'r') as file:
ci = yaml_load(file)
if "build" in ci:
targets_in_ci = ci["build"]['parallel']["matrix"][0]['GLUON_TARGET']
##
# Fetch data from gluon make
##
d = dict(environ)
if "GLUON_SITEDIR" not in d:
d["GLUON_SITEDIR"] = "../"
if "GLUON_DIR" not in d:
d["GLUON_DIR"] = "./gluon/"
chdir(d["GLUON_DIR"])
result = subprocess.run(['make', 'list-targets'], env=d, stdout=subprocess.PIPE, text=True)
targets_in_make = result.stdout.splitlines()
##
# Compare
##
only_in_ci = [ item for item in targets_in_ci if item not in targets_in_make]
only_in_make = [ item for item in targets_in_make if item not in targets_in_ci]
if len(only_in_ci) > 0:
print(f"\U0001F525 CI-Pipeline contains not supported TARGETS: {only_in_ci}")
exit(1)
if len(only_in_make) > 0:
print(f"\u26a0 CI-Pipeline does not contain all supported TARGETS: {only_in_make}")
else:
print("\u2705 works well - let's build for every TARGET a firmware")

86
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,86 @@
stages:
- lint
- build
- release
variables:
GIT_CLEAN_FLAGS: "none"
GIT_STRATEGY: "fetch"
GIT_SUBMODULE_STRATEGY: "recursive"
GLUON_SITEDIR: "$CI_PROJECT_DIR"
GLUON_DIR: "$CI_PROJECT_DIR/gluon/"
before_script:
- export GLUON_RELEASE="$(git describe --tags --abbrev=0 | sed 's/^v//g')-build${CI_PIPELINE_ID}"
'lint: TARGETS':
tags:
- gluon
stage: lint
script:
- ./.ci/lint-targets.py
"build":
tags:
- gluon
stage: build
timeout: 4h 30m
script:
- cd "gluon"
- env
# fetch newest gluon version if env is set
- "[ -z \"$FFHB_GLUON_PULL\" ] && git checkout origin/master && git pull --rebase"
# start build
- make update V=s
- make --jobs=$(grep -c '^processor' /proc/cpuinfo) --output-sync=recurse || make --jobs=1 --output-sync=recurse V=sc
artifacts:
paths:
- "gluon/output/images/sysupgrade"
expire_in: "1 month"
parallel:
matrix:
- GLUON_TARGET:
- "ath79-generic"
- "ath79-nand"
- "ath79-mikrotik"
- "bcm27xx-bcm2708"
- "bcm27xx-bcm2709"
- "bcm27xx-bcm2710" # on BROKEN
- "ipq40xx-generic"
- "ipq40xx-mikrotik"
- "ipq806x-generic"
- "lantiq-xrx200"
- "lantiq-xway"
- "mediatek-mt7622"
- "mpc85xx-p1010"
- "mpc85xx-p1020"
- "mvebu-cortexa9" # on BROKEN
- "ramips-mt7620"
- "ramips-mt7621"
- "ramips-mt76x8"
- "rockchip-armv8"
- "sunxi-cortexa7"
- "x86-generic"
- "x86-geode"
- "x86-legacy"
- "x86-64"
'release: generate manifest':
tags:
- gluon
stage: release
script:
- cd "gluon"
- '[[ "$CI_BUILD_REF_NAME" != "master" ]] && export GLUON_AUTOUPDATER_BRANCH="nightly"'
- make update V=s
- ls output/images/sysupgrade
- make manifest
- ls output/images/sysupgrade
artifacts:
paths:
- "gluon/output/images/sysupgrade/*manifest"
expire_in: "1 month"
# not use dependencies will download from every job
# empty array not download artifacts
# dependencies: []

View File

@ -28,7 +28,7 @@ GLUON_SITE_PACKAGES := \
gluon-scheduled-domain-switch
# Allow overriding the these variables from the command line
GLUON_RELEASE ?= $(patsubst v%,%,$(shell git -C $(GLUON_SITEDIR) describe --tags --dirty=+))
GLUON_RELEASE ?= $(patsubst v%,%,$(shell echo $(git -C $(GLUON_SITEDIR) describe --tags --abbrev=0))-build$(CI_PIPELINE_ID))))
GLUON_AUTOUPDATER_BRANCH ?= stable
GLUON_AUTOUPDATER_ENABLED ?= 1
GLUON_PRIORITY ?= 0