From 550506750f568f2d0c03de37a55c8bab1124ea99 Mon Sep 17 00:00:00 2001 From: Vilsol Date: Thu, 19 Oct 2023 22:15:26 +0300 Subject: [PATCH] chore: download protoc dependencies --- .github/workflows/build.yml | 15 ++++++++++++--- .github/workflows/release.yml | 5 ++++- Dockerfile | 6 ++++-- db/postgres/postgres_types.go | 2 +- db/postgres/version.go | 2 +- nodes/mod_types.go | 16 ++++++++-------- storage/b2.go | 2 +- validation/validation.go | 6 +++--- 8 files changed, 34 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f06bb0ac..332f1398 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,10 @@ jobs: uses: actions/checkout@v3 - name: Download dependencies - run: sudo apt update && sudo apt install -y build-essential libpng-dev + run: | + sudo apt update && sudo apt install -y build-essential libpng-dev protobuf-compiler + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 - name: Go Generate run: go generate -tags tools -x ./... @@ -39,7 +42,10 @@ jobs: uses: actions/checkout@v3 - name: Download dependencies - run: sudo apt update && sudo apt install -y build-essential libpng-dev + run: | + sudo apt update && sudo apt install -y build-essential libpng-dev protobuf-compiler + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 - name: Go Generate run: go generate -tags tools -x ./... @@ -65,7 +71,10 @@ jobs: uses: actions/checkout@v3 - name: Download dependencies - run: sudo apt update && sudo apt install -y build-essential libpng-dev + run: | + sudo apt update && sudo apt install -y build-essential libpng-dev protobuf-compiler + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 - name: Go Generate run: go generate -tags tools -x ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e548779..fc5a0eff 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,10 @@ jobs: fetch-depth: 0 - name: Download dependencies - run: sudo apt update && sudo apt install -y build-essential libpng-dev + run: | + sudo apt update && sudo apt install -y build-essential libpng-dev protobuf-compiler + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 - name: Run GoReleaser uses: goreleaser/goreleaser-action@v3 diff --git a/Dockerfile b/Dockerfile index d1d66b82..83c9552d 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ -FROM golang:1.18-alpine AS builder +FROM golang:1.19-alpine3.18 AS builder -RUN apk add --no-cache git build-base libpng-dev +RUN apk add --no-cache git build-base libpng-dev protoc +RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 +RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 WORKDIR $GOPATH/src/github.com/satisfactorymodding/smr-api/ diff --git a/db/postgres/postgres_types.go b/db/postgres/postgres_types.go index 89433031..c09660ed 100644 --- a/db/postgres/postgres_types.go +++ b/db/postgres/postgres_types.go @@ -100,7 +100,7 @@ type TinyVersion struct { SMRModel SMLVersion string `gorm:"type:varchar(16)"` Version string `gorm:"type:varchar(16)"` - Arch []VersionTarget `gorm:"foreignKey:ModVersionID;preload:true"` + Targets []VersionTarget `gorm:"foreignKey:VersionID;preload:true"` Dependencies []VersionDependency `gorm:"foreignKey:VersionID"` } diff --git a/db/postgres/version.go b/db/postgres/version.go index ccf95c30..d70aee89 100644 --- a/db/postgres/version.go +++ b/db/postgres/version.go @@ -96,7 +96,7 @@ func GetAllModVersionsWithDependencies(ctx context.Context, modID string) []Tiny var versions []TinyVersion DBCtx(ctx).Debug(). Preload("Dependencies"). - Preload("Arch"). + Preload("Targets"). Where("approved = ? AND denied = ?", true, false). Find(&versions, "mod_id = ?", modID) diff --git a/nodes/mod_types.go b/nodes/mod_types.go index bd5c2660..88f7b82f 100644 --- a/nodes/mod_types.go +++ b/nodes/mod_types.go @@ -59,7 +59,7 @@ type Version struct { Downloads uint `json:"downloads,omitempty"` Approved bool `json:"approved,omitempty"` Dependencies []VersionDependency `json:"dependencies,omitempty"` - Arch []VersionTarget `json:"arch,omitempty"` + Targets []VersionTarget `json:"targets,omitempty"` } type VersionDependency struct { @@ -85,11 +85,11 @@ func TinyVersionToVersion(version *postgres.TinyVersion) *Version { } } - var archs []VersionTarget - if version.Arch != nil { - archs = make([]VersionTarget, len(version.Arch)) - for i, v := range version.Arch { - archs[i] = VersionArchToVersionArch(v) + var targets []VersionTarget + if version.Targets != nil { + targets = make([]VersionTarget, len(version.Targets)) + for i, v := range version.Targets { + targets[i] = VersionTargetToVersionTarget(v) } } @@ -100,7 +100,7 @@ func TinyVersionToVersion(version *postgres.TinyVersion) *Version { Version: version.Version, SMLVersion: version.SMLVersion, Dependencies: dependencies, - Arch: archs, + Targets: targets, } } @@ -127,7 +127,7 @@ func VersionDependencyToVersionDependency(version postgres.VersionDependency) Ve } } -func VersionArchToVersionArch(version postgres.VersionTarget) VersionTarget { +func VersionTargetToVersionTarget(version postgres.VersionTarget) VersionTarget { return VersionTarget{ VersionID: version.VersionID, TargetName: version.TargetName, diff --git a/storage/b2.go b/storage/b2.go index 1672ece2..a616608d 100644 --- a/storage/b2.go +++ b/storage/b2.go @@ -224,5 +224,5 @@ func (b2o *B2) Meta(key string) (*ObjectMeta, error) { } func (b2o *B2) List(key string) ([]Object, error) { - return nil, errors.New("Unsupported") + return nil, nil // no-op } diff --git a/validation/validation.go b/validation/validation.go index e02fa199..813eb35f 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -11,7 +11,7 @@ import ( "io" "path" "path/filepath" - "slices" + "sort" "strconv" "strings" "time" @@ -147,8 +147,8 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal smlVersions := postgres.GetSMLVersions(ctx, nil) // Sort decrementing by version - slices.SortFunc(smlVersions, func(a, b postgres.SMLVersion) int { - return semver.MustParse(b.Version).Compare(semver.MustParse(a.Version)) + sort.Slice(smlVersions, func(a, b int) bool { + return semver.MustParse(smlVersions[a].Version).Compare(semver.MustParse(smlVersions[b].Version)) > 0 }) for _, version := range smlVersions {