Skip to content

Commit

Permalink
chore: Rename packages
Browse files Browse the repository at this point in the history
Also Run tests on macos and windows
  • Loading branch information
codello committed Aug 14, 2023
1 parent 7ea1196 commit bbe028a
Show file tree
Hide file tree
Showing 102 changed files with 238 additions and 251 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: true
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATES/config.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
test:
name: Test
uses: codello/.github/.github/workflows/go-test.yml@v0
with:
test-on: ubuntu-latest,ubuntu-20.04,windows-latest,macos-latest

build:
name: Build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ go.work

# Compiled Binaries
build/
karman

# Testing files
tmp/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --chmod=755 build/${TARGETOS}/${TARGETARCH}/karman /karman
USER nonroot:nonroot

EXPOSE 8080
ENTRYPOINT ["/karman"]
ENTRYPOINT ["/karman", "server"]
20 changes: 3 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
OPENAPI_FILES := $(shell find api -type f -name '*.yaml')
OPENAPI_SPECS := api/karman.yaml $(shell find api/tags -type f -name '*.yaml')
OPENAPI_FILES := $(shell find ./openapi/ -type f -name '*.yaml')
OPENAPI_SPECS := ./openapi/karman.yaml $(shell find ./openapi/tags/ -type f -name '*.yaml')
GO_FILES = $(shell find . -type f -name '*.go')


.PHONY: all
all: build openapi

.PHONY: image
image: build
docker build -t ghcr.io/Karaoke-Manager/server .

.PHONY: build
build: build/karman

.PHONY: openapi
openapi: build/openapi.html build/openapi.yaml

Expand All @@ -24,11 +13,8 @@ build/openapi.yaml: .redocly.yaml $(OPENAPI_FILES)
@echo "Build OpenAPI Document"
@redocly join --output "$@" $(OPENAPI_SPECS)
@echo "Inserting Tag Groups"
@yq -i '.x-tagGroups = ($(shell yq -j .x-tagGroups < api/karman.yaml))' "$@"
@yq -i '.x-tagGroups = ($(shell yq -j .x-tagGroups < ./openapi/karman.yaml))' "$@"

build/openapi.html: build/openapi.yaml
@echo "Build HTML Documentation"
@redocly build-docs --output "$@" "$<"

build/karman: $(GO_FILES)
go build -o build/karman github.com/Karaoke-Manager/karman/cmd/karman
3 changes: 2 additions & 1 deletion internal/api/apierror/common.go → api/apierror/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"fmt"
"net/http"

"github.com/Karaoke-Manager/server/pkg/render"
"gorm.io/gorm"

"github.com/Karaoke-Manager/karman/pkg/render"
)

// ProblemTypeDomain is the base domain for all custom problem types.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package apierror
import (
"net/http"

"github.com/Karaoke-Manager/server/pkg/mediatype"
"github.com/Karaoke-Manager/karman/pkg/mediatype"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions internal/api/apierror/rfc7807.go → api/apierror/rfc7807.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"net/http"

"github.com/Karaoke-Manager/server/pkg/mediatype"
"github.com/Karaoke-Manager/server/pkg/render"
"github.com/Karaoke-Manager/karman/pkg/mediatype"
"github.com/Karaoke-Manager/karman/pkg/render"
)

// ProblemDetails implements [RFC 7807] "Problem Details for HTTP APIs".
Expand Down
2 changes: 1 addition & 1 deletion internal/api/apierror/song.go → api/apierror/song.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"codello.dev/ultrastar/txt"

"github.com/Karaoke-Manager/server/internal/model"
"github.com/Karaoke-Manager/karman/model"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions internal/api/apierror/upload.go → api/apierror/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"net/http"

"github.com/Karaoke-Manager/server/internal/entity"
"github.com/Karaoke-Manager/karman/model"
)

// These constants identify known problem types related to uploads.
Expand All @@ -20,7 +20,7 @@ const (
)

