Skip to content
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
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
lint-and-test:
name: Lint and Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.6'

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum', '**/go.mod') }}
restore-keys: |
${{ runner.os }}-go-

- name: Download dependencies
run: go mod download

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
args: --timeout=5m

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
36 changes: 36 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
linters-settings:
govet:
enable-all: true
gocyclo:
min-complexity: 15
misspell:
locale: US
lll:
line-length: 120

linters:
enable:
- errcheck
- gofmt
- goimports
- misspell
- ineffassign
- unconvert
disable:
- govet # Disabled due to version compatibility
- staticcheck # Disabled due to version compatibility
- unused # Disabled due to version compatibility
- gosimple # Disabled due to version compatibility
- typecheck # Disabled due to version compatibility
- gocritic # Disabled due to version compatibility
- gosec # Disabled due to version compatibility
- gocyclo # Can be enabled later if needed

run:
timeout: 5m
modules-download-mode: readonly

issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
7 changes: 6 additions & 1 deletion plugin/gthulhu/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ func (c *JWTClient) requestToken() error {
if err != nil {
return fmt.Errorf("failed to send token request: %v", err)
}
defer resp.Body.Close()
defer func() {
err = resp.Body.Close()
if err != nil {
fmt.Printf("Body.Close() failed: %v", err)
}
}()

body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down
9 changes: 7 additions & 2 deletions plugin/gthulhu/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type BssData struct {
NrOnlineCpus uint64 `json:"nr_online_cpus"` // Number of online CPUs in the system
NrUserDispatches uint64 `json:"nr_user_dispatches"` // Number of user-space dispatches
NrKernelDispatches uint64 `json:"nr_kernel_dispatches"` // Number of kernel-space dispatches
NrCancelDispatches uint64 `json:"nr_cancel_dispatches"` // Number of cancelled dispatches
NrCancelDispatches uint64 `json:"nr_cancel_dispatches"` // Number of canceled dispatches
NrBounceDispatches uint64 `json:"nr_bounce_dispatches"` // Number of bounce dispatches
NrFailedDispatches uint64 `json:"nr_failed_dispatches"` // Number of failed dispatches
NrSchedCongested uint64 `json:"nr_sched_congested"` // Number of times the scheduler was congested
Expand Down Expand Up @@ -65,7 +65,12 @@ func (c *MetricsClient) SendMetrics(data BssData) error {
if err != nil {
return fmt.Errorf("failed to send metrics request: %v", err)
}
defer resp.Body.Close()
defer func() {
err = resp.Body.Close()
if err != nil {
fmt.Printf("Body.Close() failed: %v", err)
}
}()

// Check response
if resp.StatusCode != 200 {
Expand Down
7 changes: 6 additions & 1 deletion plugin/gthulhu/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ func FetchSchedulingStrategies(apiUrl string) ([]SchedulingStrategy, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() {
err = resp.Body.Close()
if err != nil {
fmt.Printf("Body.Close() failed: %v", err)
}
}()

body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down
Loading