Skip to content

Commit

Permalink
Add GHA for staticcheck and address lint issues (#102)
Browse files Browse the repository at this point in the history
Signed-off-by: Arrobo, Gabriel <gabriel.arrobo@intel.com>
  • Loading branch information
gab-arrobo authored Aug 21, 2024
1 parent f492fff commit 40dff8c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
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/setup-go-faster@v1.14.0
with:
go-version-file: 'go.mod'

- uses: dominikh/staticcheck-action@v1.3.1
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

0 comments on commit 40dff8c

Please sign in to comment.