feat(ci): first version to run on gitlab
This commit is contained in:
parent
6199e828e2
commit
dfd2c4b43c
|
@ -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")
|
|
@ -1,5 +1,7 @@
|
||||||
stages:
|
stages:
|
||||||
|
- lint
|
||||||
- build
|
- build
|
||||||
|
- release
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
GIT_CLEAN_FLAGS: "none"
|
GIT_CLEAN_FLAGS: "none"
|
||||||
|
@ -9,9 +11,17 @@ variables:
|
||||||
GLUON_DIR: "$CI_PROJECT_DIR/gluon/"
|
GLUON_DIR: "$CI_PROJECT_DIR/gluon/"
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- export GLUON_RELEASE="$(git describe --tags --abbrev=0)-build${CI_PIPELINE_ID}"
|
- export GLUON_RELEASE="$(git describe --tags --abbrev=0 | sed 's/^v//g')-build${CI_PIPELINE_ID}"
|
||||||
|
|
||||||
.job_build:
|
|
||||||
|
'lint: TARGETS':
|
||||||
|
tags:
|
||||||
|
- gluon
|
||||||
|
stage: lint
|
||||||
|
script:
|
||||||
|
- ./.ci/lint-targets.py
|
||||||
|
|
||||||
|
"build":
|
||||||
tags:
|
tags:
|
||||||
- gluon
|
- gluon
|
||||||
stage: build
|
stage: build
|
||||||
|
@ -19,19 +29,41 @@ before_script:
|
||||||
script:
|
script:
|
||||||
- cd "gluon"
|
- cd "gluon"
|
||||||
- env
|
- 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 update V=s
|
||||||
- make --jobs=$(grep -c '^processor' /proc/cpuinfo) --output-sync=recurse || make --jobs=1 --output-sync=recurse V=sc
|
- make --jobs=$(grep -c '^processor' /proc/cpuinfo) --output-sync=recurse || make --jobs=1 --output-sync=recurse V=sc
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- "gluon/output/images/sysupgrade"
|
- "gluon/output/images/sysupgrade"
|
||||||
expire_in: 1 month
|
expire_in: "1 month"
|
||||||
|
cache:
|
||||||
|
# cache across all branches based on target
|
||||||
|
key: "$GLUON_TARGET"
|
||||||
|
paths:
|
||||||
|
- "gluon/openwrt"
|
||||||
|
parallel:
|
||||||
|
matrix:
|
||||||
|
- GLUON_TARGET:
|
||||||
|
- "ath79-generic"
|
||||||
|
- "ramips-mt7621"
|
||||||
|
|
||||||
|
'release: generate manifest':
|
||||||
###
|
tags:
|
||||||
# Build per target
|
- gluon
|
||||||
###
|
stage: release
|
||||||
|
script:
|
||||||
'build: ath79-generic':
|
- cd "gluon"
|
||||||
extends: .job_build
|
- '[[ "$CI_BUILD_REF_NAME" != "master" ]] && export GLUON_AUTOUPDATER_BRANCH="nightly"'
|
||||||
variables:
|
- make update V=s
|
||||||
GLUON_TARGET: "ath79-generic"
|
- 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: []
|
||||||
|
|
2
site.mk
2
site.mk
|
@ -31,7 +31,7 @@ GLUON_SITE_PACKAGES += \
|
||||||
# respondd-module-lldp \
|
# respondd-module-lldp \
|
||||||
|
|
||||||
# Allow overriding the these variables from the command line
|
# 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_BRANCH ?= stable
|
||||||
GLUON_AUTOUPDATER_ENABLED ?= 1
|
GLUON_AUTOUPDATER_ENABLED ?= 1
|
||||||
GLUON_PRIORITY ?= 0
|
GLUON_PRIORITY ?= 0
|
||||||
|
|
Loading…
Reference in New Issue