From 8b85e9c34bad7af56eaaa4925deaa16409a47bde Mon Sep 17 00:00:00 2001 From: Juliana Trombetta Date: Tue, 16 Sep 2025 14:55:44 +0200 Subject: [PATCH 01/10] docs: add my version line to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b..fd9d517893 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! + +Juliana_Trombetta's version of Boot.dev's Notely app. From 1a2df29eb535933553945dca83acbfa4eb1c0330 Mon Sep 17 00:00:00 2001 From: Juliana Trombetta Date: Tue, 16 Sep 2025 15:19:25 +0200 Subject: [PATCH 02/10] docs: add my version line to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fd9d517893..2fddb695d6 100644 --- a/README.md +++ b/README.md @@ -23,3 +23,5 @@ go build -o notely && ./notely 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! Juliana_Trombetta's version of Boot.dev's Notely app. + +Juliana_Trombetta's version of Boot.dev's Notely app. From 6f4cf31aa65ad4f9990385f5660e1e7db6d9bafc Mon Sep 17 00:00:00 2001 From: Juliana Trombetta Date: Tue, 16 Sep 2025 15:47:06 +0200 Subject: [PATCH 03/10] chore: add CI workflow that forces failure --- .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 0000000000..249cc5258a --- /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@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.25.1" + + - name: Force Failure + run: (exit 1) From 496917d38db903d9f85c1a21e3355a42e7f0918a Mon Sep 17 00:00:00 2001 From: Juliana Trombetta Date: Wed, 17 Sep 2025 11:09:01 +0200 Subject: [PATCH 04/10] chore: update CI to run go version instead of force failure --- .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 249cc5258a..53a7e008b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: Force Failure - run: (exit 1) + - name: Print Go version + run: go version From afac443194b5d701835a0d11a149b464ee01cfa0 Mon Sep 17 00:00:00 2001 From: Juliana Trombetta Date: Thu, 18 Sep 2025 11:57:40 +0200 Subject: [PATCH 05/10] test(auth): add unit tests for GetAPIKey --- internal/auth/auth_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 internal/auth/auth_test.go diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 0000000000..0979a7cb90 --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,31 @@ +package auth + +import ( + "net/http" + "testing" +) + +// Example test for a valid header +func TestGetAPIKeyValid(t *testing.T) { + headers := http.Header{} + headers.Set("Authorization", "ApiKey my-secret-key") + + key, err := GetAPIKey(headers) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if key != "my-secret-key" { + t.Fatalf("expected 'my-secret-key', got %s", key) + } +} + +// Example test for a missing header +func TestGetAPIKeyMissing(t *testing.T) { + headers := http.Header{} + + _, err := GetAPIKey(headers) + if err == nil { + t.Fatalf("expected error when Authorization header is missing") + } +} + From e565c222d8c22fa2110a136f14d023a61d855128 Mon Sep 17 00:00:00 2001 From: Juliana Trombetta Date: Thu, 18 Sep 2025 12:23:41 +0200 Subject: [PATCH 06/10] chore(ci): run go tests in workflow --- .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 53a7e008b1..2ee7efe083 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,6 @@ jobs: with: go-version: "1.25.1" - - name: Print Go version - run: go version + - name: Run Tests + run: go test ./... + From bf88d17ddd4b3cd4793ea6abdeba199ad9eb4c9e Mon Sep 17 00:00:00 2001 From: Juliana Trombetta Date: Thu, 18 Sep 2025 12:26:52 +0200 Subject: [PATCH 07/10] test: break test on purpose to check CI failure --- internal/auth/auth_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go index 0979a7cb90..b706e5208c 100644 --- a/internal/auth/auth_test.go +++ b/internal/auth/auth_test.go @@ -14,7 +14,8 @@ func TestGetAPIKeyValid(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - if key != "my-secret-key" { + if key != "wrong-key" { + t.Fatalf("expected 'my-secret-key', got %s", key) } } From d24ac118eb9ef3b7b9f2f47a60692058da1e1a7e Mon Sep 17 00:00:00 2001 From: Juliana Trombetta Date: Thu, 18 Sep 2025 12:31:14 +0200 Subject: [PATCH 08/10] fix: restore correct test key --- internal/auth/auth_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go index b706e5208c..79de6cc5c0 100644 --- a/internal/auth/auth_test.go +++ b/internal/auth/auth_test.go @@ -14,8 +14,7 @@ func TestGetAPIKeyValid(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - if key != "wrong-key" { - + if key != "my-secret-key" { t.Fatalf("expected 'my-secret-key', got %s", key) } } From b14795d75dc5e8bf1171c4893750511ec83de7f3 Mon Sep 17 00:00:00 2001 From: Juliana Trombetta Date: Fri, 19 Sep 2025 10:48:53 +0200 Subject: [PATCH 09/10] chore(ci): add code coverage reporting to 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 2ee7efe083..78a8d8eb81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,6 @@ jobs: with: go-version: "1.25.1" - - name: Run Tests - run: go test ./... + - name: Run Tests with Coverage + run: go test -cover ./... From cc649fbf11f03ebdab232ccd2b5a5f38937d1866 Mon Sep 17 00:00:00 2001 From: Juliana Trombetta Date: Fri, 19 Sep 2025 11:00:23 +0200 Subject: [PATCH 10/10] docs: add CI badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2fddb695d6..bd0ca2d11d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![CI Tests](https://github.com/JulianaTrombetta/learn-cicd-starter/actions/workflows/ci.yml/badge.svg) + # learn-cicd-starter (Notely) This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev).