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

Commit

Permalink
Merge pull request #2 from jmourell/addstyles
Browse files Browse the repository at this point in the history
Update workflows to rurn styling
  • Loading branch information
jmourell authored Sep 8, 2024
2 parents 526a6be + 7ecec81 commit 2854ce9
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 6 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: cd

on:
push:
branches: [main]

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

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

- name: Run bashscript
run: ./scripts/buildprod.sh
32 changes: 31 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,35 @@ jobs:
with:
go-version: '1.22'

- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest

- name: Go Test
run: go test ./... -cover
run: go test ./... -cover

- name: Go Security Check
run: gosec ./...

style:
name: Style
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

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

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Format styles
run: test -z $(go fmt ./...)

- name: Run staticcheck
run: staticcheck ./...


2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 debian:stable-slim
FROM --platform=linux/arm64 debian:stable-slim

RUN apt-get update && apt-get install -y ca-certificates

Expand Down
2 changes: 1 addition & 1 deletion internal/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestGetAPIKey(t *testing.T) {

diff := cmp.Diff(tc.want, result{Auth: auth, Err: err}, cmpopts.EquateErrors())
if diff != "" {
t.Fatalf(diff)
t.Fatal(diff)
}
})
}
Expand Down
7 changes: 6 additions & 1 deletion json.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
return
}
w.WriteHeader(code)
w.Write(dat)
_, err = w.Write(dat)
if err != nil {
log.Printf("Error writing response: %s", err)
return
}

}
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
"time"

"github.com/go-chi/chi"
"github.com/go-chi/cors"
Expand Down Expand Up @@ -89,8 +90,9 @@ func main() {

router.Mount("/v1", v1Router)
srv := &http.Server{
Addr: ":" + port,
Handler: router,
Addr: ":" + port,
Handler: router,
ReadHeaderTimeout: 2 * time.Second,
}

log.Printf("Serving on port: %s\n", port)
Expand Down

0 comments on commit 2854ce9

Please sign in to comment.