From 469842952884fb8b3f008b76b8dd3867e3c4e849 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Mon, 27 Apr 2026 20:43:02 +0100 Subject: [PATCH 01/23] add owner to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b7..7451af0d96a 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! + +"Abimbola's version of Boot.dev's Notely app" From 88e72abc18de38e0dedc5f72e45dc42413ad6880 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Mon, 27 Apr 2026 21:33:16 +0100 Subject: [PATCH 02/23] add workflow --- .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..59a49827d03 --- /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/setup-go@v5 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.26.0" + + - name: Foce Failure + run: (exit 1) \ No newline at end of file From cef6585f3276c511725f396fb1cda8421ec38ee8 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Mon, 27 Apr 2026 21:45:58 +0100 Subject: [PATCH 03/23] edit 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 59a49827d03..e13b9ed4672 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.26.0" - - name: Foce Failure - run: (exit 1) \ No newline at end of file + - name: go title + run: go version \ No newline at end of file From 8e33d160c19fd165525f10c4834b311e42aa5256 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Mon, 27 Apr 2026 22:43:42 +0100 Subject: [PATCH 04/23] add ci for tests --- .github/workflows/ci.yml | 4 +- internal/auth/get_api_key_test.go | 62 +++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 internal/auth/get_api_key_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e13b9ed4672..c9b8f080e63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.26.0" - - name: go title - run: go version \ No newline at end of file + - name: run my tests + run: go test ./... \ No newline at end of file diff --git a/internal/auth/get_api_key_test.go b/internal/auth/get_api_key_test.go new file mode 100644 index 00000000000..5ac1cd99d36 --- /dev/null +++ b/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 d75ffb5a25be929ba87ce7e16262e241cb0f66f9 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Mon, 27 Apr 2026 22:54:03 +0100 Subject: [PATCH 05/23] add ci for 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 c9b8f080e63..ba36c62df4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,12 +6,12 @@ on: jobs: tests: - name: tests + name: Tests runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/setup-go@v5 + uses: actions/setup-go@v4 - name: Set up Go uses: actions/setup-go@v5 From c1504476dd8b30a503047f91b313ef119b4b9ad1 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Mon, 27 Apr 2026 22:57:15 +0100 Subject: [PATCH 06/23] add ci for tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba36c62df4f..835185e147f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Check out code - uses: actions/setup-go@v4 + uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 From cef583de163ee13c17676fe712e220367e337c1b Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Mon, 27 Apr 2026 23:09:15 +0100 Subject: [PATCH 07/23] add flag for coverage --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 835185e147f..b6809fc10cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.26.0" - name: run my tests - run: go test ./... \ No newline at end of file + run: go test -cover ./... \ No newline at end of file From 2dc8d45acbc15e9fed0ac22f6dfc36f288ea7723 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Mon, 27 Apr 2026 23:17:41 +0100 Subject: [PATCH 08/23] add test badge to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7451af0d96a..3df0f6994b2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![alt text goes here](https://github.com/abioludipe/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). From 8a23f61e9da8a44e7703fedb4ece9e175509049c Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 10:40:05 +0100 Subject: [PATCH 09/23] add format to ci.yml --- .github/workflows/ci.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6809fc10cc..efb98dc7ab6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,20 @@ jobs: go-version: "1.26.0" - name: run my tests - run: go test -cover ./... \ No newline at end of file + 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.26.0" + + - name: formot code + run: test -z $(go fmt ./...) From d275d5fe0636eb2e00ca35174d93c6a02675ce21 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 12:39:06 +0100 Subject: [PATCH 10/23] add linting --- .github/workflows/ci.yml | 4 ++++ main.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efb98dc7ab6..3b53f980d8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,3 +36,7 @@ jobs: - name: formot code run: test -z $(go fmt ./...) + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + diff --git a/main.go b/main.go index 19d7366c5f7..a621713c2bd 100644 --- a/main.go +++ b/main.go @@ -96,3 +96,8 @@ func main() { log.Printf("Serving on port: %s\n", port) log.Fatal(srv.ListenAndServe()) } + +func unused() { + // this function does nothing + // and is called nowhere +} From 2fff1f0d26205661cc2771a9f45158cde5bfc644 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 12:42:24 +0100 Subject: [PATCH 11/23] add linting --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b53f980d8a..0e58738e039 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,4 +39,7 @@ jobs: - name: Install staticcheck run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: run staticcheck + run: staticcheck ./... From 6163741f911a07c89a2738bf289b711237785624 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 12:45:02 +0100 Subject: [PATCH 12/23] add linting --- main.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/main.go b/main.go index a621713c2bd..19d7366c5f7 100644 --- a/main.go +++ b/main.go @@ -96,8 +96,3 @@ func main() { log.Printf("Serving on port: %s\n", port) log.Fatal(srv.ListenAndServe()) } - -func unused() { - // this function does nothing - // and is called nowhere -} From 3f5c5eab35b976d4610ef109a02cce085a34650b Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 12:58:19 +0100 Subject: [PATCH 13/23] add gosec check --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e58738e039..237aa92ad09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,12 @@ jobs: - name: run my 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 From da2036845573b2ed140f9c4b53e1ec1d597c93c0 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 15:32:35 +0100 Subject: [PATCH 14/23] add gosec check --- main.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 19d7366c5f7..295dde9b42a 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,8 @@ import ( "log" "net/http" "os" + "time" + "strconv" "github.com/go-chi/chi" "github.com/go-chi/cors" @@ -87,12 +89,17 @@ func main() { v1Router.Get("/healthz", handlerReadiness) + p, err := strconv.Atoi(port) + if err != nil || p < 1 || p > 65535 { + log.Fatal("invalid port") + router.Mount("/v1", v1Router) srv := &http.Server{ - Addr: ":" + port, - Handler: router, + Addr: ":" + strconv.Itoa(p), + Handler: router, + ReadHeaderTimeout: 5 * time.Second, } - log.Printf("Serving on port: %s\n", port) + log.Printf("Serving on port: %d", p) log.Fatal(srv.ListenAndServe()) } From b604192f891eae0a0a6c9340be062ffc41adfb20 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 15:42:44 +0100 Subject: [PATCH 15/23] add gosec check --- json.go | 5 ++++- main.go | 11 +++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/json.go b/json.go index 1e6e7985e18..c529c90c124 100644 --- a/json.go +++ b/json.go @@ -30,5 +30,8 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { return } w.WriteHeader(code) - w.Write(dat) + _, err = w.Write(dat) + if err != nil { + log.Printf("Critical error writing response: %s", err) + } } diff --git a/main.go b/main.go index 295dde9b42a..ec86bb7bf95 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,6 @@ import ( "net/http" "os" "time" - "strconv" "github.com/go-chi/chi" "github.com/go-chi/cors" @@ -89,17 +88,13 @@ func main() { v1Router.Get("/healthz", handlerReadiness) - p, err := strconv.Atoi(port) - if err != nil || p < 1 || p > 65535 { - log.Fatal("invalid port") - router.Mount("/v1", v1Router) srv := &http.Server{ - Addr: ":" + strconv.Itoa(p), + Addr: ":" + port, Handler: router, - ReadHeaderTimeout: 5 * time.Second, + ReadHeaderTimeout: time.Second * 5, } - log.Printf("Serving on port: %d", p) + log.Printf("Serving on port: %s\n", port) log.Fatal(srv.ListenAndServe()) } From ebd05b965634778d9ac03487328a451cf1d7bb02 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 15:46:15 +0100 Subject: [PATCH 16/23] add gosec check --- .env | 1 + .gitignore | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 00000000000..8d70f531470 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +PORT="8080" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2092f54e78a..02433f9dd1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ out -.env learn-cicd-starter notely From c210d375a145004090e4ee8e363dbfb338e57f94 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 15:51:09 +0100 Subject: [PATCH 17/23] add gosec check --- .env | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 8d70f531470..00000000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -PORT="8080" \ No newline at end of file From efa20c837bc7d83e6e89ede01e1c25e5709d0077 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 15:59:57 +0100 Subject: [PATCH 18/23] add gosec check --- .gitignore | 1 + main.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 02433f9dd1e..2092f54e78a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ out +.env learn-cicd-starter notely diff --git a/main.go b/main.go index ec86bb7bf95..e7362cf29ee 100644 --- a/main.go +++ b/main.go @@ -95,6 +95,6 @@ func main() { ReadHeaderTimeout: time.Second * 5, } - log.Printf("Serving on port: %s\n", port) + log.Println("Serving HTTP server") log.Fatal(srv.ListenAndServe()) } From f29ab1b6b4586231b1c2b9a0653103b86ccc9070 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 16:41:58 +0100 Subject: [PATCH 19/23] add cd.yml --- .github/workflows/cd.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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..ea1291477b3 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,28 @@ +name: ci + +on: + push: + branches: [main] + +jobs: + Deploy: + 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.26.0" + + - name: Build Application + run: | + chmod +x scripts/buildprod.sh + ./scripts/buildprod.sh + + + + + From 34d408320db1ace25d3f3fac8f09e96cf8465d2e Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 18:19:01 +0100 Subject: [PATCH 20/23] add cd.yml --- .github/workflows/cd.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ea1291477b3..bf8cb032b8e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -22,7 +22,19 @@ jobs: chmod +x scripts/buildprod.sh ./scripts/buildprod.sh - + steps: + - id: 'auth' + uses: 'google-github-actions/auth@v2' + with: + credentials_json: ${{secrets.GCP_CREDENTIALS}} + + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v3' + with: + version: '>= 363.0.0' + + - name: 'Use gcloud CLI' + run: 'gcloud info' From 8295e86714b98a93ea445694715eeda2c9174e4c Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 18:26:46 +0100 Subject: [PATCH 21/23] add cd.yml --- .github/workflows/cd.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index bf8cb032b8e..aa9d57b50fe 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -22,19 +22,18 @@ jobs: chmod +x scripts/buildprod.sh ./scripts/buildprod.sh - steps: - - id: 'auth' - uses: 'google-github-actions/auth@v2' - with: - credentials_json: ${{secrets.GCP_CREDENTIALS}} - - - name: 'Set up Cloud SDK' - uses: 'google-github-actions/setup-gcloud@v3' - with: - version: '>= 363.0.0' - - - name: 'Use gcloud CLI' - run: 'gcloud info' + - id: auth + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{secrets.GCP_CREDENTIALS}} + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v3 + with: + version: '>= 363.0.0' + + - name: Use gcloud CLI + run: gcloud info From 4e603267f263977852a9928e564bcc45ebb5aa64 Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Tue, 28 Apr 2026 18:38:49 +0100 Subject: [PATCH 22/23] add cd.yml --- .github/workflows/cd.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index aa9d57b50fe..31096d85bf6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -35,5 +35,8 @@ jobs: - name: Use gcloud CLI run: gcloud info + - name: Build image + run: gcloud builds submit --tag us-central1-docker.pkg.dev/notely-494716/notely-ar-repo/notely:latest . + From a76575cb2d1a860e88f55529ef44310b7ab1612b Mon Sep 17 00:00:00 2001 From: Abimbola Oludipe Date: Wed, 29 Apr 2026 10:59:59 +0100 Subject: [PATCH 23/23] change app welcome message --- .github/workflows/cd.yml | 6 +++++- static/index.html | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 31096d85bf6..e516b5dc1fb 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -38,5 +38,9 @@ jobs: - name: Build image run: gcloud builds submit --tag us-central1-docker.pkg.dev/notely-494716/notely-ar-repo/notely:latest . - + - name: deploy + run: gcloud run deploy notely --image us-central1-docker.pkg.dev/notely-494716/notely-ar-repo/notely:latest --region us-central1 --allow-unauthenticated --project notely-494716 --max-instance=4 + + + \ No newline at end of file diff --git a/static/index.html b/static/index.html index 72be101028c..5d4ad73c095 100644 --- a/static/index.html +++ b/static/index.html @@ -7,7 +7,7 @@ -

Notely

+

Welcome to Notely