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
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
You can’t perform that action at this time.
0 commit comments