Skip to content

Commit bd2a9b4

Browse files
gagan405khaf
andauthored
CLIENT-3847 update go ci workflow (#531)
* add ci action * update build yaml * chore: trigger workflow * chore: update action * chore: update action * fix step name * fix matrix include * fix version * fix server version * fix server version * fix server version: 7.0.0.26 fails. trying with 8.1 " * change server json format * Revert "change server json format" This reverts commit 92dfd25. * updated server versions * updated some descriptions * updated go version in go.mod * updated go version in go.mod * chore: update action --------- Co-authored-by: Khosrow Afroozeh <[email protected]>
1 parent 937c97c commit bd2a9b4

File tree

3 files changed

+88
-8
lines changed

3 files changed

+88
-8
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Make Server Matrix
2+
description: Builds a server matrix from JSON or file; Go version is passed separately.
3+
4+
inputs:
5+
default_json:
6+
description: Default JSON of servers (with versions) if no file exists.
7+
required: true
8+
test_servers_file_path:
9+
description: Repo-relative path to server matrix file (optional).
10+
required: false
11+
go_version:
12+
description: Go version to inject into each matrix entry.
13+
required: true
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- id: build
19+
shell: bash
20+
env:
21+
DEFAULT_JSON: ${{ inputs.default_json }}
22+
TEST_SERVERS_FILE_PATH: ${{ inputs.test_servers_file_path }}
23+
GO_VERSION: ${{ inputs.go_version }}
24+
run: |
25+
set -euo pipefail
26+
27+
FILE="${TEST_SERVERS_FILE_PATH:-}"
28+
29+
if [[ -n "${FILE}" && -s "${FILE}" ]]; then
30+
echo "Using ${FILE} from repository"
31+
JSON="$(cat "${FILE}")"
32+
else
33+
echo "${FILE:-<unset>} missing or empty – using default_json input"
34+
JSON="${DEFAULT_JSON}"
35+
fi
36+
37+
echo "Validating JSON..."
38+
echo "${JSON}" | jq . >/dev/null
39+
40+
MATRIX="$(echo "${JSON}" | jq -c --arg go "${GO_VERSION}" '[to_entries[] | { server: .key, go: $go } + .value]')"
41+
42+
{
43+
echo "matrix<<__JSON__"
44+
echo "${MATRIX}"
45+
echo "__JSON__"
46+
} >> "$GITHUB_OUTPUT"
47+
48+
outputs:
49+
matrix:
50+
description: JSON array of server entries (includes server and go version)
51+
value: ${{ steps.build.outputs.matrix }}

.github/workflows/build.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Aerospike Go Client Tests
2-
"on":
2+
on:
33
push:
44
pull_request:
55

@@ -8,14 +8,40 @@ env:
88
GODEBUG: fips140=only
99
GOFIPS140: latest
1010
jobs:
11+
make-matrix:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
input-matrix: ${{ steps.create-server-matrix.outputs.matrix }}
15+
go-version: ${{ steps.get-go-version.outputs.go-version }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Get Go version
20+
id: get-go-version
21+
run: |
22+
echo "go-version=$(grep '^go [0-9]' go.mod | awk '{print $2}')" >> $GITHUB_OUTPUT
23+
24+
- id: create-server-matrix
25+
uses: ./.github/actions/make-matrix
26+
with:
27+
default_json: |
28+
{
29+
"stable": { "version": "8.1.0.1" },
30+
"release": { "version": "8.1.0.1_2" }
31+
}
32+
go_version: ${{ steps.get-go-version.outputs.go-version }}
33+
34+
- name: debug - print input variables
35+
run: |
36+
echo ${{ steps.get-go-version.outputs.go-version }}
37+
echo ${{ steps.create-server-matrix.outputs.input-matrix }}
1138
build:
39+
timeout-minutes: 30
40+
needs: make-matrix
1241
runs-on: ubuntu-latest
1342
strategy:
1443
matrix:
15-
go-version:
16-
- 1.25.1
17-
server-version:
18-
- 8.1.0.0
44+
include: ${{ fromJson(needs.make-matrix.outputs.input-matrix) }}
1945
steps:
2046
- uses: actions/checkout@v4
2147
- name: "Setup Go ${{ matrix.go-version }}"
@@ -38,11 +64,13 @@ jobs:
3864
go mod vendor
3965
4066
- name: Display Go version
41-
run: go version
67+
run: |
68+
echo "Go version: ${{ matrix.go-version }}"
69+
4270
- name: Set up Aerospike Database
4371
uses: reugn/github-action-aerospike@v1
4472
with:
45-
server-version: ${{ matrix.server-version }}
73+
server-version: ${{ matrix.version }}
4674
- name: Test Lua Code
4775
env: {GOPROXY: off, GOSUMDB: off, GOFLAGS: -mod=vendor}
4876
run: go run -mod=vendor github.com/onsi/ginkgo/v2/ginkgo -cover -race -r -keep-going -succinct -randomize-suites internal/lua

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ docker-compose.yml
2828
golangci.yml
2929
cover*.out
3030
.vscode/settings.json
31-
ginkgo.report
31+
ginkgo.report
32+
.idea

0 commit comments

Comments
 (0)