From e709db50e86f54807e7dd83a6e0404aa2b366601 Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Tue, 5 Aug 2025 21:11:20 +0200 Subject: [PATCH 01/14] Add my name to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b..1b2e2385a4 100644 --- a/README.md +++ b/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! + +Sasho Zikov's version of Boot.dev's Notely app. From 9ddd9e9d0ed581828bd7b01f2c4d048ea951dbaf Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Wed, 6 Aug 2025 13:14:57 +0200 Subject: [PATCH 02/14] Add basic CI workflow --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 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 0000000000..da11e29497 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: ci + +on: + pull_request: + branches: [main] + +jobs: + tests: + name: Tests + 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.23.0" + + - name: Force Failure + run: (exit 1) + From 28740604ea8e47756fd55f857efa75bda01b0802 Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Wed, 6 Aug 2025 16:05:47 +0200 Subject: [PATCH 03/14] Update CI to show Go version instead of failing --- .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 da11e29497..ac90a8d4a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,6 @@ jobs: with: go-version: "1.23.0" - - name: Force Failure - run: (exit 1) + - name: Show Go Version + run: go version From cf15cc73874fdab5c424d36a66ff51b837d916bf Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Thu, 7 Aug 2025 21:07:57 +0200 Subject: [PATCH 04/14] Update CI to show Go version instead of failing --- .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 ac90a8d4a1..4c838425ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,6 @@ jobs: with: go-version: "1.23.0" - - name: Show Go Version - run: go version + - name: Show Go Version + run: go version From 40c1cd00fcc891e6028077067e97f54f76d9127a Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Fri, 8 Aug 2025 09:54:50 +0200 Subject: [PATCH 05/14] Update CI to run Go tests and add unit tests for GetAPIKey --- .github/workflows/ci.yml | 4 ++-- internal/auth/auth_test.go | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 internal/auth/auth_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c838425ea..88c80d50ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,6 @@ jobs: with: go-version: "1.23.0" - - name: Show Go Version - run: go version + - name: Run tests + run: go test ./... diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 0000000000..3fa44d0473 --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,37 @@ +package auth + +import ( + "net/http" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + t.Run("returns key when header is valid", func(t *testing.T) { + h := http.Header{} + h.Set("Authorization", "ApiKey abc123") + got, err := GetAPIKey(h) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if got != "abc123" { + t.Fatalf("expected abc123, got %q", got) + } + }) + + t.Run("returns ErrNoAuthHeaderIncluded when header missing", func(t *testing.T) { + h := http.Header{} + _, err := GetAPIKey(h) + if err != ErrNoAuthHeaderIncluded { + t.Fatalf("expected ErrNoAuthHeaderIncluded, got %v", err) + } + }) + + t.Run("returns error when header malformed", func(t *testing.T) { + h := http.Header{} + h.Set("Authorization", "Bearer abc123") + _, err := GetAPIKey(h) + if err == nil { + t.Fatalf("expected error for malformed header, got nil") + } + }) +} From f57dd520f66fd7f9f6150320eec5a22c604a023f Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Fri, 8 Aug 2025 09:59:14 +0200 Subject: [PATCH 06/14] Add code coverage reporting to CI tests --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88c80d50ff..8146a7c17f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ jobs: with: go-version: "1.23.0" - - name: Run tests - run: go test ./... + - name: Run tests with coverage + run: go test -cover ./... + From aaa4448728f695cdcd5f848072c9af78baa5ce25 Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Fri, 8 Aug 2025 13:09:36 +0200 Subject: [PATCH 07/14] Add CI test status badge to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1b2e2385a4..8d30a9993b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # learn-cicd-starter (Notely) +![Tests](https://github.com/Sashozk/learn-cicd-starter/actions/workflows/ci.yml/badge.svg) This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). From 9bc66282d28bfddbe1122b7507639213dbb16c73 Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Fri, 8 Aug 2025 13:42:12 +0200 Subject: [PATCH 08/14] Add style job to CI --- .github/workflows/ci.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8146a7c17f..46d2f952c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,3 +22,21 @@ jobs: run: go test -cover ./... + + + 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.23.0" + + - name: Check formatting + run: test -z "$(go fmt ./...)" + \ No newline at end of file From 0b9dcd3ab1a97fd1bbac31877fa5698483df5dfe Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Fri, 8 Aug 2025 13:44:48 +0200 Subject: [PATCH 09/14] Your commit message describing the changes --- internal/auth/auth.go | 5 ++++ internal/auth/auth_test.go | 56 +++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index f969aacf63..69f07002c0 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -2,6 +2,7 @@ package auth import ( "errors" + "fmt" "net/http" "strings" ) @@ -21,3 +22,7 @@ func GetAPIKey(headers http.Header) (string, error) { return splitAuth[1], nil } + +func main() { + fmt.Println("hello world!") +} diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go index 3fa44d0473..8e573ea807 100644 --- a/internal/auth/auth_test.go +++ b/internal/auth/auth_test.go @@ -1,37 +1,37 @@ package auth import ( - "net/http" - "testing" + "net/http" + "testing" ) func TestGetAPIKey(t *testing.T) { - t.Run("returns key when header is valid", func(t *testing.T) { - h := http.Header{} - h.Set("Authorization", "ApiKey abc123") - got, err := GetAPIKey(h) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if got != "abc123" { - t.Fatalf("expected abc123, got %q", got) - } - }) + t.Run("returns key when header is valid", func(t *testing.T) { + h := http.Header{} + h.Set("Authorization", "ApiKey abc123") + got, err := GetAPIKey(h) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if got != "abc123" { + t.Fatalf("expected abc123, got %q", got) + } + }) - t.Run("returns ErrNoAuthHeaderIncluded when header missing", func(t *testing.T) { - h := http.Header{} - _, err := GetAPIKey(h) - if err != ErrNoAuthHeaderIncluded { - t.Fatalf("expected ErrNoAuthHeaderIncluded, got %v", err) - } - }) + t.Run("returns ErrNoAuthHeaderIncluded when header missing", func(t *testing.T) { + h := http.Header{} + _, err := GetAPIKey(h) + if err != ErrNoAuthHeaderIncluded { + t.Fatalf("expected ErrNoAuthHeaderIncluded, got %v", err) + } + }) - t.Run("returns error when header malformed", func(t *testing.T) { - h := http.Header{} - h.Set("Authorization", "Bearer abc123") - _, err := GetAPIKey(h) - if err == nil { - t.Fatalf("expected error for malformed header, got nil") - } - }) + t.Run("returns error when header malformed", func(t *testing.T) { + h := http.Header{} + h.Set("Authorization", "Bearer abc123") + _, err := GetAPIKey(h) + if err == nil { + t.Fatalf("expected error for malformed header, got nil") + } + }) } From ada52c0e452ab262e148ae15902206f2e08298c6 Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Fri, 8 Aug 2025 13:48:24 +0200 Subject: [PATCH 10/14] Add style job to CI workflow --- .github/workflows/ci.yml | 42 +++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46d2f952c1..b7d32ff1ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,25 +18,23 @@ jobs: with: go-version: "1.23.0" - - name: Run tests with coverage - run: go test -cover ./... - - - - - 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.23.0" - - - name: Check formatting - run: test -z "$(go fmt ./...)" - \ No newline at end of file + - name: Show Go Version + run: go version + + # Your existing test steps would be here + + 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.23.0" + + - name: Check formatting + run: test -z "$(go fmt ./...)" From 34a6959746c80a68d60b937dbbd623648950c052 Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Fri, 8 Aug 2025 14:36:06 +0200 Subject: [PATCH 11/14] Add Style job to CI workflow --- .github/workflows/ci.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7d32ff1ce..4fce3a79b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,40 +1,36 @@ -name: ci +name: CI on: pull_request: - branches: [main] + branches: [ main ] jobs: tests: name: Tests runs-on: ubuntu-latest - steps: - name: Check out code uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v4 with: - go-version: "1.23.0" - - - name: Show Go Version - run: go version + go-version: 1.20 - # Your existing test steps would be here + - name: Run tests + run: go test ./... 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 + uses: actions/setup-go@v4 with: - go-version: "1.23.0" + go-version: 1.20 - name: Check formatting run: test -z "$(go fmt ./...)" From 4add97bcdc897512be76ce4e83877843bfbb6422 Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Fri, 8 Aug 2025 15:39:24 +0200 Subject: [PATCH 12/14] Fix CI Go version and add module download --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fce3a79b0..7c92df68d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,9 +13,12 @@ jobs: uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: 1.20 + go-version: "1.23.0" + + - name: Get dependencies + run: go mod download - name: Run tests run: go test ./... @@ -34,3 +37,4 @@ jobs: - name: Check formatting run: test -z "$(go fmt ./...)" + From 211499d02d5fee3d835e97772a6cdb123e4b1ee5 Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Fri, 8 Aug 2025 15:42:17 +0200 Subject: [PATCH 13/14] Add go mod download step to CI --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c92df68d6..8286cd7168 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,9 @@ on: pull_request: branches: [ main ] + jobs: tests: - name: Tests runs-on: ubuntu-latest steps: - name: Check out code @@ -15,7 +15,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.23.0" + go-version: "1.23.0" - name: Get dependencies run: go mod download @@ -23,6 +23,7 @@ jobs: - name: Run tests run: go test ./... + style: name: Style runs-on: ubuntu-latest @@ -33,7 +34,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.20 + go-version: "1.23.0" - name: Check formatting run: test -z "$(go fmt ./...)" From 4840c11f06cc5a379a0ba2ab6ff4e87f2e977ba5 Mon Sep 17 00:00:00 2001 From: Sasho Zikov <96798356+Sashozk@users.noreply.github.com> Date: Fri, 8 Aug 2025 15:43:29 +0200 Subject: [PATCH 14/14] Fix CI: unify Go setup version and add module download --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8286cd7168..324d309ae1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,6 @@ on: pull_request: branches: [ main ] - jobs: tests: runs-on: ubuntu-latest @@ -23,7 +22,6 @@ jobs: - name: Run tests run: go test ./... - style: name: Style runs-on: ubuntu-latest @@ -32,10 +30,9 @@ jobs: uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: "1.23.0" - name: Check formatting run: test -z "$(go fmt ./...)" -