diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8b976c2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2022 Intel Corporation + +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..16a125d --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2022 Intel Corporation +name: Docker image + +on: + push: + branches: + - master + tags: + - v* + +jobs: + build: + runs-on: ubuntu-latest + steps: + # Checkout and build + - uses: actions/checkout@v3 + - name: Build and push Docker image + run: | + make docker-build + +# push-dockerhub: +# env: +# DOCKER_REGISTRY: "docker.io/" +# DOCKER_REPOSITORY: "badhrinathpa/" +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# +# - run: echo GIT_SHA_SHORT=$(git rev-parse --short HEAD) >> $GITHUB_ENV +# +# - id: docker-login +# uses: docker/login-action@v2.1.0 +# with: +# registry: docker.io +# username: ${{ secrets.DOCKER_HUB_LOGIN }} +# password: ${{ secrets.DOCKER_HUB_PASSWORD }} +# +# - name: Build and push "master-latest" Docker images +# env: +# DOCKER_TAG: master-${{ env.GIT_SHA_SHORT } +# run: | +# make docker-build +# make docker-push + diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..0cdc505 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2022 Intel Corporation +name: golangci-lint +on: + push: + tags: + - v* + branches: + - master + pull_request: +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3.2.0 + with: + version: latest + args: -v --config ./.golangci.yml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..763597d --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2022 Intel Corporation +name: Pull Request + +on: [pull_request] + +concurrency: + group: ${{ github.event.pull_request.number }} + cancel-in-progress: true + + +jobs: + build: + #env: + # DOCKER_REGISTRY: "docker.io/" + # DOCKER_REPOSITORY: "badhrinathpa/" + # VERSION: "PR-${{ github.event.pull_request.number }}" + runs-on: ubuntu-latest + steps: + # Checkout and build + - uses: actions/checkout@v3 + + - name: Build Docker image + run: | + make docker-build + # Format the code + - name: Go Format + run: | + make fmt + + - name: Show all CI changes + run: | + git --no-pager diff + + # Build again and commit + - name: Build Docker image after format + run: | + make docker-build + - name: Update PR with changes + uses: gr2m/create-or-update-pull-request-action@v1.x + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + body: | + Updated with changes from CI + branch: ${{ github.event.pull_request.head.ref }} + author: "Github Actions " + commit-message: "Actions: Updated with changes from CI" diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml new file mode 100644 index 0000000..c81b7ed --- /dev/null +++ b/.github/workflows/reuse.yml @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2022 Intel Corporation +--- +name: REUSE + +on: + push: + branches: + - master + pull_request: + +jobs: + license-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: reuse lint + run: make check-reuse diff --git a/.github/workflows/run-udm-unit-test.yml b/.github/workflows/run-udm-unit-test.yml new file mode 100644 index 0000000..bf2905a --- /dev/null +++ b/.github/workflows/run-udm-unit-test.yml @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2022 Intel Corporation + +name: Unit tests + +on: + push: + branches: + - master + pull_request: + +jobs: + unit-test-pfcpiface: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + + - name: Run unit tests for UDM + run: | + make test diff --git a/.golangci.yml b/.golangci.yml index f6972aa..a2a4d69 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -224,10 +224,7 @@ linters: - staticcheck - unused - gosimple - - structcheck - - varcheck - ineffassign - - deadcode - typecheck # Additional - lll diff --git a/Makefile b/Makefile index deb8c15..2c8db71 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ -# Copyright 2019 free5GC.org -# # SPDX-License-Identifier: Apache-2.0 -# +# Copyright 2019 free5GC.org +# Copyright 2022 Intel Corporation # PROJECT_NAME := sdcore @@ -81,3 +80,28 @@ docker-push: for target in $(DOCKER_TARGETS); do \ docker push ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}5gc-$$target:${DOCKER_TAG}; \ done + +.coverage: + rm -rf $(CURDIR)/.coverage + mkdir -p $(CURDIR)/.coverage + +test: .coverage + docker run --rm -v $(CURDIR):/udm -w /udm golang:latest \ + go test \ + -race \ + -failfast \ + -coverprofile=.coverage/coverage-unit.txt \ + -covermode=atomic \ + -v \ + ./ ./... + + +fmt: + @go fmt ./... + +golint: + @docker run --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:latest golangci-lint run -v --config /app/.golangci.yml + +check-reuse: + @docker run --rm -v $(CURDIR):/udm -w /udm omecproject/reuse-verify:latest reuse lint + diff --git a/go.sum b/go.sum index 0588803..1d596ac 100644 --- a/go.sum +++ b/go.sum @@ -172,8 +172,8 @@ github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/omec-project/UeauCommon v1.1.0 h1:ynW22r/Xx/z6saviuzUeNjYlqdJfiMNtNwlv6Ot76Wk= github.com/omec-project/UeauCommon v1.1.0/go.mod h1:brKbJNGvDPgHcubWt6G45hVuxZ2Crdp/1tKXWw6zTCY= -github.com/omec-project/config5g v1.1.0 h1:NwXNSmy08xHBY5uF4iA3cEUVJRw2wKSxwc641FgCz20= -github.com/omec-project/config5g v1.1.0/go.mod h1:AWFzCbbgCBx/iJwt+zWbpDGLHRpFzg24OYHqIkdcMVA= +github.com/omec-project/config5g v1.2.0 h1:fyIg+1LZ9jn8DTkVUbD4jyxA4FgMICdIBwZVnzCyMd4= +github.com/omec-project/config5g v1.2.0/go.mod h1:AWFzCbbgCBx/iJwt+zWbpDGLHRpFzg24OYHqIkdcMVA= github.com/omec-project/http2_util v1.1.0 h1:8H2NME/V8iONth8TlyK/3w4pguAzaeUnEv9pmeAocwQ= github.com/omec-project/http2_util v1.1.0/go.mod h1:QwoZRaUyhEp/kTEqXvf0gCYtfQrNHBdkVw939vsMjZY= github.com/omec-project/http_wrapper v1.1.0 h1:2hD8RUaR/VVg3tUUfuxsuo1/JNpZLiAE8IvATGqDME4= diff --git a/service/init.go b/service/init.go index a81ceb4..2f9b614 100644 --- a/service/init.go +++ b/service/init.go @@ -1,7 +1,7 @@ -// SPDX-FileCopyrightText: 2021 Open Networking Foundation -// Copyright 2019 free5GC.org -// // SPDX-License-Identifier: Apache-2.0 +// Copyright 2019 free5GC.org +// Copyright 2021 Open Networking Foundation +// Copyright 2022 Intel Corporation // package service @@ -378,7 +378,7 @@ func (udm *UDM) BuildAndSendRegisterNFInstance() (models.NfProfile, error) { self := context.UDM_Self() profile, err := consumer.BuildNFInstance(self) if err != nil { - initLog.Error("Build UDM Profile Error: %v", err) + initLog.Error("Build UDM Profile Error: ", err) return profile, err } initLog.Infof("Pcf Profile Registering to NRF: %v", profile) diff --git a/udm.go b/udm.go index 52093d3..03b4958 100644 --- a/udm.go +++ b/udm.go @@ -1,7 +1,6 @@ -// Copyright 2019 free5GC.org -// // SPDX-License-Identifier: Apache-2.0 -// +// Copyright 2022 Intel Corporation +// Copyright 2019 free5GC.org package main