diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000..393b6f9e --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Intel Corporation + +name: Build and test workflow +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Helm + uses: azure/setup-helm@v4 + with: + version: latest + token: ${{ secrets.GH_ONOS_PAT }} + - name: build + run: make deps + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Unit tests + run: make test diff --git a/.github/workflows/code-scan.yml b/.github/workflows/code-scan.yml new file mode 100644 index 00000000..44129197 --- /dev/null +++ b/.github/workflows/code-scan.yml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Intel Corporation + +name: Code scan workflow + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + version-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: check version + run: | + sudo snap install yq + export COMPARISON_BRANCH=origin/master + git branch -a + make check-version + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: helm-lint + run: make lint + license: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: check license + run: make license + fossa-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: FOSSA scan + uses: fossa-contrib/fossa-action@v3 + with: + fossa-api-key: 6d304c09a3ec097ba4517724e4a4d17d diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..a73f940d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,99 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Intel Corporation +# Copyright 2024 Kyunghee University +name: Publish image and tag/release code + +on: + push: + branches: + - master + +jobs: + version-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: chrisdickinson/setup-yq@latest + - name: check version + run: | + sudo snap install yq + export COMPARISON_BRANCH=${{ github.event.before }} + make check-version + + tag_versions: + runs-on: ubuntu-latest + needs: version-check + if: github.repository_owner == 'onosproject' + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: create release using REST API + run: | + sudo snap install yq + target_charts=$(./build/bin/version_check.sh get_changed_charts) + for tc in $target_charts) + do + tc_ver=$(yq e '.version' ${tc}/Chart.yaml) + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GH_ONOS_PAT }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/releases \ + -d '{ + "tag_name": "$tc-$tc_ver", + "target_commitish": "${{ github.event.repository.default_branch }}", + "name": "$tc-$tc_ver", + "draft": false, + "prerelease": false, + "generate_release_notes": true + }' + done + + publish-charts: + runs-on: ubuntu-latest + needs: version-check + if: (github.repository_owner == 'onosproject') && (needs.version-check.outputs.valid_version == 'true') + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Helm + uses: azure/setup-helm@v4 + with: + version: latest + token: ${{ secrets.GH_ONOS_PAT }} + - name: build + run: make deps + - name: publish charts + run: | + export COMPARISON_BRANCH=${{ github.event.before }} + sudo snap install yq rsync + target_charts=$(./build/bin/version_check.sh get_changed_charts) + rm -rf staging && mkdir -p staging/onos-helm-charts + while IFS= read -r tc + do + mkdir -p staging/onos-helm-charts/$tc + tc_ver=$(yq e '.version' $tc/Chart.yaml) + helm package $tc --destination staging/onos-helm-charts/$tc + done <<< $target_charts + cd staging + curl -o current-index.yaml https://sdrancharts.onosproject.org/index.yaml + helm repo index onos-helm-charts --url https://sdrancharts.onosproject.org/onos-helm-charts --merge current-index.yaml + rm -rf current-index.yaml + mv onos-helm-charts/index.yaml . + cd .. + chmod -R g+r staging/ + - name: rsync deployments + uses: burnett01/rsync-deployments@7.0.1 + with: + switches: -rvzh + path: staging/ + remote_path: /srv/sites/sdrancharts.onosproject.org + remote_host: static.opennetworking.org + remote_user: ${{ secrets.JENKINS_USERNAME }} + remote_key: ${{ secrets.JENKINS_SSHKEY }} + remote_key_pass: ${{ secrets.JENKINS_PASSPHRASE }} diff --git a/.gitignore b/.gitignore index ee79231e..07e84781 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ build/release build/_output build/build-tools + +venv +*.tgz +staging \ No newline at end of file diff --git a/Makefile b/Makefile index 3ea60648..9b2f8e56 100644 --- a/Makefile +++ b/Makefile @@ -2,33 +2,20 @@ # # SPDX-License-Identifier: Apache-2.0 -.PHONY: all test clean +.PHONY: all test clean version-check -all: test +COMPARISON_BRANCH ?= master -build-tools:=$(shell if [ ! -d "./build/build-tools" ]; then cd build && git clone https://github.com/onosproject/build-tools.git; fi) -include ./build/build-tools/make/onf-common.mk +all: dep -jenkins-test: jenkins_version_check license deps # @HELP run the jenkins verification tests - docker pull quay.io/helmpack/chart-testing:v2.4.0 - docker run --rm --name ct --volume `pwd`:/charts quay.io/helmpack/chart-testing:v3.0.0-beta.1 sh -c "ct lint --charts charts/onos-e2t,charts/ran-simulator,charts/onos-kpimon --debug --validate-maintainers=false" +lint: # @HELP run helm lint + ./build/bin/helm_lint.sh -jenkins_version_check: # @HELP run the version checker on the charts - export COMPARISON_BRANCH=origin/master && export WORKSPACE=`pwd` && ./build/build-tools/chart_version_check - -version_check: # @HELP run the version checker on the charts - COMPARISON_BRANCH=master ./build/build-tools/chart_version_check +check-version: # @HELP run the version checker on the charts + COMPARISON_BRANCH=${COMPARISON_BRANCH} ./build/bin/version_check.sh all test: # @HELP run the integration tests -test: license version_check deps - ./build/bin/run-sd-ran-test - -publish: # @HELP publish version on sdrancharts.onosproject.org - ./build/build-tools/publish-version ${VERSION} - -jenkins-publish: # @HELP publish version on github - cd .. && GO111MODULE=on go install github.com/mikefarah/yq/v4@v4.16.2 - ./build/build-tools/release-chart-merge-commit https://sdrancharts.onosproject.org ${WEBSITE_USER} ${WEBSITE_PASSWORD} +test: deps license lint clean:: # @HELP clean up temporary files for SD-RAN umbrella. rm -rf sd-ran/charts sd-ran/Chart.lock @@ -36,3 +23,19 @@ clean:: # @HELP clean up temporary files for SD-RAN umbrella. deps: # @HELP build dependencies for SD-RAN Umbrella local charts. deps: clean helm dep build sd-ran + +license: # @HELP run license checks + rm -rf venv + python3 -m venv venv + . ./venv/bin/activate;\ + python3 -m pip install --upgrade pip;\ + python3 -m pip install reuse;\ + reuse lint + + +publish: # @HELP publish version on sdrancharts.onosproject.org + ./build/build-tools/publish-version ${VERSION} + +jenkins-publish: # @HELP publish version on github + cd .. && GO111MODULE=on go install github.com/mikefarah/yq/v4@v4.16.2 + ./build/build-tools/release-chart-merge-commit https://sdrancharts.onosproject.org ${WEBSITE_USER} ${WEBSITE_PASSWORD} \ No newline at end of file diff --git a/build/bin/helm_lint.sh b/build/bin/helm_lint.sh new file mode 100755 index 00000000..b3bda48f --- /dev/null +++ b/build/bin/helm_lint.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Intel Corporation + +exit_code=0 + +for dir in $(find . -maxdepth 1 -mindepth 1 -type d); do + if [[ -f "$dir/Chart.yaml" ]]; then + helm lint "$dir" + if [ $? == 1 ] + then + exit_code=2 + fi + fi +done +exit $exit_code \ No newline at end of file diff --git a/build/bin/run-sd-ran-test b/build/bin/run-sd-ran-test deleted file mode 100755 index 76e43c7f..00000000 --- a/build/bin/run-sd-ran-test +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# SPDX-FileCopyrightText: 2020-present Open Networking Foundation -# -# SPDX-License-Identifier: Apache-2.0 - -# Copyright 2020-present Open Networking Foundation. -# -# 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. -# -# Script to build and run all of the onos integration tests - -set -eu -o pipefail - -chart_dir=$(mktemp -d) - -cp -R ../onos-helm-charts/* ${chart_dir} -cp -R ../sdran-helm-charts/* ${chart_dir} - -kubectl delete ns sd-ran || true -kubectl create ns sd-ran -helmit test -n sd-ran ./test -c ${chart_dir} --suite sd-ran -kubectl delete ns sd-ran - -rm -rf ${chart_dir} - diff --git a/build/bin/version_check.sh b/build/bin/version_check.sh new file mode 100755 index 00000000..ccb6f4d2 --- /dev/null +++ b/build/bin/version_check.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Intel Corporation + +INPUT=$1 + +COMPARISON_BRANCH="${COMPARISON_BRANCH:-master}" + +function is_valid_format() { + # check if version format is matched to SemVer + VER_REGEX='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$' + if [[ ! $(echo $1 | tr -d '\n' | sed s/-dev//) =~ $VER_REGEX ]] + then + echo Version $1 is not in SemVer + return 1 + fi + return 0 +} + +function get_changed_charts() { + while IFS= read -r -d '' chart + do + chart_dir=$(dirname $chart) + chart_dir=$(basename $chart_dir) + chart_diff=$(git diff -p $COMPARISON_BRANCH --name-only ./$chart_dir) + if [ -n "$chart_diff" ] + then + echo $chart_dir + fi + done < <(find . -name Chart.yaml -print0) +} + +function is_unique_version() { + echo "comparison branch $COMPARISON_BRANCH" + + while IFS= read -r -d '' chart + do + chart_dir=$(dirname $chart) + chart_dir=$(basename $chart_dir) + chart_diff=$(git diff -p $COMPARISON_BRANCH --name-only ./$chart_dir) + + if [ -n "$chart_diff" ] + then + chart_ver=$(yq e '.version' ${chart_dir}/Chart.yaml) + + is_valid_format $chart_ver + if [ $? == 1 ] + then + echo $chart_dir does not have SemVer formatted version $chart_ver + return 1 + fi + + for t in $(git tag | grep $chart_dir | cat) + do + pure_t=$(echo $t | sed s/$chart_dir-//) + if [ "$pure_t" == "$chart_ver" ] + then + echo Chart $chart_dir version duplicated $chart_ver=$pure_t + return 1 + fi + done + fi + done < <(find . -name Chart.yaml -print0) + return 0 +} + +case $INPUT in + all) + is_unique_version + ;; + + get_changed_charts) + get_changed_charts + ;; + + *) + echo -n "unknown input" + exit 2 + ;; +esac + diff --git a/onos-pci/Chart.yaml b/onos-pci/Chart.yaml index eb50ffa3..200cdb67 100644 --- a/onos-pci/Chart.yaml +++ b/onos-pci/Chart.yaml @@ -8,7 +8,7 @@ name: onos-pci description: ONOS PCI xAPP kubeVersion: ">=1.17.0" type: application -version: 0.9.11 +version: 0.9.12 appVersion: v0.4.10 keywords: - onos diff --git a/sd-ran/Chart.yaml b/sd-ran/Chart.yaml index 52e9f2fa..20cb5f3f 100644 --- a/sd-ran/Chart.yaml +++ b/sd-ran/Chart.yaml @@ -8,7 +8,7 @@ name: sd-ran description: Umbrella chart to deploy all ONOS-RIC and simulator kubeVersion: ">=1.17.0" type: application -version: 1.4.135 +version: 1.4.136 appVersion: v1.5.0 keywords: - onos @@ -62,7 +62,7 @@ dependencies: - name: onos-pci condition: import.onos-pci.enabled repository: file://../onos-pci - version: 0.9.11 + version: 0.9.12 - name: onos-mho condition: import.onos-mho.enabled repository: file://../onos-mho