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

Updates #408

Merged
merged 2 commits into from
Nov 6, 2023
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
17 changes: 10 additions & 7 deletions .github/workflows/pullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go 1.19
uses: actions/setup-go@v3
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.21'
check-latest: true

- name: Download dependencies
run: |
go mod tidy
go mod download

- name: Run go vet
run: go vet ./...

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49
version: v1.55

- name: Run tests
run: make test
Expand All @@ -40,12 +43,12 @@ jobs:
goveralls -coverprofile=coverage.out -service=github

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: go

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

- name: Build binary
run: make build
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/pullRequestMaster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go 1.19
uses: actions/setup-go@v3
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.21'
check-latest: true

- name: Download dependencies
run: |
go mod tidy
go mod download

- name: Run go vet
run: go vet ./...

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49
version: v1.55

- name: Run tests
run: make test
Expand All @@ -40,12 +43,12 @@ jobs:
goveralls -coverprofile=coverage.out -service=github

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: go

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

- name: Build binary
run: make build
Expand Down
2 changes: 1 addition & 1 deletion cmd/ephemeral-roles/ephemeral-roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ func startSession(
}

func setupCallbackHandler(session *discordgo.Session, callbackConfig *callbacks.Handler) {
session.AddHandler(callbackConfig.ChannelDelete)
session.AddHandler(callbackConfig.Ready)
session.AddHandler(callbackConfig.VoiceStateUpdate)
session.AddHandler(callbackConfig.ChannelDelete)
}

func startHTTPServer(log logging.Interface, session *discordgo.Session, port string) (httpServer *http.Server, stop chan os.Signal) {
Expand Down
4 changes: 3 additions & 1 deletion internal/pkg/callbacks/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
"github.com/ewohltman/ephemeral-roles/internal/pkg/operations"
)

const unableToProcessEvent = "Unable to process event: "

// OperationsGateway is an interface abstraction for processing operations
// requests.
type OperationsGateway interface {
Process(*operations.Request) <-chan singleflight.Result
Process(request *operations.Request) <-chan singleflight.Result
}

// Handler contains fields for the callback methods attached to it.
Expand Down
5 changes: 1 addition & 4 deletions internal/pkg/callbacks/channelDelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import (
"github.com/bwmarrin/discordgo"
)

const (
channelDelete = "ChannelDelete"
channelDeleteEventError = "Unable to process event: " + channelDelete
)
const channelDeleteEventError = unableToProcessEvent + "ChannelDelete"

// ChannelDelete is the callback function for the ChannelDelete event from Discord.
func (handler *Handler) ChannelDelete(session *discordgo.Session, channel *discordgo.ChannelDelete) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/callbacks/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
// metadata for the error.
type CallbackError interface {
error
Is(error) bool
Is(err error) bool
Unwrap() error
InGuild() *discordgo.Guild
ForMember() *discordgo.Member
Expand Down
5 changes: 1 addition & 4 deletions internal/pkg/callbacks/ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import (
"github.com/bwmarrin/discordgo"
)

const (
ready = "Ready"
readyEventError = "Unable to process event: " + ready
)
const readyEventError = unableToProcessEvent + "Ready"

// Ready is the callback function for the Ready event from Discord.
func (handler *Handler) Ready(s *discordgo.Session, _ *discordgo.Ready) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/callbacks/voiceStateUpdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

const (
voiceStateUpdate = "VoiceStateUpdate"
voiceStateUpdateEventError = "Unable to process event: " + voiceStateUpdate
voiceStateUpdateEventError = unableToProcessEvent + voiceStateUpdate
)

type voiceStateUpdateMetadata struct {
Expand Down
5 changes: 3 additions & 2 deletions internal/pkg/mock/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

const (
rolePrefix = "{eph}"
testUserBot = mockconstants.TestUser + "Bot"
largeGuildSize = 3000
)

Expand All @@ -37,8 +38,8 @@ func NewSession() (*discordgo.Session, error) {
)

botUser := mockuser.New(
mockuser.WithID(mockconstants.TestUser+"Bot"),
mockuser.WithUsername(mockconstants.TestUser+"Bot"),
mockuser.WithID(testUserBot),
mockuser.WithUsername(testUserBot),
mockuser.WithBotFlag(true),
)

Expand Down
Loading