// UploadClosed generates an error indicating that the upload has been marked for processing and cannot be modified.
func UploadClosed(upload entity.Upload) *ProblemDetails {
func UploadClosed(upload *model.Upload) *ProblemDetails {
return &ProblemDetails{
Type: TypeUploadClosed,
Title: "Upload Closed",
Expand All @@ -33,7 +33,7 @@ func UploadClosed(upload entity.Upload) *ProblemDetails {
}

// UploadFileNotFound generates an error indicating that a requested file within an upload was not found.
func UploadFileNotFound(upload entity.Upload, path string) *ProblemDetails {
func UploadFileNotFound(upload *model.Upload, path string) *ProblemDetails {
return &ProblemDetails{
Type: TypeUploadFileNotFound,
Title: "File not Found",
Expand Down
12 changes: 6 additions & 6 deletions internal/api/controller.go → api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package api
import (
"net/http"

"github.com/Karaoke-Manager/server/internal/api/apierror"
"github.com/Karaoke-Manager/server/internal/service/media"
"github.com/Karaoke-Manager/server/internal/service/song"
"github.com/Karaoke-Manager/server/pkg/render"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"

"github.com/Karaoke-Manager/server/internal/api/v1"
"github.com/Karaoke-Manager/server/internal/service/upload"
"github.com/Karaoke-Manager/karman/api/apierror"
"github.com/Karaoke-Manager/karman/api/v1"
"github.com/Karaoke-Manager/karman/pkg/render"
"github.com/Karaoke-Manager/karman/service/media"
"github.com/Karaoke-Manager/karman/service/song"
"github.com/Karaoke-Manager/karman/service/upload"
)

// Controller is the main API controller.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package middleware
import (
"net/http"

"github.com/Karaoke-Manager/server/internal/api/apierror"
"github.com/Karaoke-Manager/server/pkg/mediatype"
"github.com/Karaoke-Manager/server/pkg/render"
"github.com/Karaoke-Manager/karman/api/apierror"
"github.com/Karaoke-Manager/karman/pkg/mediatype"
"github.com/Karaoke-Manager/karman/pkg/render"
)

// ContentTypeJSON is an instance of the RequireContentType middleware for the common application of JSON requests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"net/http/httptest"
"testing"

"github.com/Karaoke-Manager/server/internal/api/apierror"
_ "github.com/Karaoke-Manager/server/pkg/render/json"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/Karaoke-Manager/karman/api/apierror"
_ "github.com/Karaoke-Manager/karman/pkg/render/json"
)

func TestRequireContentType(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"
"strconv"

"github.com/Karaoke-Manager/server/internal/api/apierror"
"github.com/Karaoke-Manager/server/pkg/render"
"github.com/Karaoke-Manager/karman/api/apierror"
"github.com/Karaoke-Manager/karman/pkg/render"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"net/http/httptest"
"testing"

"github.com/Karaoke-Manager/server/internal/api/apierror"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/Karaoke-Manager/karman/api/apierror"
)

func TestPaginate(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions internal/api/middleware/uuid.go → api/middleware/uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"net/http"

"github.com/Karaoke-Manager/server/internal/api/apierror"
"github.com/Karaoke-Manager/server/pkg/render"
"github.com/go-chi/chi/v5"
"github.com/google/uuid"

"github.com/Karaoke-Manager/karman/api/apierror"
"github.com/Karaoke-Manager/karman/pkg/render"
)

// UUID is a simple middleware that fetches a UUID value from a request parameter named param.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"net/http/httptest"
"testing"

"github.com/Karaoke-Manager/server/internal/api/apierror"
"github.com/go-chi/chi/v5"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/Karaoke-Manager/karman/api/apierror"
)

func TestUUID(t *testing.T) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/schema/list.go → api/schema/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"
"strconv"

"github.com/Karaoke-Manager/server/pkg/render"
"github.com/Karaoke-Manager/karman/pkg/render"
)

// List is a generic schema type for list responses.
Expand Down
4 changes: 2 additions & 2 deletions internal/schema/song.go → api/schema/song.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"
"time"

"github.com/Karaoke-Manager/server/internal/model"
"github.com/Karaoke-Manager/server/pkg/mediatype"
"github.com/Karaoke-Manager/karman/model"
"github.com/Karaoke-Manager/karman/pkg/mediatype"

"codello.dev/ultrastar"
"github.com/google/uuid"
Expand Down
6 changes: 3 additions & 3 deletions internal/schema/upload.go → api/schema/upload.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package schema

import (
"github.com/Karaoke-Manager/server/internal/entity"
"github.com/Karaoke-Manager/server/pkg/render"
"github.com/Karaoke-Manager/karman/model"
"github.com/Karaoke-Manager/karman/pkg/render"
)

type UploadStatus string
Expand All @@ -20,7 +20,7 @@ type Upload struct {
Status UploadStatus `json:"status"`
}

func NewUploadFromModel(m entity.Upload) *Upload {
func NewUploadFromModel(m *model.Upload) *Upload {
var status UploadStatus
if m.Open {
status = UploadStatusCreated
Expand Down
10 changes: 5 additions & 5 deletions internal/api/v1/controller.go → api/v1/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package v1
import (
"github.com/go-chi/chi/v5"

"github.com/Karaoke-Manager/server/internal/api/v1/songs"
"github.com/Karaoke-Manager/server/internal/api/v1/uploads"
"github.com/Karaoke-Manager/server/internal/service/media"
"github.com/Karaoke-Manager/server/internal/service/song"
"github.com/Karaoke-Manager/server/internal/service/upload"
"github.com/Karaoke-Manager/karman/api/v1/songs"
"github.com/Karaoke-Manager/karman/api/v1/uploads"
"github.com/Karaoke-Manager/karman/service/media"
"github.com/Karaoke-Manager/karman/service/song"
"github.com/Karaoke-Manager/karman/service/upload"
)

// Controller implements the /v1 API namespace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package songs
import (
"github.com/go-chi/chi/v5"

"github.com/Karaoke-Manager/server/internal/api/middleware"
"github.com/Karaoke-Manager/server/internal/service/media"
"github.com/Karaoke-Manager/server/internal/service/song"
"github.com/Karaoke-Manager/server/pkg/render"
_ "github.com/Karaoke-Manager/server/pkg/render/json"
"github.com/Karaoke-Manager/karman/api/middleware"
"github.com/Karaoke-Manager/karman/pkg/render"
_ "github.com/Karaoke-Manager/karman/pkg/render/json"
"github.com/Karaoke-Manager/karman/service/media"
"github.com/Karaoke-Manager/karman/service/song"
)

// Controller implements the /v1/songs endpoint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import (
"net/http/httptest"
"testing"

"github.com/Karaoke-Manager/server/internal/api/apierror"
"github.com/Karaoke-Manager/server/internal/model"

"github.com/google/uuid"

"github.com/go-chi/chi/v5"
"github.com/google/uuid"

"github.com/Karaoke-Manager/server/internal/service/media"
"github.com/Karaoke-Manager/server/internal/service/song"
"github.com/Karaoke-Manager/server/internal/test"
"github.com/Karaoke-Manager/karman/api/apierror"
"github.com/Karaoke-Manager/karman/model"
"github.com/Karaoke-Manager/karman/service/media"
"github.com/Karaoke-Manager/karman/service/song"
"github.com/Karaoke-Manager/karman/test"
)

// setup prepares a test instance of the songs.Controller.
Expand Down
22 changes: 11 additions & 11 deletions internal/api/v1/songs/crud.go → api/v1/songs/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"codello.dev/ultrastar/txt"
"gorm.io/gorm"

"github.com/Karaoke-Manager/server/internal/api/apierror"
"github.com/Karaoke-Manager/server/internal/api/middleware"
"github.com/Karaoke-Manager/server/internal/model"
"github.com/Karaoke-Manager/server/internal/schema"
"github.com/Karaoke-Manager/server/pkg/render"
"github.com/Karaoke-Manager/karman/api/apierror"
"github.com/Karaoke-Manager/karman/api/middleware"
schema2 "github.com/Karaoke-Manager/karman/api/schema"
"github.com/Karaoke-Manager/karman/model"
"github.com/Karaoke-Manager/karman/pkg/render"
)

// Create implements the POST /v1/songs endpoint.
Expand All @@ -27,7 +27,7 @@ func (c *Controller) Create(w http.ResponseWriter, r *http.Request) {
return
}
render.SetStatus(r, http.StatusCreated)
s := schema.FromSong(song)
s := schema2.FromSong(song)
_ = render.Render(w, r, &s)
}

Expand All @@ -40,14 +40,14 @@ func (c *Controller) Find(w http.ResponseWriter, r *http.Request) {
return
}

resp := schema.List[*schema.Song]{
Items: make([]*schema.Song, len(songs)),
resp := schema2.List[*schema2.Song]{
Items: make([]*schema2.Song, len(songs)),
Offset: pagination.Offset,
Limit: pagination.RequestLimit,
Total: total,
}
for i, upload := range songs {
s := schema.FromSong(upload)
s := schema2.FromSong(upload)
resp.Items[i] = &s
}
_ = render.Render(w, r, &resp)
Expand All @@ -56,14 +56,14 @@ func (c *Controller) Find(w http.ResponseWriter, r *http.Request) {
// Get implements the GET /v1/songs/{uuid} endpoint.
func (c *Controller) Get(w http.ResponseWriter, r *http.Request) {
song := MustGetSong(r.Context())
resp := schema.FromSong(song)
resp := schema2.FromSong(song)
_ = render.Render(w, r, &resp)
}

// Update implements the PATCH /v1/songs/{uuid} endpoint.
func (c *Controller) Update(w http.ResponseWriter, r *http.Request) {
song := MustGetSong(r.Context())
update := schema.FromSong(song)
update := schema2.FromSong(song)
if err := render.Bind(r, &update); err != nil {
_ = render.Render(w, r, apierror.BindError(err))
return
Expand Down
Loading

0 comments on commit bbe028a

Please sign in to comment.