Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GHA for staticcheck and address lint issues #102

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

name: Main workflow
on:
pull_request:
branches:
- main
push:
branches:
- main
pull_request:

jobs:
build:
Expand All @@ -30,6 +32,20 @@ jobs:
- name: Build Docker image
run: make docker-build

staticcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: WillAbides/[email protected]
with:
go-version-file: 'go.mod'

- uses: dominikh/[email protected]
with:
version: latest
install-go: false

lint:
name: lint
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022-present Open Networking Foundation
# Copyright 2024 Intel Corporation
name: GitHub release and Docker images

on:
Expand Down Expand Up @@ -183,7 +184,7 @@ jobs:
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: false
signoff: true
branch: version-update
delete-branch: true
title: Update version
Expand Down
10 changes: 5 additions & 5 deletions internal/pfcpsim/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const (
)

var (
notConnected = errors.New("Not connected")
notAssociated = errors.New("Not associated")
errNotConnected = errors.New("not connected")
errNotAssociated = errors.New("not associated")
)

const SessionStep = 10
Expand Down Expand Up @@ -74,7 +74,7 @@ func (c *PfcpSimCfg) TerminatePFCPSim() error {
func (c *PfcpSimCfg) Associate() error {
switch c.state {
case SVC_INIT:
return notConnected
return errNotConnected
case SVC_CONNECTED:
err := c.sim.SetupAssociation()
if err != nil {
Expand All @@ -90,9 +90,9 @@ func (c *PfcpSimCfg) Associate() error {
func (c *PfcpSimCfg) Deassociate() error {
switch c.state {
case SVC_INIT:
return notConnected
return errNotConnected
case SVC_CONNECTED:
return notAssociated
return errNotAssociated
case SVC_ASSOCIATED:
err := c.sim.TeardownAssociation()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/pfcpsim/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"google.golang.org/grpc/status"
)

var notInit = errors.New("PFCP simulator is not initialized")
var errNotInit = errors.New("PFCP simulator is not initialized")

const (
sdfFilterFormatWPort = "permit out %v from %v to assigned %v-%v"
Expand Down Expand Up @@ -50,7 +50,7 @@ func ConnectPFCPSim() error {

func DisconnectPFCPSim() error {
if sim == nil {
return notInit
return errNotInit
}

return sim.TeardownAssociation()
Expand Down
11 changes: 5 additions & 6 deletions pkg/pfcpsim/pfcpsim.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"sync"
"time"

"github.com/wmnsk/go-pfcp/ie"
ieLib "github.com/wmnsk/go-pfcp/ie"
"github.com/wmnsk/go-pfcp/message"
)
Expand All @@ -25,8 +24,8 @@ const (
var (
activeSessions = make(map[int]*PFCPSession, 0)
lockActiveSessions = new(sync.Mutex)
wrongRspType = errors.New("unexpected response type")
assocFailed = errors.New("association failed")
errWrongRspType = errors.New("unexpected response type")
errAssocFailed = errors.New("association failed")
)

func GetActiveSessionNum() int {
Expand Down Expand Up @@ -304,7 +303,7 @@ func (c *PFCPClient) sendSessionReportResponse(seq uint32, seid uint64) error {
}

res := message.NewSessionReportResponse(0, 0, rseid, seq, 0,
ie.NewCause(ie.CauseRequestAccepted))
ieLib.NewCause(ieLib.CauseRequestAccepted))

return c.sendMsg(res)
}
Expand Down Expand Up @@ -456,7 +455,7 @@ func (c *PFCPClient) SetupAssociation() error {

assocResp, ok := resp.(*message.AssociationSetupResponse)
if !ok {
return NewInvalidResponseError(wrongRspType)
return NewInvalidResponseError(errWrongRspType)
}

cause, err := assocResp.Cause.Cause()
Expand All @@ -465,7 +464,7 @@ func (c *PFCPClient) SetupAssociation() error {
}

if cause != ieLib.CauseRequestAccepted {
return NewInvalidResponseError(assocFailed)
return NewInvalidResponseError(errAssocFailed)
}

c.setAssociationStatus(true)
Expand Down