Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
607903a
Update README with my version
abdoulbchir Apr 28, 2026
a977f2a
add wokflows
abdoulbchir Apr 28, 2026
37c10ef
fix: move ci.yml to workflows folder
abdoulbchir Apr 28, 2026
934726a
pass workflows code
abdoulbchir Apr 28, 2026
2714230
pass workflows ERROR GO TEST
abdoulbchir Apr 28, 2026
caa6868
pass workflows VALIDATION GO TEST
abdoulbchir Apr 28, 2026
cbb7d56
pass workflows VALIDATION GO COVER TEST
abdoulbchir Apr 28, 2026
333a0b3
add CI badge to README
abdoulbchir Apr 28, 2026
7c30f29
add FORMAT GO
abdoulbchir Apr 29, 2026
f66717c
UPDATE FORMAT GO
abdoulbchir Apr 29, 2026
2509c09
add static test
abdoulbchir Apr 29, 2026
e4e5acb
delete unset static test
abdoulbchir Apr 29, 2026
9525f06
update ci static test
abdoulbchir Apr 29, 2026
a9f07a8
update vf ci static test
abdoulbchir Apr 29, 2026
e26005b
Fix Go formatting
abdoulbchir Apr 29, 2026
5401f50
Trigger CI
abdoulbchir Apr 29, 2026
c6508ec
update ci version fin
abdoulbchir Apr 29, 2026
4b0e9d2
update main version fin
abdoulbchir Apr 29, 2026
ebe6916
Fix Go formatting
abdoulbchir Apr 29, 2026
825918f
Fix Go formatting
abdoulbchir Apr 29, 2026
45370b7
Exclude vendor from formatting check
abdoulbchir Apr 29, 2026
53c9b0e
Format vendor dependencies
abdoulbchir Apr 29, 2026
3b27b73
Format main.go
abdoulbchir Apr 29, 2026
65e2c1c
Format ci.yiml
abdoulbchir Apr 29, 2026
b0599a4
add gosec to ci.yiml
abdoulbchir Apr 29, 2026
6fe6296
Fix gosec security issues
abdoulbchir Apr 29, 2026
cde1268
Fix formatting
abdoulbchir Apr 29, 2026
6f31053
Add CD workflow
abdoulbchir Apr 29, 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
22 changes: 22 additions & 0 deletions .github/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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.26.0"

- name: Force Failure
run: (exit 1)
21 changes: 21 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
push:
branches: [main]
jobs:
Deploy:
name: 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.25.1"

- name: Run unit tests
run: go test ./... -cover
- name: Run code
run: scripts/buildprod.sh
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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 unit tests
run: go test ./... -cover

- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Run gosec
run: gosec ./...
- name: passcode
run: (exit 0)
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: Check formatting
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,6 @@
![CI](https://github.com/abdoulbchir/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,4 @@ 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!
"abdoulbchir's version of Boot.dev's Notely app."
53 changes: 53 additions & 0 deletions internal/auth/get_api_key_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package auth

import (
"net/http"
"testing"
)

func TestGetAPIKey(t *testing.T) {
tests := []struct {
name string
headers http.Header
expectedKey string
expectError bool
}{
{
name: "Pas de header Authorization",
headers: http.Header{},
expectedKey: "",
expectError: true,
},
{
name: "Format incorrect - Bearer",
headers: http.Header{
"Authorization": []string{"Bearer token123"},
},
expectedKey: "",
expectError: true,
},
{
name: "Header valide avec ApiKey",
headers: http.Header{
"Authorization": []string{"ApiKey ma_cle_secrete"},
},
expectedKey: "ma_cle_secrete",
expectError: false,
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
key, err := GetAPIKey(tc.headers)
if tc.expectError && err == nil {
t.Errorf("Erreur attendue mais aucune erreur retournée")
}
if !tc.expectError && err != nil {
t.Errorf("Aucune erreur attendue mais got: %v", err)
}
if key != tc.expectedKey {
t.Errorf("Attendu '%s', obtenu '%s'", tc.expectedKey, key)
}
})
}
}
4 changes: 3 additions & 1 deletion json.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
return
}
w.WriteHeader(code)
w.Write(dat)
if _, err := w.Write(dat); err != nil {
log.Printf("error writing response: %v", err)
}
}
15 changes: 8 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package main
import (
"database/sql"
"embed"
"github.com/go-chi/chi"
"github.com/go-chi/cors"
"github.com/joho/godotenv"
"io"
"log"
"net/http"
"os"

"github.com/go-chi/chi"
"github.com/go-chi/cors"
"github.com/joho/godotenv"
"time"

"github.com/bootdotdev/learn-cicd-starter/internal/database"

Expand Down Expand Up @@ -89,10 +89,11 @@ func main() {

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

log.Printf("Serving on port: %s\n", port)
log.Println("Serving on port: " + port) // #nosec G706
log.Fatal(srv.ListenAndServe())
}
42 changes: 21 additions & 21 deletions vendor/github.com/go-chi/chi/chi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions vendor/github.com/go-chi/chi/context.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions vendor/github.com/go-chi/cors/cors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/google/uuid/dce.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/google/uuid/hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/google/uuid/node_js.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/google/uuid/node_net.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions vendor/github.com/google/uuid/null.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading