Bulk merge from repo:ci-managment
Change-Id: I7b733b43699b47deaaec2fe433987619b6928158
diff --git a/makefiles/release/help.mk b/makefiles/release/help.mk
new file mode 100644
index 0000000..72af6be
--- /dev/null
+++ b/makefiles/release/help.mk
@@ -0,0 +1,38 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+# Intent: Helper makefile target used to setup for a release
+# -----------------------------------------------------------------------
+
+## ---------------------------------------------------------------------------
+## Intent: Display supported targets
+## ---------------------------------------------------------------------------
+help-voltha-release :
+ @echo
+ @echo '[RELEASE] - Create branch driven testing pipelines'
+ @echo ' create-jobs-release'
+ @echo ' create-jobs-release-bat Build and test jobs'
+ @echo ' create-jobs-release-e2e End-to-End testing'
+ @echo ' create-jobs-release-certification Certification testing'
+ @echo ' create-jobs-release-nightly Nightly testing'
+ @echo ' create-jobs-release-units Unit testing'
+
+ @echo ' sterile-create-jobs-release Purge pipeline job content'
+
+help ::
+ @echo ' help-voltha-release Display voltha release targets'
+
+# [EOF]
diff --git a/makefiles/release/include.mk b/makefiles/release/include.mk
new file mode 100644
index 0000000..8891df1
--- /dev/null
+++ b/makefiles/release/include.mk
@@ -0,0 +1,36 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##--------------------##
+##---] INCLUDES [---##
+##--------------------##
+include $(ONF_MAKEDIR)/release/help.mk
+include $(ONF_MAKEDIR)/release/required.mk
+
+ifdef USE_VOLTHA_RELEASE_MK
+ # Dynamic loading when targets are requested by name
+ include $(ONF_MAKEDIR)/release/targets.mk
+endif
+
+# [EOF]
+
+
diff --git a/makefiles/release/required.mk b/makefiles/release/required.mk
new file mode 100644
index 0000000..620b827
--- /dev/null
+++ b/makefiles/release/required.mk
@@ -0,0 +1,36 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+# Intent: Conditionally load when named targets are requested.
+# var ?= $(error ...) definitions are fatal to "make help" and others
+# -----------------------------------------------------------------------
+
+voltha-release-mk-targets := $(NULL)
+voltha-release-mk-targets += create-jobs-release
+voltha-release-mk-targets += create-jobs-release-certification
+voltha-release-mk-targets += create-jobs-release-nightly
+voltha-release-mk-targets += create-jobs-release-units
+voltha-release-mk-targets += sterile-create-jobs-release
+
+# -----------------------------------------------------------------------
+# Define a flag to only load release targets when mentioned by name
+# Makefile can also explicitly define the flag to force always loading.
+# -----------------------------------------------------------------------
+$(foreach tgt,$(voltha-release-mk-targets),\
+ $(if $(findstring $(tgt),$(MAKECMDGOALS)),$(eval USE_VOLTHA_RELEASE_MK := true))\
+)
+
+# [EOF]
diff --git a/makefiles/release/targets.mk b/makefiles/release/targets.mk
new file mode 100644
index 0000000..b201998
--- /dev/null
+++ b/makefiles/release/targets.mk
@@ -0,0 +1,86 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+# Intent: Helper makefile target used to setup for a release
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+
+# TODO: Library function $(call mk-path,makefiles/release/targets.mk)
+release-mk-top := $(abspath $(lastword $(MAKEFILE_LIST)))
+release-mk-top := $(subst /makefiles/release/targets.mk,$(null),$(release-mk-top))
+
+GIT ?= /usr/bin/env git
+
+##--------------------##
+##---] INCLUDES [---##
+##--------------------##
+include $(ONF_MAKEDIR)/release/voltha-versions.mk
+include $(ONF_MAKEDIR)/release/targets/voltha-certification.mk
+include $(ONF_MAKEDIR)/release/targets/voltha-e2e.mk
+include $(ONF_MAKEDIR)/release/targets/voltha-nightly-jobs.mk
+
+# last-release := voltha-2.11
+last-release := $(voltha-release-last)
+
+
+##-------------------##
+##---] TARGETS [---##
+##-------------------##
+all: help
+
+## ---------------------------------------------------------------------------
+## Intent: Build these deps to create a new branch/release area
+## ---------------------------------------------------------------------------
+create-jobs-release += create-jobs-release-bat
+create-jobs-release += create-jobs-release-certification
+create-jobs-release += create-jobs-release-nightly
+create-jobs-release += create-jobs-release-units
+create-jobs-release += create-jobs-release-e2e
+
+create-jobs-release : $(create-jobs-release)
+
+ @echo
+ $(GIT) status
+
+## ---------------------------------------------------------------------------
+## Intent: Create branch driven pipeline test jobs.
+## ---------------------------------------------------------------------------
+units-yaml := $(release-mk-top)/jjb/pipeline/voltha/$(voltha-version)
+units-root := $(subst /$(voltha-version),$(null),$(units-yaml))
+create-jobs-release-units : $(units-yaml)
+$(units-yaml):
+
+ @echo
+ @echo "** Create branch driven pipeline: unit tests"
+ $(HIDE)mkdir -vp $@
+ rsync -r --checksum $(units-root)/master/. $@/.
+ $(HIDE)/bin/ls -l $(units-root)
+
+## ---------------------------------------------------------------------------
+## Intent: Create branch driven nightly test jobs.
+## ---------------------------------------------------------------------------
+sterile-create-jobs-release := $(addprefix sterile-,$(create-jobs-release))
+sterile-create-jobs-release : $(sterile-create-jobs-release)
+ $(RM) -r $(units-yaml)
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/release/targets/voltha-certification.mk b/makefiles/release/targets/voltha-certification.mk
new file mode 100644
index 0000000..55e4f1a
--- /dev/null
+++ b/makefiles/release/targets/voltha-certification.mk
@@ -0,0 +1,56 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+# Intent: Helper makefile target used to setup for a release
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## ---------------------------------------------------------------------------
+## Intent: Create branch driven nightly test jobs.
+## o Clone config for the last nightly release
+## o In-place edit to the latest version.
+## ---------------------------------------------------------------------------
+## NOTE: WIP - nightly jobs have not yet migrated from the mega job config file
+## ---------------------------------------------------------------------------
+certification-dir := $(release-mk-top)/jjb/voltha-test/voltha-certification
+certification-yaml := $(certification-dir)/$(voltha-version).yaml
+certification-tmpl := $(certification-dir)/$(voltha-release-last).yaml
+
+create-jobs-release-certification : $(certification-yaml)
+$(certification-yaml) : $(certification-tmpl)
+
+ @echo
+ @echo "** Create branch driven pipeline: nightly tests"
+ sed -e 's/$(last-release)/$(voltha-version)/g' $< > $@
+ $(HIDE)/bin/ls -l $(dir $@)
+
+## ---------------------------------------------------------------------------
+## Intent: Create branch driven nightly test jobs.
+## ---------------------------------------------------------------------------
+$(certification-tmpl):
+ @echo "ERROR: Yaml template branch does not exist: $@"
+ @echo 1
+
+## ---------------------------------------------------------------------------
+## Intent: Create branch driven nightly test jobs.
+## ---------------------------------------------------------------------------
+sterile-create-jobs-release-certification :
+ $(RM) $(certification-yaml)
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/release/targets/voltha-e2e.mk b/makefiles/release/targets/voltha-e2e.mk
new file mode 100644
index 0000000..40e7c5d
--- /dev/null
+++ b/makefiles/release/targets/voltha-e2e.mk
@@ -0,0 +1,56 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+# Intent: Helper makefile target used to setup for a release
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## ---------------------------------------------------------------------------
+## Intent: Create branch driven nightly test jobs.
+## o Clone config for the last nightly release
+## o In-place edit to the latest version.
+## ---------------------------------------------------------------------------
+## NOTE: WIP - nightly jobs have not yet migrated from the mega job config file
+## ---------------------------------------------------------------------------
+voltha-e2e-dir := $(release-mk-top)/jjb/voltha-e2e
+voltha-e2e-yaml := $(voltha-e2e-dir)/$(voltha-version).yaml
+voltha-e2e-tmpl := $(voltha-e2e-dir)/$(voltha-release-last).yaml
+
+create-jobs-release-e2e : $(voltha-e2e-yaml)
+$(voltha-e2e-yaml) : $(voltha-e2e-tmpl)
+
+ @echo
+ @echo "** Create branch driven pipeline: nightly tests"
+ sed -e 's/$(last-release)/$(voltha-version)/g' $< > $@
+ $(HIDE)/bin/ls -l $(dir $@)
+
+## ---------------------------------------------------------------------------
+## Intent: Create branch driven nightly test jobs.
+## ---------------------------------------------------------------------------
+$(voltha-e2e-tmpl):
+ @echo "ERROR: Yaml template branch does not exist: $@"
+ @echo 1
+
+## ---------------------------------------------------------------------------
+## Intent: Create branch driven nightly test jobs.
+## ---------------------------------------------------------------------------
+sterile-create-jobs-release-e2e :
+ $(RM) $(voltha-e2e-yaml)
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/release/targets/voltha-nightly-jobs.mk b/makefiles/release/targets/voltha-nightly-jobs.mk
new file mode 100644
index 0000000..20e37de
--- /dev/null
+++ b/makefiles/release/targets/voltha-nightly-jobs.mk
@@ -0,0 +1,54 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+# Intent: Helper makefile target used to setup for a release
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+
+## ---------------------------------------------------------------------------
+## Intent: Create branch driven nightly test jobs.
+## o Clone config for the last nightly release
+## o In-place edit to the latest version.
+## ---------------------------------------------------------------------------
+## NOTE: WIP - nightly jobs have not yet migrated from the mega job config file
+## ---------------------------------------------------------------------------
+voltha-nightly-dir := $(release-mk-top)/jjb/voltha-test/voltha-nightly-jobs
+voltha-nightly-yaml := $(voltha-nightly-dir)/$(voltha-version).yaml
+voltha-nightly-tmpl := $(voltha-nightly-dir)/$(voltha-release-last).yaml
+
+create-jobs-release-nightly : $(voltha-nightly-yaml)
+$(voltha-nightly-yaml) : $(voltha-nightly-tmpl)
+
+ @echo
+ @echo "** Create branch driven pipeline: nightly tests"
+ sed -e 's/$(last-release)/$(voltha-version)/g' $< > $@
+ $(HIDE)/bin/ls -l $(dir $@)
+
+## ---------------------------------------------------------------------------
+## Intent: Create branch driven nightly test jobs.
+## ---------------------------------------------------------------------------
+$(voltha-nightly-tmpl):
+ @echo "ERROR: Yaml template branch does not exist: $@"
+ @echo 1
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/release/voltha-versions.mk b/makefiles/release/voltha-versions.mk
new file mode 100644
index 0000000..a6ab7b6
--- /dev/null
+++ b/makefiles/release/voltha-versions.mk
@@ -0,0 +1,44 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+# Intent: Helper makefile target used to setup for a release
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+voltha-versions += master
+voltha-versions += voltha-2.12
+voltha-versions += voltha-2.11
+voltha-versions += voltha-2.8
+voltha-versions += playground
+
+# VOLTHA: release
+# active : $(words 0,$(voltha-versions))
+# next : $(words 1,$(voltha-versions))
+# last : $(words 2,$(voltha-versions))
+
+# fatal to make help (param is null)
+voltha-version ?= $(error $(MAKE) voltha-verison=voltha-x.yy is required)\
+
+voltha-release-this := $(word 1,$(voltha-versions))
+voltha-release-last := $(word 2,$(voltha-versions))
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]