diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..d6382b2461 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Intel Corporation + +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + + - package-ecosystem: "docker" + directory: "docker" + schedule: + interval: "weekly" diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000000..2375ed36ca --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Intel Corporation + +name: Build and test workflow +on: + pull_request: + branches: + - develop-onf + push: + branches: + - develop-onf + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: build + run: make build + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - 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 0000000000..1b2d37d23f --- /dev/null +++ b/.github/workflows/code-scan.yml @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Intel Corporation + +name: Code scan workflow + +on: + pull_request: + branches: + - develop-onf + push: + branches: + - develop-onf + +jobs: + version-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: check version + run: make check-version + 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 0000000000..e86590eca2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,133 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Intel Corporation +# Copyright 2024 Kyunghee University +name: Publish image and tag/release code + +on: + push: + branches: + - develop-onf + +jobs: + version-check: + if: (github.repository_owner == 'onosproject') + runs-on: ubuntu-latest + outputs: + valid_version: ${{ steps.version-check-step.outputs.valid_version }} + dev_version: ${{ steps.dev-version-check-step.outputs.dev_version }} + target_version: ${{ steps.get-target-version-step.outputs.target_version }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: check version + id: version-check-step + run: | + make check-version; if [[ $? == 0 ]]; then echo "valid_version=true" >> $GITHUB_OUTPUT; else echo "valid_version=false" >> $GITHUB_OUTPUT; fi + cat $GITHUB_OUTPUT + + - name: check dev version + id: dev-version-check-step + run: | + f_dev=$(./build/bin/version_check.sh is_dev) + if [[ $f_dev == "true" ]]; then echo "dev_version=true" >> $GITHUB_OUTPUT; else echo "dev_version=false" >> $GITHUB_OUTPUT; fi + cat $GITHUB_OUTPUT + + - name: get target version + id: get-target-version-step + run: | + echo "target_version=$(cat VERSION)" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT + + tag_versions: + runs-on: ubuntu-latest + needs: version-check + if: (github.repository_owner == 'onosproject') && (needs.version-check.outputs.valid_version == 'true') && (needs.version-check.outputs.dev_version == 'false') + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: create release using REST API + run: | + 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": "v${{ needs.version-check.outputs.target_version }}", + "target_commitish": "${{ github.event.repository.default_branch }}", + "name": "v${{ needs.version-check.outputs.target_version }}", + "draft": false, + "prerelease": false, + "generate_release_notes": true + }' + + publish-images: + runs-on: ubuntu-latest + needs: version-check + if: (github.repository_owner == 'onosproject') && (needs.version-check.outputs.valid_version == 'true') + env: + REGISTRY: docker.io + DOCKER_REPOSITORY: onosproject/ + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - uses: docker/login-action@v3.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push Docker image with tag latest + env: + DOCKER_TAG: latest + run: | + OAI_ALL_VERSION=${{ env.DOCKER_TAG }} make docker-build + OAI_ALL_VERSION=${{ env.DOCKER_TAG }} make docker-push + - name: Build and push Docker image with tag + if: needs.version-check.outputs.dev_version == 'false' + env: + DOCKER_TAG: v${{ needs.version-check.outputs.target_version }} + run: | + OAI_ALL_VERSION=${{ env.DOCKER_TAG }} make docker-build + OAI_ALL_VERSION=${{ env.DOCKER_TAG }} make docker-push + + bump-up-version: + runs-on: ubuntu-latest + needs: version-check + if: (github.repository_owner == 'onosproject') && (needs.version-check.outputs.valid_version == 'true') && (needs.version-check.outputs.dev_version == 'false') + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: increment version + run: | + IFS='.' read -r major minor patch <<< ${{ needs.version-check.outputs.target_version }} + patch_update=$((patch+1)) + NEW_VERSION="$major.$minor.$patch_update-dev" + echo $NEW_VERSION > VERSION + echo "Updated version: $NEW_VERSION" + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GH_ONOS_PAT }} + commit-message: Update version + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> + signoff: true + branch: version-update + delete-branch: true + title: Update version + body: | + Update VERSION file + add-paths: | + VERSION \ No newline at end of file diff --git a/.gitignore b/.gitignore index 64e82352e8..57e56e3a7e 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ targets/bin/ *coverage*.xml *-output.out +.vscode \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 6757ed47f6..0000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "(gdb) Launch", - "type": "cppdbg", - "request": "launch", - "program": "enter program name, for example ${workspaceFolder}/a.exe", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "miDebuggerPath": "/path/to/gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ] - } - ] -} \ No newline at end of file diff --git a/Makefile b/Makefile index 796cdc0a0f..0c56db9c4f 100644 --- a/Makefile +++ b/Makefile @@ -1,67 +1,93 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2019 Open Networking Foundation +# Copyright 2024 Intel Corporation -BUILD_BASE_VERSION := latest -OAI_ALL_VERSION := latest +OAI_ALL_VERSION ?= latest -all: images test +all: build docker-build + +build: # @HELP build all OAI code +build: docker-build-oai-all docker-build-oai-ue docker-build-oai-enb docker-build-oai-enb-cu docker-build-oai-enb-du test: $(info No tests exist yet) -images: oai-all oai-ue oai-enb oai-enb-cu oai-enb-du - .PHONY: oai-build-base oai-ue oai-enb oai-enb-cu oai-enb-du -oai-build-base: +docker-build-oai-build-base: # @HELP build oai build base image docker build . -f docker/oai-build-base/Dockerfile \ - -t onosproject/oai-build-base:${BUILD_BASE_VERSION} + -t onosproject/oai-build-base:${OAI_ALL_VERSION} -oai-all: +docker-build-oai-all: # @HELP build oai all image docker build . -f docker/oai-all/Dockerfile \ - --build-arg BUILD_BASE_VERSION=${BUILD_BASE_VERSION} \ + --build-arg OAI_ALL_VERSION=${OAI_ALL_VERSION} \ -t onosproject/oai-all:${OAI_ALL_VERSION} -oai-ue: +docker-build-oai-ue: # @HELP build oai ue image docker build . -f docker/oai-ue/Dockerfile \ --build-arg OAI_ALL_VERSION=${OAI_ALL_VERSION} \ -t onosproject/oai-ue:${OAI_ALL_VERSION} -docker rmi $$(docker images -q -f "dangling=true" -f "label=autodelete=true") -oai-enb: +docker-build-oai-enb: # @HELP build oai enb image docker build . -f docker/oai-enb/Dockerfile \ - --build-arg BUILD_BASE_VERSION=${BUILD_BASE_VERSION} \ + --build-arg OAI_ALL_VERSION=${OAI_ALL_VERSION} \ -t onosproject/oai-enb:${OAI_ALL_VERSION} -docker rmi $$(docker images -q -f "dangling=true" -f "label=autodelete=true") -oai-enb-cu: +docker-build-oai-enb-cu: # @HELP build oai enb cu image docker build . -f docker/oai-enb-cu/Dockerfile \ - --build-arg BUILD_BASE_VERSION=${BUILD_BASE_VERSION} \ + --build-arg OAI_ALL_VERSION=${OAI_ALL_VERSION} \ -t onosproject/oai-enb-cu:${OAI_ALL_VERSION} -docker rmi $$(docker images -q -f "dangling=true" -f "label=autodelete=true") -oai-enb-du: +docker-build-oai-enb-du: # @HELP build oai enb du image docker build . -f docker/oai-enb-du/Dockerfile \ - --build-arg BUILD_BASE_VERSION=${BUILD_BASE_VERSION} \ + --build-arg OAI_ALL_VERSION=${OAI_ALL_VERSION} \ -t onosproject/oai-enb-du:${OAI_ALL_VERSION} -docker rmi $$(docker images -q -f "dangling=true" -f "label=autodelete=true") -dev-base: - docker build . -f docker/dev/base/Dockerfile -t oai-enb-cu-base:latest --rm=false +docker-build: # @HELP build all Docker images +docker-build: build -dev: - docker build . -f docker/dev/Dockerfile -t onosproject/oai-enb-cu:latest --rm=false +docker-push-oai-build-base: # @HELP push oai build base image + docker build . -f docker/oai-build-base/Dockerfile \ + -t onosproject/oai-build-base:${OAI_ALL_VERSION} -build-tools: # @HELP install the ONOS build tools if needed - @if [ ! -d "../build-tools" ]; then cd .. && git clone https://github.com/onosproject/build-tools.git; fi +docker-push-oai-all: # @HELP push oai all image + docker build . -f docker/oai-all/Dockerfile \ + --build-arg OAI_ALL_VERSION=${OAI_ALL_VERSION} \ + -t onosproject/oai-all:${OAI_ALL_VERSION} -jenkins-tools: # @HELP installs tooling needed for Jenkins - cd .. && go get -u github.com/jstemmer/go-junit-report && go get github.com/t-yuki/gocover-cobertura +docker-push-oai-ue: # @HELP push oai ue image + docker build . -f docker/oai-ue/Dockerfile \ + --build-arg OAI_ALL_VERSION=${OAI_ALL_VERSION} \ + -t onosproject/oai-ue:${OAI_ALL_VERSION} + -docker rmi $$(docker images -q -f "dangling=true" -f "label=autodelete=true") -jenkins-test: images build-tools jenkins-tools - TEST_PACKAGES=NONE ./../build-tools/build/jenkins/make-unit +docker-push-oai-enb: # @HELP push oai enb image + docker build . -f docker/oai-enb/Dockerfile \ + --build-arg OAI_ALL_VERSION=${OAI_ALL_VERSION} \ + -t onosproject/oai-enb:${OAI_ALL_VERSION} + -docker rmi $$(docker images -q -f "dangling=true" -f "label=autodelete=true") + +docker-push-oai-enb-cu: # @HELP push oai enb cu image + docker build . -f docker/oai-enb-cu/Dockerfile \ + --build-arg OAI_ALL_VERSION=${OAI_ALL_VERSION} \ + -t onosproject/oai-enb-cu:${OAI_ALL_VERSION} + -docker rmi $$(docker images -q -f "dangling=true" -f "label=autodelete=true") + +docker-push-oai-enb-du: # @HELP push oai enb du image + docker build . -f docker/oai-enb-du/Dockerfile \ + --build-arg OAI_ALL_VERSION=${OAI_ALL_VERSION} \ + -t onosproject/oai-enb-du:${OAI_ALL_VERSION} + -docker rmi $$(docker images -q -f "dangling=true" -f "label=autodelete=true") -publish: # @HELP publish version on github and dockerhub - ./../build-tools/publish-version ${VERSION} onosproject/oai-ue onosproject/oai-enb onosproject/oai-enb-cu onosproject/oai-enb-du +docker-push: # @HELP push docker images +docker-push: docker-push-oai-all docker-push-oai-ue docker-push-oai-enb docker-push-oai-enb-cu docker-push-oai-enb-du -jenkins-publish: build-tools jenkins-tools - ./build/bin/push-images - BASE_BRANCH=develop-onf ../build-tools/release-merge-commit +dev-base: + docker build . -f docker/dev/base/Dockerfile -t oai-enb-cu-base:latest --rm=false + +dev: + docker build . -f docker/dev/Dockerfile -t onosproject/oai-enb-cu:latest --rm=false diff --git a/README.md b/README.md index 2f3426cfc2..78fffdce0b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The RIC Agent is an ONF addition to OAI that adds support for interfacing the OA $ cd openairinterface5g $ source oaienv $ cd cmake_targets -$ ./build_oai -c -I --eNB --UE -w USRP -g --build-ric-agent +$ ./build_oai -c -I --eNB --UE -w USRP -g --build-ric-agent --build-ran-slicing ``` The top-level *Makefile* builds docker images that include the RIC Agent: diff --git a/build/bin/push-images b/build/bin/push-images deleted file mode 100755 index 713962af8d..0000000000 --- a/build/bin/push-images +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e - -echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USER" --password-stdin -docker push onosproject/oai-ue:latest -docker push onosproject/oai-enb:latest -docker push onosproject/oai-enb-cu:latest -docker push onosproject/oai-enb-du:latest - diff --git a/build/bin/version_check.sh b/build/bin/version_check.sh new file mode 100755 index 0000000000..feabddbda5 --- /dev/null +++ b/build/bin/version_check.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Intel Corporation + +set +x + +# input should be all, is_valid_format, is_dev, and is_unique +INPUT=$1 + +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 [[ ! $(cat VERSION | tr -d '\n' | sed s/-dev//) =~ $VER_REGEX ]] + then + return 1 + fi + return 0 +} + +function is_dev_version() { + # check if version has '-dev' + # if there is, no need to check version + if [[ $(cat VERSION | tr -d '\n' | tail -c 4) =~ "-dev" ]] + then + return 0 + fi + return 1 +} + +function is_unique_version() { + # check if the version is already tagged in GitHub repository + for t in $(git tag | cat) + do + if [[ $t == $(echo v$(cat VERSION | tr -d '\n')) ]] + then + return 1 + fi + done + return 0 +} + +case $INPUT in + all) + is_valid_format + f_valid=$? + if [[ $f_valid == 1 ]] + then + echo "ERROR: Version $(cat VERSION) is not in SemVer format" + exit 2 + fi + + is_dev_version + f_dev=$? + if [[ $f_dev == 0 ]] + then + echo "This is dev version" + exit 0 + fi + + is_unique_version + f_unique=$? + if [[ $f_unique == 1 ]] + then + echo "ERROR: duplicated tag $(cat VERSION)" + exit 2 + fi + ;; + + is_valid_format) + is_valid_format + ;; + + is_dev) + is_dev_version + f_dev=$? + if [[ $f_dev == 0 ]] + then + echo "true" + exit 0 + fi + echo "false" + ;; + + is_unique) + is_unique_version + ;; + + *) + echo -n "unknown input" + exit 2 + ;; + +esac