Skip to content

Commit

Permalink
Add golangci github action
Browse files Browse the repository at this point in the history
  • Loading branch information
saolof committed May 17, 2024
1 parent 8eae906 commit 0bd7be9
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Dockerfile
README.md
logo.webp
pgxcron
.github
**/.git
25 changes: 25 additions & 0 deletions .github/workflows/golancgci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: golangci-lint
on:
push:
branches:
- main
- master
pull_request:

permissions:
contents: read
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ func run(ctx context.Context, w io.Writer, logger *log.Logger, webport int, chec
}
if webport > 0 && webport <= 49152 {
server := webserver(webport, jobs, monitor)
go server.ListenAndServe()
go func() {
if err := server.ListenAndServe(); err != nil {
logger.Printf("Fatal error in webserver: %s", err)
}
}()
fmt.Println("Listening to traffic on port ", webport)
}
c.Run()
Expand Down
12 changes: 9 additions & 3 deletions monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func (m Monitor) SetStatus(ctx context.Context, id JobId, status string) error {
}

func (m Monitor) Fail(ctx context.Context, id JobId, err error) {
m.SetStatus(ctx, id, "failed")
if err := m.SetStatus(ctx, id, "failed"); err != nil {
m.ErrorLog.Printf("Error writing status update to sqlite: %s", err)
}
m.ErrorLog.Println(err)
gauge, err := m.ActiveJobs.GetMetricWithLabelValues(id.database, id.jobname)
if err != nil {
Expand All @@ -85,11 +87,15 @@ func (m Monitor) Fail(ctx context.Context, id JobId, err error) {
}

func (m Monitor) Run(ctx context.Context, id JobId) {
m.SetStatus(ctx, id, "running")
if err := m.SetStatus(ctx, id, "running"); err != nil {
m.ErrorLog.Printf("Error writing status update to sqlite: %s", err)
}
}

func (m Monitor) Complete(ctx context.Context, id JobId) {
m.SetStatus(ctx, id, "completed")
if err := m.SetStatus(ctx, id, "completed"); err != nil {
m.ErrorLog.Printf("Error writing status update to sqlite: %s", err)
}
gauge, err := m.ActiveJobs.GetMetricWithLabelValues(id.database, id.jobname)
if err != nil {
m.ErrorLog.Printf("While failing, failed to find metric for failing job: %s", err)
Expand Down

0 comments on commit 0bd7be9

Please sign in to comment.