Skip to content

Commit 7246c9d

Browse files
committed
chore: optimize CI pipeline and fix JSONB NULL scan error
- Add Go module caching (cache: true) to all workflows - Add Docker layer caching via GitHub Actions cache in main workflow - Add Elasticsearch health check to avoid test flakiness - Skip CI for docs-only changes (paths-ignore for *.md and docs/**) - Remove unnecessary fetch-depth: 0 from lint and main workflows - Remove duplicate go mod tidy (Makefile clean no longer depends on tidy) - Update Dockerfile.dev to use parameterized Go version (1.25) and alpine 3.21 - Fix JSONMap.Scan() to handle NULL JSONB values from PostgreSQL
1 parent 264d39f commit 7246c9d

6 files changed

Lines changed: 37 additions & 11 deletions

File tree

.github/workflows/lint.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
name: Lint
22

3-
on: [push]
3+
on:
4+
push:
5+
paths-ignore:
6+
- "**.md"
7+
- "docs/**"
48

59
jobs:
610
golangci:
711
runs-on: ubuntu-latest
812
steps:
913
- uses: actions/checkout@v6
10-
with:
11-
fetch-depth: 0
1214
- uses: actions/setup-go@v6
1315
with:
1416
go-version-file: "go.mod"
17+
cache: true
1518
- name: golangci-lint
1619
uses: golangci/golangci-lint-action@v9
1720
with:

.github/workflows/main.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@ on:
33
push:
44
branches:
55
- main
6+
paths-ignore:
7+
- "**.md"
8+
- "docs/**"
69

710
jobs:
811
dev:
912
runs-on: ubuntu-latest
1013
steps:
1114
- name: Checkout code
1215
uses: actions/checkout@v6
13-
with:
14-
fetch-depth: 0
1516
- name: Set up Go
1617
uses: actions/setup-go@v6
1718
with:
1819
go-version-file: "go.mod"
20+
cache: true
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
1923
- name: Login to DockerHub
2024
uses: docker/login-action@v4
2125
with:
@@ -29,3 +33,5 @@ jobs:
2933
push: true
3034
file: "./Dockerfile.dev"
3135
tags: raystack/compass:dev
36+
cache-from: type=gha
37+
cache-to: type=gha,mode=max

.github/workflows/test.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
name: Test
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
paths-ignore:
5+
- "**.md"
6+
- "docs/**"
7+
pull_request:
8+
paths-ignore:
9+
- "**.md"
10+
- "docs/**"
311

412
jobs:
513
test:
@@ -13,17 +21,21 @@ jobs:
1321
discovery.type: single-node
1422
xpack.security.enabled: "false"
1523
ES_JAVA_OPTS: "-Xms128m -Xmx128m"
24+
options: >-
25+
--health-cmd "curl -f http://localhost:9200/_cluster/health"
26+
--health-interval 10s
27+
--health-timeout 5s
28+
--health-retries 10
1629
env:
1730
ES_TEST_SERVER_URL: "http://localhost:9200"
1831
steps:
1932
- uses: actions/checkout@v6
2033
- uses: actions/setup-go@v6
2134
with:
2235
go-version-file: "go.mod"
36+
cache: true
2337
- name: Install dependencies
2438
run: sudo apt-get install build-essential
25-
- name: Install packages
26-
run: go mod tidy
2739
- name: Run Test
2840
run: make test
2941
- name: Install goveralls and send coverage

Dockerfile.dev

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
FROM golang:1.20-alpine3.17 as builder
1+
ARG GO_VERSION=1.25
2+
FROM golang:${GO_VERSION}-alpine3.21 as builder
23
RUN apk add make
34
WORKDIR /build/
45
COPY . .
56
RUN make build
67

7-
FROM alpine:3.17
8+
FROM alpine:3.21
89

910
COPY --from=builder /build/compass /usr/bin/compass
1011
RUN apk update

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ lint: ## Lint checker
2525
@echo "Running lint checks using golangci-lint..."
2626
@golangci-lint run
2727

28-
clean: tidy ## Clean the build artifacts
28+
clean: ## Clean the build artifacts
2929
@echo "Cleaning up build directories..."
3030
@rm -rf $coverage.out ${BUILD_DIR}
3131

internal/store/postgres/asset_model.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ func (m JSONMap) Value() (driver.Value, error) {
156156
}
157157

158158
func (m *JSONMap) Scan(value interface{}) error {
159+
if value == nil {
160+
*m = JSONMap{}
161+
return nil
162+
}
159163
var ba []byte
160164
switch v := value.(type) {
161165
case []byte:

0 commit comments

Comments
 (0)