Skip to content

Commit

Permalink
chore: download protoc dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilsol committed Oct 19, 2023
1 parent c13a52b commit 5505067
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 20 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
- name: Go Generate
run: go generate -tags tools -x ./...
Expand All @@ -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/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
- name: Go Generate
run: go generate -tags tools -x ./...
Expand All @@ -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/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
- name: Go Generate
run: go generate -tags tools -x ./...
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/[email protected]
RUN go install google.golang.org/grpc/cmd/[email protected]

WORKDIR $GOPATH/src/github.com/satisfactorymodding/smr-api/

Expand Down
2 changes: 1 addition & 1 deletion db/postgres/postgres_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
2 changes: 1 addition & 1 deletion db/postgres/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 8 additions & 8 deletions nodes/mod_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
}

Expand All @@ -100,7 +100,7 @@ func TinyVersionToVersion(version *postgres.TinyVersion) *Version {
Version: version.Version,
SMLVersion: version.SMLVersion,
Dependencies: dependencies,
Arch: archs,
Targets: targets,
}
}

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion storage/b2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"io"
"path"
"path/filepath"
"slices"
"sort"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5505067

Please sign in to comment.