diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000000..48062ac333 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,20 @@ +on: + push: + branches: [main] + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.0" + + - name: Build app + run: ./scripts/buildprod.sh + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..f1f129df05 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: ci + +on: + pull_request: + branches: [main] + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.0" + + - name: Run tests + run: go test -cover ./... + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + - name: Run staticcheck + run: staticcheck ./... diff --git a/README.md b/README.md index c2bec0368b..3de3561c12 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -# learn-cicd-starter (Notely) +# learn-cicd-starter (Notely) +https://github.com/ArchitDewan/learn-cicd-starter/actions/workflows/ci.yml/badge.svg This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). ## Local Development @@ -21,3 +22,6 @@ 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! + +Archit Dewans's version of Boot.dev's Notely app. + diff --git a/internal/auth/get_api_key_test.go b/internal/auth/get_api_key_test.go new file mode 100644 index 0000000000..d8c6a09921 --- /dev/null +++ b/internal/auth/get_api_key_test.go @@ -0,0 +1,25 @@ +package auth + +import ( + "reflect" + "net/http" + "testing" +) + +func TestGetApiKey(t *testing.T) { + header := http.Header{} + header.Set("Authorization", "ApiKey your-api-key-here") + got, err := GetAPIKey(header) + + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + want := "your-api-key-here" + + if !reflect.DeepEqual(want, got) { + t.Fatalf("expected %q, got: %q",want, got) + } + +} + + diff --git a/main.go b/main.go index 19d7366c5f..32a3c1d0c5 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,6 @@ import ( _ "github.com/tursodatabase/libsql-client-go/libsql" ) - type apiConfig struct { DB *database.Queries }