Refactor Docker and Makefile configurations for improved build processes

- Updated docker-compose.tools.yml to mount source code at /src and set working directory for backend tools, ensuring proper Go module caching.
- Modified Dockerfile.tools to install the latest golangci-lint version compatible with Go 1.24 and adjusted working directory for build-time operations.
- Enhanced Makefile to build backend tools before running tests and linting, ensuring dependencies are up-to-date and improving overall workflow efficiency.
- Refactored test and handler files to include error handling for database operations, enhancing reliability and debugging capabilities.
This commit is contained in:
2026-03-04 13:59:00 +03:00
parent fc42d86ca0
commit 761fbaed55
20 changed files with 352 additions and 165 deletions

View File

@@ -111,7 +111,7 @@ func (s *ExportService) Export(ctx context.Context, w io.Writer) error {
if markersb != nil {
markersgrid := markersb.Bucket(store.BucketMarkersGrid)
if markersgrid != nil {
markersgrid.ForEach(func(k, v []byte) error {
if err := markersgrid.ForEach(func(k, v []byte) error {
select {
case <-ctx.Done():
return ctx.Err()
@@ -125,7 +125,9 @@ func (s *ExportService) Export(ctx context.Context, w io.Writer) error {
maps[gridMap[marker.GridID]].Markers[marker.GridID] = append(maps[gridMap[marker.GridID]].Markers[marker.GridID], marker)
}
return nil
})
}); err != nil {
return err
}
}
}
return nil
@@ -218,7 +220,11 @@ func (s *ExportService) Merge(ctx context.Context, zr *zip.Reader) error {
f.Close()
return err
}
io.Copy(f, r)
if _, err := io.Copy(f, r); err != nil {
r.Close()
f.Close()
return err
}
r.Close()
f.Close()
newTiles[strings.TrimSuffix(filepath.Base(fhdr.Name), ".png")] = struct{}{}
@@ -290,8 +296,12 @@ func (s *ExportService) processMergeJSON(
Image: img,
}
raw, _ := json.Marshal(m)
mgrid.Put(key, raw)
idB.Put(idKey, key)
if err := mgrid.Put(key, raw); err != nil {
return err
}
if err := idB.Put(idKey, key); err != nil {
return err
}
}
}
@@ -333,7 +343,9 @@ func (s *ExportService) processMergeJSON(
if err != nil {
return err
}
grids.Put([]byte(grid), raw)
if err := grids.Put([]byte(grid), raw); err != nil {
return err
}
}
return nil
}
@@ -372,11 +384,13 @@ func (s *ExportService) processMergeJSON(
if err != nil {
return err
}
grids.Put([]byte(grid), raw)
if err := grids.Put([]byte(grid), raw); err != nil {
return err
}
}
if len(existingMaps) > 1 {
grids.ForEach(func(k, v []byte) error {
if err := grids.ForEach(func(k, v []byte) error {
gd := app.GridData{}
if err := json.Unmarshal(v, &gd); err != nil {
return err
@@ -413,16 +427,22 @@ func (s *ExportService) processMergeJSON(
File: td.File,
})
}
grids.Put(k, raw)
if err := grids.Put(k, raw); err != nil {
return err
}
}
return nil
})
}); err != nil {
return err
}
}
for mergeid, merge := range existingMaps {
if mapid == mergeid {
continue
}
mapB.Delete([]byte(strconv.Itoa(mergeid)))
if err := mapB.Delete([]byte(strconv.Itoa(mergeid))); err != nil {
return err
}
slog.Info("reporting merge", "from", mergeid, "to", mapid)
s.mapSvc.ReportMerge(mergeid, mapid, app.Coord{X: offset.X - merge.X, Y: offset.Y - merge.Y})
}