Skip to content

Added Line to README.md #1804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
aeb8f65
Added Line to README.md
WhileWorkingdoLearn Aug 8, 2025
37a6e81
Merge pull request #1 from WhileWorkingdoLearn/addtests
WhileWorkingdoLearn Aug 8, 2025
8247fda
Added CI
WhileWorkingdoLearn Aug 9, 2025
d649dff
Changed CI
WhileWorkingdoLearn Aug 9, 2025
59ca7c4
Fixed CI
WhileWorkingdoLearn Aug 9, 2025
0eb53d9
failing test
WhileWorkingdoLearn Aug 9, 2025
b60f884
fail2
WhileWorkingdoLearn Aug 9, 2025
ba523a8
f2
WhileWorkingdoLearn Aug 9, 2025
a767dcc
correct
WhileWorkingdoLearn Aug 9, 2025
160e506
Added Cover to Test
WhileWorkingdoLearn Aug 9, 2025
64034ff
Added README Badge
WhileWorkingdoLearn Aug 9, 2025
8d45453
Merge pull request #2 from WhileWorkingdoLearn/addtests
WhileWorkingdoLearn Aug 9, 2025
159b051
Added Formatter Check
WhileWorkingdoLearn Aug 9, 2025
150839b
Merge pull request #3 from WhileWorkingdoLearn/addtests
WhileWorkingdoLearn Aug 9, 2025
d7972d3
Fixed Added Style Formatter
WhileWorkingdoLearn Aug 9, 2025
734b33c
Merge pull request #4 from WhileWorkingdoLearn/addtests
WhileWorkingdoLearn Aug 9, 2025
2cb2483
Fixed Style run
WhileWorkingdoLearn Aug 9, 2025
e1f38fd
Merge pull request #5 from WhileWorkingdoLearn/addtests
WhileWorkingdoLearn Aug 9, 2025
11052f4
added echo
WhileWorkingdoLearn Aug 9, 2025
4f768e8
Update ci.yml
WhileWorkingdoLearn Aug 9, 2025
d753084
Merge pull request #6 from WhileWorkingdoLearn/addtests
WhileWorkingdoLearn Aug 9, 2025
b11b6d2
Update ci.yml
WhileWorkingdoLearn Aug 9, 2025
ce6ec03
print
WhileWorkingdoLearn Aug 9, 2025
2711e7a
Merge pull request #7 from WhileWorkingdoLearn/addtests
WhileWorkingdoLearn Aug 10, 2025
e70c8d9
Update ci.yml
WhileWorkingdoLearn Aug 10, 2025
20f5e9c
style
WhileWorkingdoLearn Aug 10, 2025
7c57240
Merge pull request #8 from WhileWorkingdoLearn/addtests
WhileWorkingdoLearn Aug 10, 2025
bff075e
Update ci.yml
WhileWorkingdoLearn Aug 10, 2025
c4c09c0
fixed workflow yml
WhileWorkingdoLearn Aug 10, 2025
cea01cc
Merge branch 'main' into addtests
WhileWorkingdoLearn Aug 10, 2025
919e28b
empty
WhileWorkingdoLearn Aug 10, 2025
208484a
Style
WhileWorkingdoLearn Aug 10, 2025
bf62533
linter
WhileWorkingdoLearn Aug 10, 2025
5c206a7
linter 2
WhileWorkingdoLearn Aug 10, 2025
d59a0ee
gosec
WhileWorkingdoLearn Aug 10, 2025
8b6d8a9
Fixed errors
WhileWorkingdoLearn Aug 10, 2025
75a8c49
fixed gosec
WhileWorkingdoLearn Aug 10, 2025
3fcc070
fixed gosec
WhileWorkingdoLearn Aug 10, 2025
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
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.23.0"

- name: Go Version
run: go test -cover ./internal/auth

- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: 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.23.0"

- name: Check formatting
run: test -z $(go fmt ./...)

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



5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@


![Test Status](https://github.com/WhileWorkingdoLearn/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 +24,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!

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

import (
"net/http"
"testing"
)

func TestEmpty(t *testing.T) {}

func TestGetAuth(t *testing.T) {

tests := map[string]struct {
input string
want string
err string
}{
"simple": {input: "ApiKey blablabla", want: "blablabla", err: ""},
"no seperator": {input: "ApiKeyblablabla", want: "", err: "malformed authorization header"},
"api key": {input: "ApiKey", want: "", err: "malformed authorization header"},
}

for name, tc := range tests {
t.Run(name, func(t *testing.T) {
header := http.Header{}
header.Add("Authorization", tc.input)
got, err := GetAPIKey(header)
if err != nil {
if err.Error() != tc.err {
t.Fatalf("%s: expected: %v, got: %v, err: %v", name, tc.want, got, err)
}
}
if got != tc.want {
t.Fatalf("%s: expected: %v, got: %v, err: %v", name, tc.want, got, err)
}
})
}
}
5 changes: 4 additions & 1 deletion json.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
return
}
w.WriteHeader(code)
w.Write(dat)
_, errWrite := w.Write(dat)
if errWrite != nil {
log.Printf("Error with writing: %s", err)
}
}
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
"time"

"github.com/go-chi/chi"
"github.com/go-chi/cors"
Expand Down Expand Up @@ -89,10 +90,16 @@ func main() {

router.Mount("/v1", v1Router)
srv := &http.Server{
Addr: ":" + port,
Handler: router,
Addr: ":" + port,
Handler: router,
ReadHeaderTimeout: 3 * time.Second,
}

log.Printf("Serving on port: %s\n", port)
log.Fatal(srv.ListenAndServe())
}

func unused() {
// this function does nothing
// and is called nowhere
}