File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 default : ' '
1111
1212jobs :
13- examples :
13+ prepare :
1414 runs-on : ubuntu-latest
15+ outputs :
16+ matrix : ${{ steps.split.outputs.matrix }}
17+ steps :
18+ - uses : actions/checkout@v3
19+ with :
20+ repository : DataDog/datadog-api-client-go
21+ ref : ${{ inputs.target-branch || github.ref }}
22+ - name : Compute example groups
23+ id : split
24+ run : ./scripts/prepare-examples.sh
25+ shell : bash
26+
27+ build :
28+ needs : prepare
29+ runs-on : ubuntu-latest
30+ strategy :
31+ matrix :
32+ group : ${{ fromJson(needs.prepare.outputs.matrix) }}
1533 steps :
1634 - uses : actions/checkout@v3
1735 with :
2341 go-version : 1.22.x
2442 cache : true
2543 cache-dependency-path : tests/go.sum
26- - name : Check examples
27- run : ./check -examples.sh
28- shell : bash
44+ - name : Build examples (group ${{ matrix.group }})
45+ run : ./scripts/build -examples-group .sh ${{ matrix.group }}
46+ shell : bash
Original file line number Diff line number Diff line change 2121 required : false
2222
2323jobs :
24+ staticcheck :
25+ strategy :
26+ matrix :
27+ go-version : ["1.22.x", "1.23.x"]
28+ go-build-tags : ["--tags=goccy_gojson", ""]
29+ platform : ["ubuntu-latest"]
30+ runs-on : ${{ matrix.platform }}
31+ steps :
32+ - name : Checkout code
33+ uses : actions/checkout@v3
34+ with :
35+ repository : DataDog/datadog-api-client-go
36+ ref : ${{ inputs.target-branch || github.ref }}
37+ - name : Install Go
38+ uses : actions/setup-go@v4
39+ with :
40+ go-version : ${{ matrix.go-version }}
41+ cache : true
42+ cache-dependency-path : tests/go.sum
43+ - name : Staticcheck (api module)
44+ uses : dominikh/staticcheck-action@v1
45+ with :
46+ checks : " -SA1009"
47+ working-directory : api
48+ cache-key : ${{ matrix.go }}
49+ - name : Staticcheck (tests module)
50+ uses : dominikh/staticcheck-action@v1
51+ with :
52+ checks : " inherit,-SA1019"
53+ cache-key : ${{ matrix.go }}
54+ working-directory : tests
2455 test :
2556 strategy :
2657 matrix :
4172 cache : true
4273 cache-dependency-path : tests/go.sum
4374 - name : Test
44- run : ./run-tests.sh
75+ run : ./scripts/ run-tests.sh
4576 env :
4677 TESTARGS : ${{ matrix.go-build-tags }}
4778
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ jobs:
111111 cache-dependency-path : tests/go.sum
112112 - name : Run integration tests
113113 shell : bash
114- run : ./run-tests.sh
114+ run : ./scripts/ run-tests.sh
115115 env :
116116 CI : " true"
117117 DD_AGENT_HOST : localhost
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -e
3+
4+ GROUP=${1:? usage: build-examples-group.sh <group-number>}
5+ EXAMPLES_PER_GROUP=${EXAMPLES_PER_GROUP:- 400}
6+
7+ ALL_EXAMPLES=()
8+ while IFS= read -r f; do ALL_EXAMPLES+=(" $f " ); done < <( find examples -mindepth 3 -maxdepth 3 -name " *.go" | sort)
9+ TOTAL=${# ALL_EXAMPLES[@]}
10+
11+ START=$(( (GROUP - 1 ) * EXAMPLES_PER_GROUP ))
12+ SLICE=(" ${ALL_EXAMPLES[@]: $START : $EXAMPLES_PER_GROUP } " )
13+
14+ echo " Building group $GROUP : examples $(( START + 1 )) -$(( START + ${# SLICE[@]} )) of $TOTAL "
15+
16+ for f in " ${SLICE[@]} " ; do
17+ df=" build/$( dirname " $f " ) /$( basename " $f " .go) "
18+ mkdir -p " $df "
19+ cp " $f " " $df /main.go"
20+ done
21+
22+ if go build -o /dev/null -ldflags " -s -w -linkmode internal" ./build/examples/* /* /* ; then
23+ echo " Examples are buildable"
24+ else
25+ echo " Failed to build examples"
26+ exit 1
27+ fi
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -e
3+
4+ EXAMPLES_PER_GROUP=${EXAMPLES_PER_GROUP:- 400}
5+
6+ ALL_EXAMPLES=()
7+ while IFS= read -r f; do ALL_EXAMPLES+=(" $f " ); done < <( find examples -mindepth 3 -maxdepth 3 -name " *.go" | sort)
8+ TOTAL=${# ALL_EXAMPLES[@]}
9+ NUM_GROUPS=$(( (TOTAL + EXAMPLES_PER_GROUP - 1 ) / EXAMPLES_PER_GROUP ))
10+
11+ echo " Total examples: $TOTAL , groups: $NUM_GROUPS (max $EXAMPLES_PER_GROUP per group)"
12+
13+ MATRIX_JSON=" ["
14+ for i in $( seq 1 " $NUM_GROUPS " ) ; do
15+ [ " $i " -gt 1 ] && MATRIX_JSON+=" ,"
16+ MATRIX_JSON+=" $i "
17+ done
18+ MATRIX_JSON+=" ]"
19+
20+ echo " matrix=$MATRIX_JSON "
21+ if [ -n " ${GITHUB_OUTPUT:- } " ]; then
22+ echo " matrix=$MATRIX_JSON " >> " $GITHUB_OUTPUT "
23+ fi
Original file line number Diff line number Diff line change 2323# make sure the below installed dependencies don't get added to go.mod/go.sum
2424# unfortunately there's no better way to fix this than change directory
2525# this might get solved in Go 1.14: https://github.com/golang/go/issues/30515
26+ echo " Installing gotestsum"
2627cd " $( mktemp -d) "
27- GO111MODULE=on go install honnef.co/go/tools/cmd/staticcheck@latest
2828GO111MODULE=on go install gotest.tools/gotestsum@latest
2929cd -
3030
31- staticcheck -checks -SA1009 ./api/...
31+ echo " Running mod tidy and cleanup test cache "
3232go mod tidy
3333go clean -testcache
3434
3535# Run the same in tests submodule
3636cd tests
37- staticcheck -checks inherit,-SA1019 ./...
37+ echo " Running mod tidy and cleanup test cache in test module "
3838go mod tidy
3939go clean -testcache
4040
4141if [ " $RECORD " == " none" ]; then
42+ echo " Running with no RECORD"
4243 gotestsum --rerun-fails=1 --format short-verbose --packages ./... -- -timeout=20m $TESTARGS
4344else
45+ echo " Running with RECORD"
4446 gotestsum --format short-verbose --packages ./... -- $TESTARGS
4547fi
4648
You can’t perform that action at this time.
0 commit comments