From df5c5ff24b7d61c3ddaac5382f65e32a17ccc734 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 11:37:34 +0200 Subject: [PATCH 1/8] added style checks --- .github/workflows/ci.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ce56c9..09109b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,4 +25,23 @@ jobs: go-version: "1.27.1" - name: Run unit tests - run: go test ./... -cover \ No newline at end of file + run: go test ./... -cover + style: + name: Style + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./learn-cicd + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.27.1" + + - name: Run style checks + run: test -z $(go fmt ./...) From 385c6e13bb85390648758ae3c04196515b7bbdf3 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 11:40:15 +0200 Subject: [PATCH 2/8] added workflow changes to also trigger ci --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09109b0..714919e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: ci on: pull_request: paths: + - '.github/workflows/ci.yml' - 'learn-cicd/**' branches: [main] From eede62ba4cf8102ad8dbb772cff3fbd136f4781a Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 12:13:49 +0200 Subject: [PATCH 3/8] added staticcheck and unused func --- .github/workflows/ci.yml | 6 ++++++ .vscode/settings.json | 2 ++ learn-cicd/main.go | 7 +++++++ 3 files changed, 15 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 714919e..e713cb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,3 +46,9 @@ jobs: - name: Run style checks run: test -z $(go fmt ./...) + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + run: staticcheck ./... diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/learn-cicd/main.go b/learn-cicd/main.go index 19d7366..6a53932 100644 --- a/learn-cicd/main.go +++ b/learn-cicd/main.go @@ -3,6 +3,7 @@ package main import ( "database/sql" "embed" + "fmt" "io" "log" "net/http" @@ -96,3 +97,9 @@ func main() { log.Printf("Serving on port: %s\n", port) log.Fatal(srv.ListenAndServe()) } + +func unused() { + // this function does nothin + // and is called nowhere + fmt.Sprintf("hello") +} From a287992f3b991ce53a6d4a12261390cabfcb6fc1 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 12:15:08 +0200 Subject: [PATCH 4/8] removed unused func --- learn-cicd/main.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/learn-cicd/main.go b/learn-cicd/main.go index 6a53932..19d7366 100644 --- a/learn-cicd/main.go +++ b/learn-cicd/main.go @@ -3,7 +3,6 @@ package main import ( "database/sql" "embed" - "fmt" "io" "log" "net/http" @@ -97,9 +96,3 @@ func main() { log.Printf("Serving on port: %s\n", port) log.Fatal(srv.ListenAndServe()) } - -func unused() { - // this function does nothin - // and is called nowhere - fmt.Sprintf("hello") -} From 9edfccc035cc06aefdec94b1c2f268bd818a453f Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 12:20:45 +0200 Subject: [PATCH 5/8] added failing gosec check --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e713cb9..a01a6bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,13 @@ jobs: - name: Run unit tests run: go test ./... -cover + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + + - name: Run gosec + run: gosec ./... + style: name: Style runs-on: ubuntu-latest From 5ef9d44829b3351454779d7f65101c4ef29e7d73 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 12:40:29 +0200 Subject: [PATCH 6/8] fixed gosec issues --- learn-cicd/json.go | 6 +++++- learn-cicd/main.go | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/learn-cicd/json.go b/learn-cicd/json.go index 1e6e798..99c4bb0 100644 --- a/learn-cicd/json.go +++ b/learn-cicd/json.go @@ -30,5 +30,9 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { return } w.WriteHeader(code) - w.Write(dat) + if _, err := w.Write(dat); err != nil { + log.Printf("Error writing data: %s", err) + w.WriteHeader(500) + return + } } diff --git a/learn-cicd/main.go b/learn-cicd/main.go index 19d7366..b86345b 100644 --- a/learn-cicd/main.go +++ b/learn-cicd/main.go @@ -7,6 +7,8 @@ import ( "log" "net/http" "os" + "strconv" + "time" "github.com/go-chi/chi" "github.com/go-chi/cors" @@ -89,10 +91,14 @@ func main() { router.Mount("/v1", v1Router) srv := &http.Server{ - Addr: ":" + port, - Handler: router, + Addr: ":" + port, + Handler: router, + ReadHeaderTimeout: time.Minute * 5, } - - log.Printf("Serving on port: %s\n", port) + p, err := strconv.Atoi(port) + if err != nil { + log.Fatal("Invalid port") + } + log.Printf("Serving on port: %d\n", p) log.Fatal(srv.ListenAndServe()) } From e1c7cf383f7cb495170e4e2ea77f79a275716c57 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 12:46:35 +0200 Subject: [PATCH 7/8] used changes from original code and updated clibadges --- .github/workflows/chirpy.yml | 65 +++++++++++++++++++++++++++++ .github/workflows/gator.yml | 65 +++++++++++++++++++++++++++++ .github/workflows/http-from-tcp.yml | 65 +++++++++++++++++++++++++++++ .github/workflows/learn-pub-sub.yml | 65 +++++++++++++++++++++++++++++ .github/workflows/pokedexcli.yml | 65 +++++++++++++++++++++++++++++ README.md | 10 ++--- learn-cicd/json.go | 3 +- learn-cicd/main.go | 9 ++-- 8 files changed, 334 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/chirpy.yml create mode 100644 .github/workflows/gator.yml create mode 100644 .github/workflows/http-from-tcp.yml create mode 100644 .github/workflows/learn-pub-sub.yml create mode 100644 .github/workflows/pokedexcli.yml diff --git a/.github/workflows/chirpy.yml b/.github/workflows/chirpy.yml new file mode 100644 index 0000000..8d1c46a --- /dev/null +++ b/.github/workflows/chirpy.yml @@ -0,0 +1,65 @@ +name: chirpy + +on: + pull_request: + paths: + - '.github/workflows/chirpy.yml' + - 'chirpy/**' + branches: [main] + push: + paths: + - '.github/workflows/chirpy.yml' + - 'chirpy/**' + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./chirpy + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.4" + + - name: Run unit tests + run: go test ./... -cover + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + + - name: Run gosec + run: gosec ./... + + style: + name: Style + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./chirpy + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.27.1" + + - name: Run style checks + run: test -z $(go fmt ./...) + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + run: staticcheck ./... diff --git a/.github/workflows/gator.yml b/.github/workflows/gator.yml new file mode 100644 index 0000000..5aeebab --- /dev/null +++ b/.github/workflows/gator.yml @@ -0,0 +1,65 @@ +name: gator + +on: + pull_request: + paths: + - '.github/workflows/gator.yml' + - 'gator/**' + branches: [main] + push: + paths: + - '.github/workflows/gator.yml' + - 'gator/**' + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./gator + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.4" + + - name: Run unit tests + run: go test ./... -cover + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + + - name: Run gosec + run: gosec ./... + + style: + name: Style + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./gator + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.27.1" + + - name: Run style checks + run: test -z $(go fmt ./...) + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + run: staticcheck ./... diff --git a/.github/workflows/http-from-tcp.yml b/.github/workflows/http-from-tcp.yml new file mode 100644 index 0000000..71eced9 --- /dev/null +++ b/.github/workflows/http-from-tcp.yml @@ -0,0 +1,65 @@ +name: http-from-tcp + +on: + pull_request: + paths: + - '.github/workflows/http-from-tcp.yml' + - 'http-from-tcp/**' + branches: [main] + push: + paths: + - '.github/workflows/http-from-tcp.yml' + - 'http-from-tcp/**' + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./http-from-tcp + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.27.1" + + - name: Run unit tests + run: go test ./... -cover + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + + - name: Run gosec + run: gosec ./... + + style: + name: Style + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./http-from-tcp + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.4" + + - name: Run style checks + run: test -z $(go fmt ./...) + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + run: staticcheck ./... diff --git a/.github/workflows/learn-pub-sub.yml b/.github/workflows/learn-pub-sub.yml new file mode 100644 index 0000000..476b85e --- /dev/null +++ b/.github/workflows/learn-pub-sub.yml @@ -0,0 +1,65 @@ +name: learn-pub-sub + +on: + pull_request: + paths: + - '.github/workflows/learn-pub-sub.yml' + - 'learn-pub-sub/**' + branches: [main] + push: + paths: + - '.github/workflows/learn-pub-sub.yml' + - 'learn-pub-sub/**' + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./learn-pub-sub + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.4" + + - name: Run unit tests + run: go test ./... -cover + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + + - name: Run gosec + run: gosec ./... + + style: + name: Style + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./learn-pub-sub + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.27.1" + + - name: Run style checks + run: test -z $(go fmt ./...) + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + run: staticcheck ./... diff --git a/.github/workflows/pokedexcli.yml b/.github/workflows/pokedexcli.yml new file mode 100644 index 0000000..b7566d2 --- /dev/null +++ b/.github/workflows/pokedexcli.yml @@ -0,0 +1,65 @@ +name: pokedexcli + +on: + pull_request: + paths: + - '.github/workflows/pokedexcli.yml' + - 'pokedexcli/**' + branches: [main] + push: + paths: + - '.github/workflows/pokedexcli.yml' + - 'pokedexcli/**' + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./learn-cicd + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.4" + + - name: Run unit tests + run: go test ./... -cover + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + + - name: Run gosec + run: gosec ./... + + style: + name: Style + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./learn-cicd + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.27.1" + + - name: Run style checks + run: test -z $(go fmt ./...) + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + run: staticcheck ./... diff --git a/README.md b/README.md index f238ae1..05eef6f 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ A collection of projects completed as part of my coursework on [Boot.dev](https: | Project | CI | Description | | --- | --- | --- | -| [`chirpy`](./chirpy) | | HTTP web server built from scratch in Go, including routing, JSON handling, and a REST API backed by a database. | -| [`pokedexcli`](./pokedexcli) | | A CLI Pokedex in Go that consumes the PokeAPI REST API, with caching and a REPL-style interface. | -| [`gator`](./gator) | | RSS feed aggregator CLI in Go with persistent storage (PostgreSQL) and scheduled feed fetching. | -| [`http-from-tcp`](./http-from-tcp) | | Implements an HTTP server from raw TCP sockets in Go, without using the standard `net/http` package, to understand the protocol at a low level. | -| [`learn-pub-sub`](./learn-pub-sub) | | Pub/sub messaging system in Go using RabbitMQ, built around a multiplayer game simulation. | +| [`chirpy`](./chirpy) | ![chirpy](https://github.com/lennago/bootdev/actions/workflows/chirpy.yml/badge.svg) | HTTP web server built from scratch in Go, including routing, JSON handling, and a REST API backed by a database. | +| [`pokedexcli`](./pokedexcli) | ![pokedexcli](https://github.com/lennago/bootdev/actions/workflows/pokedexcli.yml/badge.svg) | A CLI Pokedex in Go that consumes the PokeAPI REST API, with caching and a REPL-style interface. | +| [`gator`](./gator) | ![gator](https://github.com/lennago/bootdev/actions/workflows/gator.yml/badge.svg) | RSS feed aggregator CLI in Go with persistent storage (PostgreSQL) and scheduled feed fetching. | +| [`http-from-tcp`](./http-from-tcp) | ![http-from-tcp](https://github.com/lennago/bootdev/actions/workflows/http-from-tcp.yml/badge.svg) | Implements an HTTP server from raw TCP sockets in Go, without using the standard `net/http` package, to understand the protocol at a low level. | +| [`learn-pub-sub`](./learn-pub-sub) | ![learn-pub-sub](https://github.com/lennago/bootdev/actions/workflows/learn-pub-sub.yml/badge.svg) | Pub/sub messaging system in Go using RabbitMQ, built around a multiplayer game simulation. | | [`kubernetes`](./kubernetes) | | Deploying and orchestrating an application with Kubernetes. | | [`static-site-generator`](./static-site-generator) | | A static site generator written in Python that converts Markdown files into HTML pages. | | [`asteroids`](./asteroids) | | A recreation of the classic Asteroids arcade game in Python using Pygame. | diff --git a/learn-cicd/json.go b/learn-cicd/json.go index 99c4bb0..c382d65 100644 --- a/learn-cicd/json.go +++ b/learn-cicd/json.go @@ -31,8 +31,7 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { } w.WriteHeader(code) if _, err := w.Write(dat); err != nil { - log.Printf("Error writing data: %s", err) - w.WriteHeader(500) + log.Printf("Critical error writing response: %s", err) return } } diff --git a/learn-cicd/main.go b/learn-cicd/main.go index b86345b..1882728 100644 --- a/learn-cicd/main.go +++ b/learn-cicd/main.go @@ -93,12 +93,9 @@ func main() { srv := &http.Server{ Addr: ":" + port, Handler: router, - ReadHeaderTimeout: time.Minute * 5, + ReadHeaderTimeout: time.Second * 5, } - p, err := strconv.Atoi(port) - if err != nil { - log.Fatal("Invalid port") - } - log.Printf("Serving on port: %d\n", p) + + log.Printf("Serving on port: %s\n", strconv.Quote(port)) log.Fatal(srv.ListenAndServe()) } From 5d813c5f2f9091f2ee6ff96708ee75c2f25e0470 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 13:03:56 +0200 Subject: [PATCH 8/8] added cd file --- .github/workflows/cd.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/chirpy.yml | 6 ------ .github/workflows/gator.yml | 6 ------ .github/workflows/http-from-tcp.yml | 6 ------ .github/workflows/learn-pub-sub.yml | 6 ------ .github/workflows/pokedexcli.yml | 8 +------- 6 files changed, 30 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..f6948ae --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,29 @@ +name: cd + +on: + push: + paths: + - '.github/workflows/ci.yml' + - 'learn-cicd/**' + branches: [main] + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./learn-cicd + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.27.1" + + - name: Build app + run: ./scripts/buildprod.sh diff --git a/.github/workflows/chirpy.yml b/.github/workflows/chirpy.yml index 8d1c46a..237942f 100644 --- a/.github/workflows/chirpy.yml +++ b/.github/workflows/chirpy.yml @@ -31,12 +31,6 @@ jobs: - name: Run unit tests run: go test ./... -cover - - - name: Install gosec - run: go install github.com/securego/gosec/v2/cmd/gosec@latest - - - name: Run gosec - run: gosec ./... style: name: Style diff --git a/.github/workflows/gator.yml b/.github/workflows/gator.yml index 5aeebab..f8fce29 100644 --- a/.github/workflows/gator.yml +++ b/.github/workflows/gator.yml @@ -31,12 +31,6 @@ jobs: - name: Run unit tests run: go test ./... -cover - - - name: Install gosec - run: go install github.com/securego/gosec/v2/cmd/gosec@latest - - - name: Run gosec - run: gosec ./... style: name: Style diff --git a/.github/workflows/http-from-tcp.yml b/.github/workflows/http-from-tcp.yml index 71eced9..ddd30ec 100644 --- a/.github/workflows/http-from-tcp.yml +++ b/.github/workflows/http-from-tcp.yml @@ -31,12 +31,6 @@ jobs: - name: Run unit tests run: go test ./... -cover - - - name: Install gosec - run: go install github.com/securego/gosec/v2/cmd/gosec@latest - - - name: Run gosec - run: gosec ./... style: name: Style diff --git a/.github/workflows/learn-pub-sub.yml b/.github/workflows/learn-pub-sub.yml index 476b85e..8b1572c 100644 --- a/.github/workflows/learn-pub-sub.yml +++ b/.github/workflows/learn-pub-sub.yml @@ -31,12 +31,6 @@ jobs: - name: Run unit tests run: go test ./... -cover - - - name: Install gosec - run: go install github.com/securego/gosec/v2/cmd/gosec@latest - - - name: Run gosec - run: gosec ./... style: name: Style diff --git a/.github/workflows/pokedexcli.yml b/.github/workflows/pokedexcli.yml index b7566d2..8d405f1 100644 --- a/.github/workflows/pokedexcli.yml +++ b/.github/workflows/pokedexcli.yml @@ -27,16 +27,10 @@ jobs: - name: Set up Go uses: actions/setup-go@v6 with: - go-version: "1.26.4" + go-version: "1.27.1" - name: Run unit tests run: go test ./... -cover - - - name: Install gosec - run: go install github.com/securego/gosec/v2/cmd/gosec@latest - - - name: Run gosec - run: gosec ./... style: name: Style