Skip to content

Commit

Permalink
CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed May 16, 2024
1 parent aa70add commit 7b06819
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 10 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version number
id: version
run: echo "version=$(echo ${{ github.ref_name }} | cut -c2- -)" >> $GITHUB_OUTPUT
- name: Release
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
makeLatest: "legacy"
name: "Version ${{ steps.version.outputs.version }}"
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
go_build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
- name: Test
run: go test ./...
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
exclude: ^.github/.*$
16 changes: 8 additions & 8 deletions pfcp/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"github.com/wmnsk/go-pfcp/message"
)

type handler = func(receivedMessage ReceivedMessage) error
type PFCPMessageHandler = func(receivedMessage ReceivedMessage) error

type PFCPEntity struct {
nodeID *ie.IE
recoveryTimeStamp *ie.IE
handlers map[pfcputil.MessageType]handler
handlers map[pfcputil.MessageType]PFCPMessageHandler
conn *net.UDPConn
connMu sync.Mutex
associationsMap AssociationsMap
Expand Down Expand Up @@ -64,8 +64,8 @@ func (e *PFCPEntity) RecoveryTimeStamp() *ie.IE {
return e.recoveryTimeStamp
}

func newDefaultPFCPEntityHandlers() map[pfcputil.MessageType]handler {
m := make(map[pfcputil.MessageType]handler)
func newDefaultPFCPEntityHandlers() map[pfcputil.MessageType]PFCPMessageHandler {
m := make(map[pfcputil.MessageType]PFCPMessageHandler)
m[message.MsgTypeHeartbeatRequest] = handleHeartbeatRequest
return m
}
Expand Down Expand Up @@ -103,14 +103,14 @@ func (e *PFCPEntity) listen() error {
return nil
}

func (e *PFCPEntity) GetHandler(t pfcputil.MessageType) (h handler, err error) {
func (e *PFCPEntity) GetHandler(t pfcputil.MessageType) (h PFCPMessageHandler, err error) {
if f, exists := e.handlers[t]; exists {
return f, nil
}
return nil, fmt.Errorf("Received unexpected PFCP message type")
}

func (e *PFCPEntity) AddHandler(t pfcputil.MessageType, h handler) error {
func (e *PFCPEntity) AddHandler(t pfcputil.MessageType, h PFCPMessageHandler) error {
if e.RecoveryTimeStamp() != nil {
return fmt.Errorf("Cannot add handler to already started PFCP Entity")
}
Expand All @@ -121,7 +121,7 @@ func (e *PFCPEntity) AddHandler(t pfcputil.MessageType, h handler) error {
return nil
}

func (e *PFCPEntity) AddHandlers(funcs map[pfcputil.MessageType]handler) error {
func (e *PFCPEntity) AddHandlers(funcs map[pfcputil.MessageType]PFCPMessageHandler) error {
if e.RecoveryTimeStamp() != nil {
return fmt.Errorf("Cannot add handler to already started PFCP Entity")
}
Expand Down Expand Up @@ -152,7 +152,7 @@ func (e *PFCPEntity) NewEstablishedPFCPAssociation(nodeID *ie.IE) (association a
if err != nil {
return nil, err
}
if e.RecoveryTimeStamp == nil {
if e.RecoveryTimeStamp() == nil {
return nil, fmt.Errorf("Local PFCP entity is not started")
}
nid, err := nodeID.NodeID()
Expand Down
2 changes: 0 additions & 2 deletions pfcp/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ func handleAssociationSetupRequest(msg ReceivedMessage) error {
switch {
case msg.Message == nil:
return fmt.Errorf("msg is nil")
case msg.Sequence == nil:
return fmt.Errorf("msg.Sequence is nil")
case msg.Entity == nil:
return fmt.Errorf("entity is nil")
case msg.Entity.NodeID() == nil:
Expand Down

0 comments on commit 7b06819

Please sign in to comment.