Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Lagniappe CI Jobs #95

Merged
merged 16 commits into from
Jun 30, 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
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2

updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
23 changes: 0 additions & 23 deletions .github/workflows/e2e-test.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/go-test.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/golangci-lint.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/hygeine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: hygeiene

on:
push:
branches: [ "master", "development" ]
pull_request:
branches: [ "master", "development" ]

jobs:
ensure-mock-gen:
# Generation assurance test workflow
# (e.g. no uncovered diffs in go-mocks)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Install mockgen
run: go install github.com/golang/mock/[email protected]

- name: Mock diff check
run: make go-gen-mocks && git diff --exit-code

golangci:
# Linting job
# https://github.com/golangci/golangci-lint-action
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.52.1
22 changes: 22 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: security

on:
push:
branches: [ "master", "development" ]
pull_request:
branches: [ "master", "development" ]

jobs:
# Static security scan using gosec
# https://github.com/securego/gosec
gosec:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v3
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: ./...
48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Go test workflow
name: test

on:
push:
branches: [ "master", "development" ]
pull_request:
branches: [ "master", "development" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Build App
run: make build-app

go-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Run Unit Tests
run: make test

e2e-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Run E2E Integration Tests
run: make e2e-test
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ lint:

@golangci-lint run

gosec:
@echo "$(GREEN) Running security scan with gosec...$(COLOR_END)"
gosec ./...

.PHONY: metric-docs
metric-docs: build-app
@echo "$(GREEN) Generating metric documentation...$(COLOR_END)"
Expand All @@ -59,4 +63,4 @@ docker-build:
.PHONY: docker-run
docker-run:
@echo "$(GREEN) Running docker image...$(COLOR_END)"
@docker run -p 8080:8080 -p 7300:7300 -e config.env $(APP_NAME)
@docker run -p 8080:8080 -p 7300:7300 -e config.env $(APP_NAME)
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"

"github.com/base-org/pessimism/cmd/doc"
Expand Down Expand Up @@ -117,7 +118,7 @@ func fetchBootSessions(path string) ([]app.BootSession, error) {
return nil, fmt.Errorf("invalid bootstrap file format; expected %s", extJSON)
}

file, err := os.ReadFile(path)
file, err := os.ReadFile(filepath.Clean(path))
if err != nil {
return nil, err
}
Expand Down
11 changes: 6 additions & 5 deletions internal/api/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ func initializeServer(config *Config, handler http.Handler) *Server {
return &Server{
Cfg: config,
serverHTTP: &http.Server{
Addr: fmt.Sprintf("%s:%d", config.Host, config.Port),
Handler: handler,
IdleTimeout: time.Duration(config.KeepAlive) * time.Second,
ReadTimeout: time.Duration(config.ReadTimeout) * time.Second,
WriteTimeout: time.Duration(config.WriteTimeout) * time.Second,
Addr: fmt.Sprintf("%s:%d", config.Host, config.Port),
Handler: handler,
IdleTimeout: time.Duration(config.KeepAlive) * time.Second,
ReadHeaderTimeout: time.Duration(config.ReadTimeout) * time.Second,
ReadTimeout: time.Duration(config.ReadTimeout) * time.Second,
WriteTimeout: time.Duration(config.WriteTimeout) * time.Second,
},
}
}
9 changes: 8 additions & 1 deletion internal/client/slack_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/http"

"github.com/base-org/pessimism/internal/logging"
"go.uber.org/zap"
)

// SlackClient ... Interface for slack client
Expand Down Expand Up @@ -86,7 +87,13 @@ func (sc slackClient) PostData(ctx context.Context, str string) (*SlackAPIRespon
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() {
err := resp.Body.Close()
if err != nil {
logging.WithContext(ctx).Warn("Could not close slack response body",
zap.Error(err))
}
}()

// read response
bytes, err := io.ReadAll(resp.Body)
Expand Down