From 129ad355f075eff995bf8a6ca83bed21164deb6f Mon Sep 17 00:00:00 2001 From: itselcid Date: Tue, 9 Dec 2025 11:27:01 +0100 Subject: [PATCH 01/10] my version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2bec0368b7..92b6839aaa1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # learn-cicd-starter (Notely) - +elcid's version of Boot.dev's Notely app. This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). ## Local Development From 829bc70439c822227cada79e7748d479dfbc16ce Mon Sep 17 00:00:00 2001 From: itselcid Date: Tue, 9 Dec 2025 11:31:42 +0100 Subject: [PATCH 02/10] v2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92b6839aaa1..1be67d534e0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # learn-cicd-starter (Notely) -elcid's version of Boot.dev's Notely app. +elcid's version of Boot.dev's Notely app . This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). ## Local Development From 17a19347c5ad600c8299b887e5b0aa6798791bfb Mon Sep 17 00:00:00 2001 From: itselcid Date: Tue, 9 Dec 2025 11:33:57 +0100 Subject: [PATCH 03/10] v3 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1be67d534e0..4481074f11d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # learn-cicd-starter (Notely) -elcid's version of Boot.dev's Notely app . + elcid's version of Boot.dev's Notely app . This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). ## Local Development From bad41e710a438ca2e3705042ce2456abc4f0d79e Mon Sep 17 00:00:00 2001 From: itselcid Date: Tue, 9 Dec 2025 12:04:48 +0100 Subject: [PATCH 04/10] ci workflow test --- .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 00000000000..a54d8248d54 --- /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) \ No newline at end of file From 204c9b7b452478c0d8c47e979c181e4a6f319a5d Mon Sep 17 00:00:00 2001 From: itselcid Date: Tue, 9 Dec 2025 12:13:17 +0100 Subject: [PATCH 05/10] get the go version --- .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 a54d8248d54..3e8e125b2fe 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) \ No newline at end of file + - name: get go version + run: go version \ No newline at end of file From 348159c1b351bd37eb111a7f95fdb243d7244abf Mon Sep 17 00:00:00 2001 From: itselcid Date: Tue, 9 Dec 2025 14:13:22 +0100 Subject: [PATCH 06/10] testing ci tests --- .github/workflows/ci.yml | 4 +-- internal/auth/auth.go | 2 +- internal/auth/auth_test.go | 67 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 internal/auth/auth_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e8e125b2fe..f692292024b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: get go version - run: go version \ No newline at end of file + - name: run tests + run: go test ./... \ No newline at end of file diff --git a/internal/auth/auth.go b/internal/auth/auth.go index f969aacf638..4faaf83453e 100644 --- a/internal/auth/auth.go +++ b/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) < 2 || splitAuth[0] != "Api" { return "", errors.New("malformed authorization header") } diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 00000000000..67a6a130652 --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,67 @@ +package auth + +import ( + "net/http" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + tests := []struct { + name string + headers http.Header + expectedKey string + expectedError error + }{ + { + name: "Valid API Key", + headers: http.Header{ + "Authorization": []string{"ApiKey test-api-key-123"}, + }, + expectedKey: "test-api-key-123", + expectedError: nil, + }, + { + name: "No Authorization Header", + headers: http.Header{}, + expectedKey: "", + expectedError: ErrNoAuthHeaderIncluded, + }, + { + name: "Malformed Authorization Header - Missing ApiKey prefix", + headers: http.Header{ + "Authorization": []string{"Bearer test-token"}, + }, + expectedKey: "", + expectedError: nil, // Will check error message instead + }, + { + name: "Malformed Authorization Header - No space", + headers: http.Header{ + "Authorization": []string{"ApiKeytest-api-key"}, + }, + expectedKey: "", + expectedError: nil, // Will check error message instead + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + key, err := GetAPIKey(tt.headers) + + if key != tt.expectedKey { + t.Errorf("Expected key %q, got %q", tt.expectedKey, key) + } + + if tt.expectedError != nil { + if err != tt.expectedError { + t.Errorf("Expected error %v, got %v", tt.expectedError, err) + } + } else if tt.name != "Valid API Key" { + // For malformed header tests, just check that an error occurred + if err == nil { + t.Errorf("Expected an error for malformed header, got nil") + } + } + }) + } +} From 2768c2ac90af4989e6459325905ed1328de41b06 Mon Sep 17 00:00:00 2001 From: itselcid Date: Tue, 9 Dec 2025 14:15:28 +0100 Subject: [PATCH 07/10] fixed the code --- internal/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 4faaf83453e..f969aacf638 100644 --- a/internal/auth/auth.go +++ b/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] != "Api" { + if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { return "", errors.New("malformed authorization header") } From e0de583731be0ae8cbb3540884cf93a632694e38 Mon Sep 17 00:00:00 2001 From: itselcid Date: Wed, 10 Dec 2025 16:11:37 +0100 Subject: [PATCH 08/10] cover is been added --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f692292024b..1fd88003222 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,5 @@ jobs: go-version: "1.25.1" - name: run tests - run: go test ./... \ No newline at end of file + run: go test -cover ./... + \ No newline at end of file From ac436cc8811759224e7e6b41fa647b94b47fc4e6 Mon Sep 17 00:00:00 2001 From: itselcid Date: Wed, 10 Dec 2025 16:31:19 +0100 Subject: [PATCH 09/10] made the dynamuc badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4481074f11d..6810889600c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![ci](https://github.com/itselcid/learn-cicd-starter/actions/workflows/ci.yml/badge.svg)](https://github.com/itselcid/learn-cicd-starter/actions/workflows/ci.yml) # learn-cicd-starter (Notely) elcid's version of Boot.dev's Notely app . This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). From bbbe03fe6fb41e8ac2aae3d913f338c21d200db0 Mon Sep 17 00:00:00 2001 From: itselcid Date: Wed, 10 Dec 2025 17:09:39 +0100 Subject: [PATCH 10/10] deplyment cd --- .github/workflows/cd.yml | 21 +++++++++++++++++++++ README.md | 8 +++++--- 2 files changed, 26 insertions(+), 3 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 00000000000..81390f0ca12 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,21 @@ +name: cd +on: + push: + branches: [main] + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.25.1" + + - name: Build + run: ./scripts/buildprod.sh \ No newline at end of file diff --git a/README.md b/README.md index 6810889600c..9b7eff34668 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ [![ci](https://github.com/itselcid/learn-cicd-starter/actions/workflows/ci.yml/badge.svg)](https://github.com/itselcid/learn-cicd-starter/actions/workflows/ci.yml) + # learn-cicd-starter (Notely) - elcid's version of Boot.dev's Notely app . + +elcid's version of Boot.dev's Notely app . This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). ## Local Development @@ -19,6 +21,6 @@ Run the server: go build -o notely && ./notely ``` -*This starts the server in non-database mode.* It will serve a simple webpage at `http://localhost:8080`. +_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! +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!