Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8de8284
Update to README
gabyrod7 Jan 16, 2026
6f3a4c4
Add basic CI .yml file
gabyrod7 Jan 16, 2026
37ec7a2
Update failing test to -go version-
gabyrod7 Jan 16, 2026
39f06a9
Add tests for auth.go and include them in the ci.yml file.
gabyrod7 Jan 16, 2026
574fe1f
Remove test designed to fail
gabyrod7 Jan 16, 2026
c4007c1
Update go tests with -cover flag
gabyrod7 Jan 16, 2026
7669587
Add badge to README
gabyrod7 Jan 16, 2026
ed1df93
Add style formatting job to CI
gabyrod7 Jan 17, 2026
96d4e22
Fix ci.yml file. Was missing some important lines
gabyrod7 Jan 17, 2026
27fce3c
Add linting with staticcheck to CI pipeline and a failing main.go file.
gabyrod7 Jan 17, 2026
58de0bd
main.go failed format test... no the fail I was looking for
gabyrod7 Jan 17, 2026
b8706e5
remove unnecessary code in main.go so that the test passes
gabyrod7 Jan 17, 2026
c5f1838
Add a security check with gosec
gabyrod7 Jan 17, 2026
c6cf76f
Fix security issues identified by gosec
gabyrod7 Jan 17, 2026
7c55c59
Fix formatting issues in main.go and json.go
gabyrod7 Jan 17, 2026
026f66e
Add CD pipeline
gabyrod7 Jan 17, 2026
20d3299
Fixed typo in cd.yml
gabyrod7 Jan 17, 2026
74a3a18
Add a gcloud build and submit step to CD pipeline
gabyrod7 Jan 18, 2026
20527e8
Fix indentation in cd.yml
gabyrod7 Jan 18, 2026
2bf2fc0
.
gabyrod7 Jan 18, 2026
f0d1230
Fix gcloud command in cd.yml
gabyrod7 Jan 18, 2026
f7a2502
Add deploy to Cloud Run step to CD pipeline
gabyrod7 Jan 18, 2026
bbbde05
Add turso to CD pipeline
gabyrod7 Jan 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: cd

on:
push:
branches: [main]

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}

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: Install goose
run: go install github.com/pressly/goose/v3/cmd/goose@latest

- name: Run build script
run: ./scripts/buildprod.sh

- name: Run migration
run: ./scripts/migrateup.sh

- 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

- name: Use gcloud CLI
run: gcloud builds submit --tag europe-west6-docker.pkg.dev/notely-484713/notely-ar-repo/notely:latest .

- name: Deploy to Cloud Run
run: gcloud run deploy notely --image europe-west6-docker.pkg.dev/notely-484713/notely-ar-repo/notely:latest --region europe-west6 --allow-unauthenticated --project notely-484713 --max-instances=4
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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: Run Go 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
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: Format Go code
run: test -z $(go fmt ./...)

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Run staticcheck
run: staticcheck ./...
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![](https://github.com/gabyrod7/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).
Expand All @@ -21,3 +23,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!

Gabriel's version of Boot.dev's Notely app.
48 changes: 48 additions & 0 deletions internal/auth/auth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package auth

import (
"net/http"
"testing"
)

func TestGetAPIKey_ValidHeader(t *testing.T) {
h := http.Header{}
h.Set("Authorization", "ApiKey abc123")

key, err := GetAPIKey(h)
if err != nil {
t.Fatalf("expected no error, got %v", err)
}
if key != "abc123" {
t.Fatalf("expected key %q, got %q", "abc123", key)
}
}

func TestGetAPIKey_MissingHeader(t *testing.T) {
h := http.Header{}

_, err := GetAPIKey(h)
if err != ErrNoAuthHeaderIncluded {
t.Fatalf("expected ErrNoAuthHeaderIncluded, got %v", err)
}
}

func TestGetAPIKey_WrongScheme(t *testing.T) {
h := http.Header{}
h.Set("Authorization", "Bearer abc123")

_, err := GetAPIKey(h)
if err == nil {
t.Fatal("expected error, got nil")
}
}

func TestGetAPIKey_MalformedHeader(t *testing.T) {
h := http.Header{}
h.Set("Authorization", "ApiKey")

_, err := GetAPIKey(h)
if err == nil {
t.Fatal("expected error, got nil")
}
}
6 changes: 5 additions & 1 deletion json.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
return
}
w.WriteHeader(code)
w.Write(dat)
if _, err := w.Write(dat); err != nil {
// At this point headers are already sent, so we can only log.
log.Printf("failed to write response: %v", err)
}

}
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ func main() {

router.Mount("/v1", v1Router)
srv := &http.Server{
Addr: ":" + port,
Handler: router,
Addr: ":" + port,
Handler: router,
ReadHeaderTimeout: 5_000_000_000, // nanoseconds
}

log.Printf("Serving on port: %s\n", port)
Expand Down
2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</head>

<body class="section">
<h1>Notely</h1>
<h1>Welcome to Notely</h1>

<div id="userCreationContainer" class="section">
<input id="nameField" type="text" placeholder="Enter your name">
Expand Down