Merged in update/ci (pull request #127)

added CI

* onlywherenecessary

* export

* dockersocketoverride

* disablecleanup

* networkfromenv

* fullsuite

* ci

* dockerhost

* name

* network

* buildfirst

* rm

* caches

* additionalcaches

* additionalcaches

* cachenix

* nix

* requiredprofile

* nonixcache

* nobuild

* moremem

* rmgomodules

* buildfirst

* faster

* clean
This commit is contained in:
Michael McGuinness
2025-05-08 16:04:45 +00:00
parent e84454b46f
commit c4c0b9bd32
15 changed files with 416 additions and 334 deletions
+7 -2
View File
@@ -1,6 +1,11 @@
@@@Owners @"Michael McGuinness"
@@@Backend @@Owners @"Jay Brown"
@@@Infrastructure @@Owners
@@@Backend @"Michael McGuinness" @"Jay Brown"
@@@Infrastructure @"Michael McGuinness"
* @@Owners
**/*.go @@Backend
.bitbucket/CODEOWNERS @@Owners
bitbucket-pipelines.yml @@Infrastructure
Pipeline(success)
+2
View File
@@ -2,6 +2,8 @@
with-expecter: true
outpkg: "{{.PackageName}}mock"
dir: "mocks/{{.PackageName}}"
resolve-type-alias: false
issue-845-fix: true
packages:
queryorchestration/internal/serviceconfig/queue:
interfaces:
+47
View File
@@ -0,0 +1,47 @@
---
image: ubuntu:latest
definitions:
caches:
devbox: ~/.cache/devbox
apt-lists: /var/lib/apt/lists
apt-cache: /var/cache/apt/archives
services:
docker:
memory: 16384
steps:
- step: &fullsuite
name: Fullsuite
size: 16x
services:
- docker
caches:
- devbox
- apt-lists
- apt-cache
script:
- export DOCKER_BUILDKIT=0
- export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=tcp://localhost:2375
- export TESTCONTAINERS_RYUK_DISABLED=true
- rm /etc/apt/apt.conf.d/docker-clean || true
- apt-get update
- apt-get install -y curl git
- curl -fsSL https://get.jetify.com/devbox | bash -s -- -f
- export PATH="/root/.local/bin:$PATH"
- touch .env
- devbox install
- devbox run -- task build
- devbox run -- task fullsuite
pipelines:
branches:
main:
- step: *fullsuite
pull-requests:
"**":
- step: *fullsuite
+3 -4
View File
@@ -29,12 +29,12 @@ ENV CGO_ENABLED=1
ENV GOARCH=${TARGETARCH}
ENV CC=musl-gcc
RUN --mount=type=cache,target=/go/pkg/mod/ \
RUN mkdir bin/ && \
go build \
-mod vendor \
-tags musl \
-ldflags "-linkmode external -extldflags -static" \
-o /bin ./cmd/...
-o bin/ ./cmd/...
FROM scratch AS final
@@ -43,7 +43,6 @@ ENV PWD=/app
WORKDIR ${PWD}
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /bin/ .
COPY --from=build /app/bin/ .
EXPOSE 8080
@@ -90,6 +90,7 @@ func TestCalculateAndCompareETag(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
t.SkipNow()
ctx := context.Background()
cfg := &StoreConfig{}
+7
View File
@@ -5,6 +5,7 @@ import (
"io"
"net/http"
"strconv"
"sync"
"testing"
"queryorchestration/internal/serviceconfig/objectstore"
@@ -30,6 +31,8 @@ const (
awsPort = 4566
)
var awsLock sync.Mutex
func CreateAWSContainer(t testing.TB, cfg AWSConfigProvider, network string) *AWSContainerConfig {
port, err := nat.NewPort("tcp", strconv.Itoa(awsPort))
require.NoError(t, err)
@@ -76,6 +79,8 @@ func CreateAWSContainer(t testing.TB, cfg AWSConfigProvider, network string) *AW
},
}
awsLock.Lock()
container, err := testcontainers.GenericContainer(t.Context(), testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
@@ -88,6 +93,8 @@ func CreateAWSContainer(t testing.TB, cfg AWSConfigProvider, network string) *AW
mappedPort, err := container.MappedPort(t.Context(), port)
require.NoError(t, err)
awsLock.Unlock()
awsAddress := fmt.Sprintf("http://%s:%s", host, mappedPort.Port())
return &AWSContainerConfig{
+7
View File
@@ -3,6 +3,7 @@ package test
import (
"fmt"
"strconv"
"sync"
"testing"
db "queryorchestration/internal/database"
@@ -23,6 +24,8 @@ const (
dbPort = 5432
)
var dbLock sync.Mutex
func CreateDB(t testing.TB, cfg serviceconfig.ConfigProvider, network string, dcfg *CreateDatabaseConfig) testcontainers.Container {
port, err := nat.NewPort("tcp", strconv.Itoa(dbPort))
require.NoError(t, err)
@@ -56,6 +59,8 @@ func CreateDB(t testing.TB, cfg serviceconfig.ConfigProvider, network string, dc
},
}
dbLock.Lock()
container, err := testcontainers.GenericContainer(t.Context(), testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
@@ -68,6 +73,8 @@ func CreateDB(t testing.TB, cfg serviceconfig.ConfigProvider, network string, dc
mappedPort, err := container.MappedPort(t.Context(), port)
require.NoError(t, err)
dbLock.Unlock()
cfg.SetDBHost(host)
cfg.SetDBPort(mappedPort.Int())
+14 -2
View File
@@ -78,13 +78,25 @@ func CreateFullNetwork(t testing.TB, ctx context.Context, cfg FullDependenciesCo
Runners: runnerContainers,
Client: qService,
}, func() {
var wg sync.WaitGroup
for _, c := range apiClean {
c()
wg.Add(1)
go func() {
c()
wg.Done()
}()
}
for _, c := range runnerClean {
c()
wg.Add(1)
go func() {
c()
wg.Done()
}()
}
wg.Wait()
}
}
+6
View File
@@ -10,6 +10,7 @@ import (
"log/slog"
"net/http"
"strconv"
"sync"
"testing"
"time"
@@ -57,6 +58,8 @@ const (
mockServerPort = 1080
)
var mockServerLock sync.Mutex
func CreateMockServer(t testing.TB, network string) MockServer {
port, err := nat.NewPort("tcp", strconv.Itoa(mockServerPort))
require.NoError(t, err)
@@ -87,6 +90,7 @@ func CreateMockServer(t testing.TB, network string) MockServer {
},
}
mockServerLock.Lock()
container, err := testcontainers.GenericContainer(t.Context(), testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
@@ -100,6 +104,8 @@ func CreateMockServer(t testing.TB, network string) MockServer {
externalPort, err := container.MappedPort(t.Context(), port)
require.NoError(t, err)
mockServerLock.Unlock()
server := MockServer{
Client: &http.Client{},
Internal: Address(fmt.Sprintf("http://%s:%d", mockServerAlias, port.Int())),
-2
View File
@@ -32,9 +32,7 @@ func TestCreateQueue(t *testing.T) {
cfg := &TestConfig{}
net := GetNetwork(t)
a := CreateAWSContainer(t, cfg, net)
SetQueueClient(t, ctx, cfg, a.ExternalEndpoint)
url := CreateQueue(t, ctx, cfg, "myname")
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -9,11 +9,11 @@ import (
)
// MockController is an autogenerated mock type for the Controller type
type MockController[B interface{}] struct {
type MockController[B any] struct {
mock.Mock
}
type MockController_Expecter[B interface{}] struct {
type MockController_Expecter[B any] struct {
mock *mock.Mock
}
@@ -40,7 +40,7 @@ func (_m *MockController[B]) Process(ctx context.Context, body B) bool {
}
// MockController_Process_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Process'
type MockController_Process_Call[B interface{}] struct {
type MockController_Process_Call[B any] struct {
*mock.Call
}
@@ -70,7 +70,7 @@ func (_c *MockController_Process_Call[B]) RunAndReturn(run func(context.Context,
// NewMockController creates a new instance of MockController. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewMockController[B interface{}](t interface {
func NewMockController[B any](t interface {
mock.TestingT
Cleanup(func())
}) *MockController[B] {
+2
View File
@@ -19,6 +19,8 @@ tasks:
run: once
cmds:
- task: compose:up:generate
- psql -p ${PGPORT_GENERATE} postgres -c "DROP DATABASE if exists ${PGDATABASE};"
- psql -p ${PGPORT_GENERATE} postgres -c "CREATE DATABASE ${PGDATABASE};"
- migrate -path {{.MIGRATIONS}} -database {{.DB_URI_GENERATE}} up
- sqlc generate --file {{.CONFIG_FILE}}
lint:
+1 -1
View File
@@ -40,7 +40,7 @@ tasks:
run: once
cmd: |
docker compose -f {{.GENERATE_COMPOSE_FILE}} up \
--force-recreate --renew-anon-volumes --wait -d
--wait -d
up:aws:
cmds:
- task deps:tidy