From 413a6d814b0b980041083b50192a6f5e9e092199 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Tue, 5 Aug 2025 14:30:04 +0200 Subject: [PATCH 01/28] Add personalized line to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c2bec0368b..023ac3e80b 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,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! +Niveditha's version of Boot.dev's Notely app. From ec5d9f029646e5d95344217188445bed8cabf208 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Tue, 5 Aug 2025 16:22:36 +0200 Subject: [PATCH 02/28] Add CI workflow that fails --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 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 0000000000..da11e29497 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +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: Force Failure + run: (exit 1) + From f73ab411f258121b1b23a5e6473e4c43e0046526 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Tue, 5 Aug 2025 16:40:19 +0200 Subject: [PATCH 03/28] Add CI workflow that pass --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da11e29497..7f4c422036 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,5 +19,4 @@ jobs: go-version: "1.23.0" - name: Force Failure - run: (exit 1) - + run: exit 0 From 251aae3a21125498b94e5dd79cf5e4712a42a8fe Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Tue, 5 Aug 2025 16:58:47 +0200 Subject: [PATCH 04/28] Update CI to run go version instead of force failure --- .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 7f4c422036..91235dc8b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.23.0" - - name: Force Failure - run: exit 0 + - name: Show Go Version + run: go version From cefc0b63cb71d3c8668c4cfeb3f1eb49cf4290d9 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 14:08:22 +0200 Subject: [PATCH 05/28] Add failing test to verify CI detects failure --- internal/auth/auth_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 internal/auth/auth_test.go diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 0000000000..fa57e3c2b1 --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,33 @@ +package auth + +import ( + "net/http" + "testing" +) + +func TestGetAPIKey_Success(t *testing.T) { + headers := http.Header{} + headers.Set("Authorization", "ApiKey 12345") + + key, err := GetAPIKey(headers) + if err != nil { + t.Fatalf("Expected no error, got %v", err) + } + + if key != "12345" { + t.Errorf("Expected key '12345', got '%s'", key) + } +} + +func TestGetAPIKey_MissingHeader(t *testing.T) { + headers := http.Header{} + + _, err := GetAPIKey(headers) + if err == nil { + t.Fatal("Expected an error, got nil") + } +} + +func TestGetAPIKey_MissingHeader(t *testing.T) { + t.Fatal("Intentionally failing test to verify CI catches failures") +} From 5a4e0b1d5647ba0f0b681fa80394d33fd8908d75 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 14:13:03 +0200 Subject: [PATCH 06/28] Remove failing test to fix CI --- internal/auth/auth_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go index fa57e3c2b1..e97f078af6 100644 --- a/internal/auth/auth_test.go +++ b/internal/auth/auth_test.go @@ -28,6 +28,4 @@ func TestGetAPIKey_MissingHeader(t *testing.T) { } } -func TestGetAPIKey_MissingHeader(t *testing.T) { - t.Fatal("Intentionally failing test to verify CI catches failures") -} + From 9f2c720853acd16b8666cf620f379cc07fbe3577 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 14:31:10 +0200 Subject: [PATCH 07/28] Break tests to verify CI fails --- .github/workflows/ci.yml | 10 +++------- .idea/.gitignore | 3 +++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/learn-cicd-starter.iml | 8 ++++++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ package-lock.json | 6 ++++++ 8 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/learn-cicd-starter.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 package-lock.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91235dc8b1..b18cfbfc3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,6 @@ jobs: - name: Check out code uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: "1.23.0" - - - name: Show Go Version - run: go version + + - name: Run Unit Tests + run: go test ./... diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000..26d33521af --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000..105ce2da2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/learn-cicd-starter.iml b/.idea/learn-cicd-starter.iml new file mode 100644 index 0000000000..d0876a78d0 --- /dev/null +++ b/.idea/learn-cicd-starter.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000..dfe3a26f93 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000..d0adac68cd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000..35eb1ddfbb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000000..6c19ba9aa3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "learn-cicd-starter", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} From 631749c8a166fc6549baadaf325092daef899fd2 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 14:41:30 +0200 Subject: [PATCH 08/28] Fix: restored working code for passing tests --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b18cfbfc3d..1df120abe5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,5 +14,7 @@ jobs: uses: actions/checkout@v4 - - name: Run Unit Tests - run: go test ./... + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.23.0 From 05d25177d039b5585bc14d92ac7aa17ed7634d7f Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 14:45:05 +0200 Subject: [PATCH 09/28] Fix: restored working code for passing tests --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1df120abe5..d8c539a3f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,4 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.23.0 + go-version: '1.20' + + - name: Run tests + run: go test ./... From da2d2dc083c50fe32db681eeaa485db0b7a6e8ca Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 14:50:20 +0200 Subject: [PATCH 10/28] Fix CI workflow YAML syntax --- .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 d8c539a3f3..c4244b47f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22.0' - name: Run tests run: go test ./... From bb1db7e6d6d0db23c739db8364f163f62bd4f0e3 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 15:41:57 +0200 Subject: [PATCH 11/28] Fix CI workflow YAML syntax --- .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 c4244b47f4..e976a669b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,5 +19,5 @@ jobs: with: go-version: '1.22.0' - - name: Run tests - run: go test ./... + - name: Run tests with coverage + run: go test -cover ./... From da66b9afa90045feb02d97adaea4a73b8159ce56 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 15:47:07 +0200 Subject: [PATCH 12/28] Add CI status badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 023ac3e80b..d6c0437952 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![Tests](https://github.com/N123p/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 9dd55b0dff9931e93776d14d398f4bc69ecf064e Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 20:17:12 +0200 Subject: [PATCH 13/28] Add style job to CI to check formatting --- .github/workflows/ci.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e976a669b7..8599a7e749 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,3 +21,20 @@ jobs: - name: Run tests with coverage 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.22' + + - name: Run formatting check + run: test -z $(go fmt ./...) From dd3dec2452dd01082a18e6419a92a07c7bd586ad Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 20:22:12 +0200 Subject: [PATCH 14/28] Add style job to CI to check formatting --- .github/workflows/ci.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8599a7e749..ee6ae5b23b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,14 +20,13 @@ jobs: go-version: '1.22.0' - name: Run tests with coverage - run: go test -cover ./... - - - style: + run: go test ./... + + style: name: Style runs-on: ubuntu-latest - steps: + steps: - name: Check out code uses: actions/checkout@v4 From 36a155634b1ebfe9375f1dba748775a7f7f92cf3 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 20:26:17 +0200 Subject: [PATCH 15/28] Add style job to CI to check formatting --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee6ae5b23b..bae84a36f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,6 @@ jobs: - name: Check out code uses: actions/checkout@v4 - - name: Set up Go uses: actions/setup-go@v5 with: @@ -21,12 +20,12 @@ jobs: - name: Run tests with coverage run: go test ./... - - style: + + style: name: Style runs-on: ubuntu-latest - steps: + steps: - name: Check out code uses: actions/checkout@v4 @@ -37,3 +36,4 @@ jobs: - name: Run formatting check run: test -z $(go fmt ./...) + From 467ddf322fc4bc8d70ce437cc409dba73413e60b Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 20:37:36 +0200 Subject: [PATCH 16/28] Add style job to CI and update tests --- internal/auth/auth_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go index e97f078af6..e5ae617ff6 100644 --- a/internal/auth/auth_test.go +++ b/internal/auth/auth_test.go @@ -27,5 +27,3 @@ func TestGetAPIKey_MissingHeader(t *testing.T) { t.Fatal("Expected an error, got nil") } } - - From 9bdaa31ac772328d8d73712eff637922a35eb1ca Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 20:41:06 +0200 Subject: [PATCH 17/28] Fix indentation to enable 'style' job --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bae84a36f2..3d21b75395 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,4 +36,3 @@ jobs: - name: Run formatting check run: test -z $(go fmt ./...) - From d1e79bee583e4597ec0606eb106879587d444285 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 20:51:52 +0200 Subject: [PATCH 18/28] Add parallel style and test jobs to CI --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d21b75395..29ad9d8f3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,8 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.22' + go-version: '1.22.0' - name: Run formatting check - run: test -z $(go fmt ./...) + run: test -z "$(go fmt ./...)" + From dd9f968396778792b8bd936f047cb04dc6edf3cc Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 20:57:52 +0200 Subject: [PATCH 19/28] Fix formatting issues --- .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 29ad9d8f3e..de21daac6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,5 +35,5 @@ jobs: go-version: '1.22.0' - name: Run formatting check - run: test -z "$(go fmt ./...)" + run: test -z $(go fmt ./...) From 4d719ef82b48bf522d549f8d762fb42db6beb8ff Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Wed, 6 Aug 2025 21:03:49 +0200 Subject: [PATCH 20/28] Fix formatting issues --- .github/workflows/ci.yml | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de21daac6d..d8a1c1785a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,39 +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 + + - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.22.0' - + - name: Run tests with coverage run: go test ./... - - 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.22.0' - - - name: Run formatting check - run: test -z $(go fmt ./...) - From d0526a8d932230406894f6c33361d1fe12cda409 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Thu, 7 Aug 2025 08:54:52 +0200 Subject: [PATCH 21/28] Add style job to check Go formatting --- .github/workflows/ci.yml | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8a1c1785a..6ba01138d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,22 +1,39 @@ 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 + + - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.22.0' - - - name: Run tests with coverage - run: go test ./... + go-version: 1.22 + + - name: Run tests + 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.22 + + - name: Check Go formatting + run: test -z "$(go fmt ./...)" + From d0c7f819238d3128478b9785c18e5a8c6c11ad06 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Thu, 7 Aug 2025 09:10:36 +0200 Subject: [PATCH 22/28] Add style job to check Go formatting --- .github/workflows/ci.yml | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ba01138d0..61b6dff0a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,39 +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 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 with: - go-version: 1.22 - + go-version: '1.20' - name: Run tests - run: go test -cover ./... + run: go test ./... 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 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 with: - go-version: 1.22 - + go-version: '1.20' - name: Check Go formatting - run: test -z "$(go fmt ./...)" + run: test -z $(go fmt ./...) From 8b11db6313e3d400b99ce0193c5409ab5bc613e5 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Thu, 7 Aug 2025 09:13:10 +0200 Subject: [PATCH 23/28] Add style job to check Go formatting --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61b6dff0a2..897b4ed848 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,10 @@ +name: Go CI + +on: + pull_request: + branches: + - main + jobs: tests: runs-on: ubuntu-latest From 12f6bfe6ea1d6cf4c22832eda500a2a11b7e5b43 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Thu, 7 Aug 2025 09:15:47 +0200 Subject: [PATCH 24/28] Add style job to check Go formatting --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 897b4ed848..37186bde54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,5 +25,10 @@ jobs: with: go-version: '1.20' - name: Check Go formatting - run: test -z $(go fmt ./...) + run: | + if [ -n "$(gofmt -l .)" ]; then + echo "Files need formatting:" + gofmt -l . + exit 1 + fi From c2d0f9fee1c244509a18ba274812e7299bfd2de6 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Thu, 7 Aug 2025 09:19:49 +0200 Subject: [PATCH 25/28] Add style job to check Go formatting --- .github/workflows/ci.yml | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37186bde54..1981e3d2ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,34 +1,43 @@ -name: Go CI +name: ci on: pull_request: - branches: - - main + branches: [main] jobs: tests: + name: Tests runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: 1.22 + - name: Run tests - run: go test ./... + run: go test -cover ./... style: name: Style runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: 1.22 + - name: Check Go formatting run: | if [ -n "$(gofmt -l .)" ]; then - echo "Files need formatting:" + echo "The following files need formatting:" gofmt -l . exit 1 fi - From ed4cedafbac86ac2a02d34d224c8bb2840342271 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Thu, 7 Aug 2025 09:46:21 +0200 Subject: [PATCH 26/28] Add style job to check Go formatting --- .github/workflows/ci.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1981e3d2ad..6ba01138d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,9 +35,5 @@ jobs: go-version: 1.22 - name: Check Go formatting - run: | - if [ -n "$(gofmt -l .)" ]; then - echo "The following files need formatting:" - gofmt -l . - exit 1 - fi + run: test -z "$(go fmt ./...)" + From 15d268f4d56fb4ca1b5b571c3824671083aa8054 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Thu, 7 Aug 2025 09:53:58 +0200 Subject: [PATCH 27/28] Add style job to check Go formatting --- .github/workflows/ci.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ba01138d0..0b5b2daf48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,18 @@ jobs: with: go-version: 1.22 - - name: Check Go formatting + # ✅ STRICT STYLE CHECK (assignment requires this) + - name: Check Go formatting (strict) run: test -z "$(go fmt ./...)" + # 🟡 OPTIONAL: SOFT CHECK (uncomment if you don't want to fail CI) + # - name: Check Go formatting (soft, always passes) + # run: | + # files=$(go fmt ./...) + # if [ -n "$files" ]; then + # echo "These files are not formatted correctly:" + # echo "$files" + # else + # echo "All files are properly formatted." + # fi + From 7863f8eecea583335fdc644a9581b293884f6ad9 Mon Sep 17 00:00:00 2001 From: Niveditha <79445393+N123p@users.noreply.github.com> Date: Thu, 7 Aug 2025 09:55:55 +0200 Subject: [PATCH 28/28] Fix formatting --- vendor/github.com/go-chi/chi/chi.go | 42 +++++++++---------- vendor/github.com/go-chi/chi/context.go | 14 +++---- vendor/github.com/go-chi/cors/cors.go | 12 +++--- vendor/github.com/google/uuid/dce.go | 4 +- vendor/github.com/google/uuid/hash.go | 4 +- vendor/github.com/google/uuid/node_js.go | 1 + vendor/github.com/google/uuid/node_net.go | 1 + vendor/github.com/google/uuid/null.go | 17 ++++---- vendor/github.com/google/uuid/version4.go | 14 +++---- vendor/nhooyr.io/websocket/accept.go | 1 + vendor/nhooyr.io/websocket/close_notjs.go | 1 + vendor/nhooyr.io/websocket/compress_notjs.go | 1 + vendor/nhooyr.io/websocket/conn_notjs.go | 1 + vendor/nhooyr.io/websocket/dial.go | 1 + vendor/nhooyr.io/websocket/doc.go | 11 ++--- .../websocket/internal/wsjs/wsjs_js.go | 1 + vendor/nhooyr.io/websocket/read.go | 1 + vendor/nhooyr.io/websocket/write.go | 1 + 18 files changed, 69 insertions(+), 59 deletions(-) diff --git a/vendor/github.com/go-chi/chi/chi.go b/vendor/github.com/go-chi/chi/chi.go index b7063dc297..db1780b1c6 100644 --- a/vendor/github.com/go-chi/chi/chi.go +++ b/vendor/github.com/go-chi/chi/chi.go @@ -1,29 +1,29 @@ -// // Package chi is a small, idiomatic and composable router for building HTTP services. // // chi requires Go 1.10 or newer. // // Example: -// package main // -// import ( -// "net/http" +// package main +// +// import ( +// "net/http" // -// "github.com/go-chi/chi" -// "github.com/go-chi/chi/middleware" -// ) +// "github.com/go-chi/chi" +// "github.com/go-chi/chi/middleware" +// ) // -// func main() { -// r := chi.NewRouter() -// r.Use(middleware.Logger) -// r.Use(middleware.Recoverer) +// func main() { +// r := chi.NewRouter() +// r.Use(middleware.Logger) +// r.Use(middleware.Recoverer) // -// r.Get("/", func(w http.ResponseWriter, r *http.Request) { -// w.Write([]byte("root.")) -// }) +// r.Get("/", func(w http.ResponseWriter, r *http.Request) { +// w.Write([]byte("root.")) +// }) // -// http.ListenAndServe(":3333", r) -// } +// http.ListenAndServe(":3333", r) +// } // // See github.com/go-chi/chi/_examples/ for more in-depth examples. // @@ -47,12 +47,12 @@ // placeholder which will match / characters. // // Examples: -// "/user/{name}" matches "/user/jsmith" but not "/user/jsmith/info" or "/user/jsmith/" -// "/user/{name}/info" matches "/user/jsmith/info" -// "/page/*" matches "/page/intro/latest" -// "/page/*/index" also matches "/page/intro/latest" -// "/date/{yyyy:\\d\\d\\d\\d}/{mm:\\d\\d}/{dd:\\d\\d}" matches "/date/2017/04/01" // +// "/user/{name}" matches "/user/jsmith" but not "/user/jsmith/info" or "/user/jsmith/" +// "/user/{name}/info" matches "/user/jsmith/info" +// "/page/*" matches "/page/intro/latest" +// "/page/*/index" also matches "/page/intro/latest" +// "/date/{yyyy:\\d\\d\\d\\d}/{mm:\\d\\d}/{dd:\\d\\d}" matches "/date/2017/04/01" package chi import "net/http" diff --git a/vendor/github.com/go-chi/chi/context.go b/vendor/github.com/go-chi/chi/context.go index 8c97f214a9..bd30d52b4f 100644 --- a/vendor/github.com/go-chi/chi/context.go +++ b/vendor/github.com/go-chi/chi/context.go @@ -112,13 +112,13 @@ func (x *Context) URLParam(key string) string { // // For example, // -// func Instrument(next http.Handler) http.Handler { -// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { -// next.ServeHTTP(w, r) -// routePattern := chi.RouteContext(r.Context()).RoutePattern() -// measure(w, r, routePattern) -// }) -// } +// func Instrument(next http.Handler) http.Handler { +// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { +// next.ServeHTTP(w, r) +// routePattern := chi.RouteContext(r.Context()).RoutePattern() +// measure(w, r, routePattern) +// }) +// } func (x *Context) RoutePattern() string { routePattern := strings.Join(x.RoutePatterns, "") return replaceWildcards(routePattern) diff --git a/vendor/github.com/go-chi/cors/cors.go b/vendor/github.com/go-chi/cors/cors.go index 8df81636e3..75196ab91c 100644 --- a/vendor/github.com/go-chi/cors/cors.go +++ b/vendor/github.com/go-chi/cors/cors.go @@ -3,15 +3,15 @@ // // You can configure it by passing an option struct to cors.New: // -// c := cors.New(cors.Options{ -// AllowedOrigins: []string{"foo.com"}, -// AllowedMethods: []string{"GET", "POST", "DELETE"}, -// AllowCredentials: true, -// }) +// c := cors.New(cors.Options{ +// AllowedOrigins: []string{"foo.com"}, +// AllowedMethods: []string{"GET", "POST", "DELETE"}, +// AllowCredentials: true, +// }) // // Then insert the handler in the chain: // -// handler = c.Handler(handler) +// handler = c.Handler(handler) // // See Options documentation for more options. // diff --git a/vendor/github.com/google/uuid/dce.go b/vendor/github.com/google/uuid/dce.go index fa820b9d30..9302a1c1bb 100644 --- a/vendor/github.com/google/uuid/dce.go +++ b/vendor/github.com/google/uuid/dce.go @@ -42,7 +42,7 @@ func NewDCESecurity(domain Domain, id uint32) (UUID, error) { // NewDCEPerson returns a DCE Security (Version 2) UUID in the person // domain with the id returned by os.Getuid. // -// NewDCESecurity(Person, uint32(os.Getuid())) +// NewDCESecurity(Person, uint32(os.Getuid())) func NewDCEPerson() (UUID, error) { return NewDCESecurity(Person, uint32(os.Getuid())) } @@ -50,7 +50,7 @@ func NewDCEPerson() (UUID, error) { // NewDCEGroup returns a DCE Security (Version 2) UUID in the group // domain with the id returned by os.Getgid. // -// NewDCESecurity(Group, uint32(os.Getgid())) +// NewDCESecurity(Group, uint32(os.Getgid())) func NewDCEGroup() (UUID, error) { return NewDCESecurity(Group, uint32(os.Getgid())) } diff --git a/vendor/github.com/google/uuid/hash.go b/vendor/github.com/google/uuid/hash.go index b404f4bec2..24ccde6464 100644 --- a/vendor/github.com/google/uuid/hash.go +++ b/vendor/github.com/google/uuid/hash.go @@ -39,7 +39,7 @@ func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { // NewMD5 returns a new MD5 (Version 3) UUID based on the // supplied name space and data. It is the same as calling: // -// NewHash(md5.New(), space, data, 3) +// NewHash(md5.New(), space, data, 3) func NewMD5(space UUID, data []byte) UUID { return NewHash(md5.New(), space, data, 3) } @@ -47,7 +47,7 @@ func NewMD5(space UUID, data []byte) UUID { // NewSHA1 returns a new SHA1 (Version 5) UUID based on the // supplied name space and data. It is the same as calling: // -// NewHash(sha1.New(), space, data, 5) +// NewHash(sha1.New(), space, data, 5) func NewSHA1(space UUID, data []byte) UUID { return NewHash(sha1.New(), space, data, 5) } diff --git a/vendor/github.com/google/uuid/node_js.go b/vendor/github.com/google/uuid/node_js.go index 24b78edc90..96090351a9 100644 --- a/vendor/github.com/google/uuid/node_js.go +++ b/vendor/github.com/google/uuid/node_js.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build js // +build js package uuid diff --git a/vendor/github.com/google/uuid/node_net.go b/vendor/github.com/google/uuid/node_net.go index 0cbbcddbd6..e91358f7d9 100644 --- a/vendor/github.com/google/uuid/node_net.go +++ b/vendor/github.com/google/uuid/node_net.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !js // +build !js package uuid diff --git a/vendor/github.com/google/uuid/null.go b/vendor/github.com/google/uuid/null.go index d7fcbf2865..06ecf9de2a 100644 --- a/vendor/github.com/google/uuid/null.go +++ b/vendor/github.com/google/uuid/null.go @@ -17,15 +17,14 @@ var jsonNull = []byte("null") // NullUUID implements the SQL driver.Scanner interface so // it can be used as a scan destination: // -// var u uuid.NullUUID -// err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&u) -// ... -// if u.Valid { -// // use u.UUID -// } else { -// // NULL value -// } -// +// var u uuid.NullUUID +// err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&u) +// ... +// if u.Valid { +// // use u.UUID +// } else { +// // NULL value +// } type NullUUID struct { UUID UUID Valid bool // Valid is true if UUID is not NULL diff --git a/vendor/github.com/google/uuid/version4.go b/vendor/github.com/google/uuid/version4.go index 7697802e4d..62ac273815 100644 --- a/vendor/github.com/google/uuid/version4.go +++ b/vendor/github.com/google/uuid/version4.go @@ -9,7 +9,7 @@ import "io" // New creates a new random UUID or panics. New is equivalent to // the expression // -// uuid.Must(uuid.NewRandom()) +// uuid.Must(uuid.NewRandom()) func New() UUID { return Must(NewRandom()) } @@ -17,7 +17,7 @@ func New() UUID { // NewString creates a new random UUID and returns it as a string or panics. // NewString is equivalent to the expression // -// uuid.New().String() +// uuid.New().String() func NewString() string { return Must(NewRandom()).String() } @@ -31,11 +31,11 @@ func NewString() string { // // A note about uniqueness derived from the UUID Wikipedia entry: // -// Randomly generated UUIDs have 122 random bits. One's annual risk of being -// hit by a meteorite is estimated to be one chance in 17 billion, that -// means the probability is about 0.00000000006 (6 × 10−11), -// equivalent to the odds of creating a few tens of trillions of UUIDs in a -// year and having one duplicate. +// Randomly generated UUIDs have 122 random bits. One's annual risk of being +// hit by a meteorite is estimated to be one chance in 17 billion, that +// means the probability is about 0.00000000006 (6 × 10−11), +// equivalent to the odds of creating a few tens of trillions of UUIDs in a +// year and having one duplicate. func NewRandom() (UUID, error) { if !poolEnabled { return NewRandomFromReader(rander) diff --git a/vendor/nhooyr.io/websocket/accept.go b/vendor/nhooyr.io/websocket/accept.go index 18536bdb2c..b54471312e 100644 --- a/vendor/nhooyr.io/websocket/accept.go +++ b/vendor/nhooyr.io/websocket/accept.go @@ -1,3 +1,4 @@ +//go:build !js // +build !js package websocket diff --git a/vendor/nhooyr.io/websocket/close_notjs.go b/vendor/nhooyr.io/websocket/close_notjs.go index 4251311d2e..8cafaa9dcf 100644 --- a/vendor/nhooyr.io/websocket/close_notjs.go +++ b/vendor/nhooyr.io/websocket/close_notjs.go @@ -1,3 +1,4 @@ +//go:build !js // +build !js package websocket diff --git a/vendor/nhooyr.io/websocket/compress_notjs.go b/vendor/nhooyr.io/websocket/compress_notjs.go index 809a272c3d..e094513b35 100644 --- a/vendor/nhooyr.io/websocket/compress_notjs.go +++ b/vendor/nhooyr.io/websocket/compress_notjs.go @@ -1,3 +1,4 @@ +//go:build !js // +build !js package websocket diff --git a/vendor/nhooyr.io/websocket/conn_notjs.go b/vendor/nhooyr.io/websocket/conn_notjs.go index 0c85ab7711..3c1361c5b2 100644 --- a/vendor/nhooyr.io/websocket/conn_notjs.go +++ b/vendor/nhooyr.io/websocket/conn_notjs.go @@ -1,3 +1,4 @@ +//go:build !js // +build !js package websocket diff --git a/vendor/nhooyr.io/websocket/dial.go b/vendor/nhooyr.io/websocket/dial.go index 7a7787ff71..7b91713e9c 100644 --- a/vendor/nhooyr.io/websocket/dial.go +++ b/vendor/nhooyr.io/websocket/dial.go @@ -1,3 +1,4 @@ +//go:build !js // +build !js package websocket diff --git a/vendor/nhooyr.io/websocket/doc.go b/vendor/nhooyr.io/websocket/doc.go index efa920e3b6..a2b873c722 100644 --- a/vendor/nhooyr.io/websocket/doc.go +++ b/vendor/nhooyr.io/websocket/doc.go @@ -1,3 +1,4 @@ +//go:build !js // +build !js // Package websocket implements the RFC 6455 WebSocket protocol. @@ -16,7 +17,7 @@ // // More documentation at https://nhooyr.io/websocket. // -// Wasm +// # Wasm // // The client side supports compiling to Wasm. // It wraps the WebSocket browser API. @@ -25,8 +26,8 @@ // // Some important caveats to be aware of: // -// - Accept always errors out -// - Conn.Ping is no-op -// - HTTPClient, HTTPHeader and CompressionMode in DialOptions are no-op -// - *http.Response from Dial is &http.Response{} with a 101 status code on success +// - Accept always errors out +// - Conn.Ping is no-op +// - HTTPClient, HTTPHeader and CompressionMode in DialOptions are no-op +// - *http.Response from Dial is &http.Response{} with a 101 status code on success package websocket // import "nhooyr.io/websocket" diff --git a/vendor/nhooyr.io/websocket/internal/wsjs/wsjs_js.go b/vendor/nhooyr.io/websocket/internal/wsjs/wsjs_js.go index 26ffb45625..88e8f43f69 100644 --- a/vendor/nhooyr.io/websocket/internal/wsjs/wsjs_js.go +++ b/vendor/nhooyr.io/websocket/internal/wsjs/wsjs_js.go @@ -1,3 +1,4 @@ +//go:build js // +build js // Package wsjs implements typed access to the browser javascript WebSocket API. diff --git a/vendor/nhooyr.io/websocket/read.go b/vendor/nhooyr.io/websocket/read.go index ae05cf93ed..0f10afef62 100644 --- a/vendor/nhooyr.io/websocket/read.go +++ b/vendor/nhooyr.io/websocket/read.go @@ -1,3 +1,4 @@ +//go:build !js // +build !js package websocket diff --git a/vendor/nhooyr.io/websocket/write.go b/vendor/nhooyr.io/websocket/write.go index 2210cf817a..9528e5acd7 100644 --- a/vendor/nhooyr.io/websocket/write.go +++ b/vendor/nhooyr.io/websocket/write.go @@ -1,3 +1,4 @@ +//go:build !js // +build !js package websocket