From d011a47aa3fa1319666ccdf03743474583fc3a82 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 10:19:42 +0200 Subject: [PATCH 1/6] changed README.md --- learn-cicd/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/learn-cicd/README.md b/learn-cicd/README.md index eb5dca9..36a2d4e 100644 --- a/learn-cicd/README.md +++ b/learn-cicd/README.md @@ -21,3 +21,5 @@ go build -o notely && ./notely *This starts the server in non-database mode.* It will serve a simple webpage at `http://localhost:8080`. You do *not* need to set up a database or any interactivity on the webpage yet. Instructions for that will come later in the course! + +lennago's version of Boot.dev's Notely app. From 8d512cc1a133916635879a5387a402658576d43c Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 10:28:15 +0200 Subject: [PATCH 2/6] add workflows --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cf81444 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: ci + +on: + pull_request: + branches: [main] + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + 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: Force Failure + run: (exit 1) \ No newline at end of file From 44955706a64c3c78b242c0c6a1836b2157923233 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 10:33:15 +0200 Subject: [PATCH 3/6] updated workflow --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf81444..b4a2062 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.27.1" - - name: Force Failure - run: (exit 1) \ No newline at end of file + - name: go version + run: go version \ No newline at end of file From 1043f0ffe7a48c49779ad83c190c676eba825426 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 11:01:45 +0200 Subject: [PATCH 4/6] added testing to workflow and broke code --- .github/workflows/ci.yml | 10 +++- README.md | 25 ++++---- learn-cicd/internal/auth/auth.go | 2 +- learn-cicd/internal/auth/get_api_key_test.go | 62 ++++++++++++++++++++ 4 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 learn-cicd/internal/auth/get_api_key_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4a2062..6309568 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,8 @@ name: ci on: pull_request: + paths: + - 'learn-cicd/**' branches: [main] jobs: @@ -9,6 +11,10 @@ jobs: name: Tests runs-on: ubuntu-latest + defaults: + run: + working-directory: ./learn-cicd + steps: - name: Check out code uses: actions/checkout@v6 @@ -18,5 +24,5 @@ jobs: with: go-version: "1.27.1" - - name: go version - run: go version \ No newline at end of file + - name: Run go tests + run: go test ./... \ No newline at end of file diff --git a/README.md b/README.md index ce90241..f238ae1 100644 --- a/README.md +++ b/README.md @@ -4,18 +4,19 @@ A collection of projects completed as part of my coursework on [Boot.dev](https: ## Projects -| Project | 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. | -| [`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. | -| [`bookbot`](./bookbot) | A Python CLI tool that analyzes text files and reports word counts and character frequency statistics. | -| [`ai-agent`](./ai-agent) | A toy AI coding agent in Python that uses an LLM (via function calling) to read, write, and execute files in a sandboxed directory. | +| 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. | +| [`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. | +| [`bookbot`](./bookbot) | | A Python CLI tool that analyzes text files and reports word counts and character frequency statistics. | +| [`ai-agent`](./ai-agent) | | A toy AI coding agent in Python that uses an LLM (via function calling) to read, write, and execute files in a sandboxed directory. | +| [`learn-cicd`](./learn-cicd) | ![learn-cicd](https://github.com/lennago/bootdev/actions/workflows/ci.yml/badge.svg) | Notely — a Go web server covering building, testing, and deploying with GitHub Actions and Google Cloud Run. | ## About diff --git a/learn-cicd/internal/auth/auth.go b/learn-cicd/internal/auth/auth.go index f969aac..6959c10 100644 --- a/learn-cicd/internal/auth/auth.go +++ b/learn-cicd/internal/auth/auth.go @@ -15,7 +15,7 @@ func GetAPIKey(headers http.Header) (string, error) { return "", ErrNoAuthHeaderIncluded } splitAuth := strings.Split(authHeader, " ") - if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { + if len(splitAuth) < 10 || splitAuth[0] != "ApiKey" { return "", errors.New("malformed authorization header") } diff --git a/learn-cicd/internal/auth/get_api_key_test.go b/learn-cicd/internal/auth/get_api_key_test.go new file mode 100644 index 0000000..5ac1cd9 --- /dev/null +++ b/learn-cicd/internal/auth/get_api_key_test.go @@ -0,0 +1,62 @@ +package auth + +import ( + "fmt" + "net/http" + "strings" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + tests := []struct { + key string + value string + expect string + expectErr string + }{ + { + expectErr: "no authorization header", + }, + { + key: "Authorization", + expectErr: "no authorization header", + }, + { + key: "Authorization", + value: "-", + expectErr: "malformed authorization header", + }, + { + key: "Authorization", + value: "Bearer xxxxxx", + expectErr: "malformed authorization header", + }, + { + key: "Authorization", + value: "ApiKey xxxxxx", + expect: "xxxxxx", + expectErr: "not expecting an error", + }, + } + + for i, test := range tests { + t.Run(fmt.Sprintf("TestGetAPIKey Case #%v:", i), func(t *testing.T) { + header := http.Header{} + header.Add(test.key, test.value) + + output, err := GetAPIKey(header) + if err != nil { + if strings.Contains(err.Error(), test.expectErr) { + return + } + t.Errorf("Unexpected: TestGetAPIKey:%v\n", err) + return + } + + if output != test.expect { + t.Errorf("Unexpected: TestGetAPIKey:%s", output) + return + } + }) + } +} From 624fe33dcec20fea23db868064b64d0a615c9850 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 11:03:00 +0200 Subject: [PATCH 5/6] fixed code --- learn-cicd/internal/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learn-cicd/internal/auth/auth.go b/learn-cicd/internal/auth/auth.go index 6959c10..f969aac 100644 --- a/learn-cicd/internal/auth/auth.go +++ b/learn-cicd/internal/auth/auth.go @@ -15,7 +15,7 @@ func GetAPIKey(headers http.Header) (string, error) { return "", ErrNoAuthHeaderIncluded } splitAuth := strings.Split(authHeader, " ") - if len(splitAuth) < 10 || splitAuth[0] != "ApiKey" { + if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { return "", errors.New("malformed authorization header") } From b79b8f7a7a82a0fb5aecc3c747b50f451e4c15e6 Mon Sep 17 00:00:00 2001 From: lennago Date: Sat, 5 Sep 2026 11:10:40 +0200 Subject: [PATCH 6/6] addeded coverage info to unit tests --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6309568..0ce56c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,5 +24,5 @@ jobs: with: go-version: "1.27.1" - - name: Run go tests - run: go test ./... \ No newline at end of file + - name: Run unit tests + run: go test ./... -cover \ No newline at end of file