forked from binance/binance-connector-js
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (75 loc) · 2.61 KB
/
ci.yaml
File metadata and controls
91 lines (75 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Connectors CI/CD
on:
pull_request:
jobs:
detect-targets:
runs-on: ubuntu-latest
outputs:
modified_targets: ${{ steps.filter.outputs.modified_targets }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Detect modified targets
id: filter
run: |
MODIFIED_TARGETS=()
# Ensure HEAD^ exists
if git rev-parse --verify HEAD^ >/dev/null 2>&1; then
BASE_COMMIT="HEAD^"
else
BASE_COMMIT=$(git rev-list --max-parents=0 HEAD) # First commit
fi
# Check common directory
if ! git diff --quiet "$BASE_COMMIT" HEAD -- "common"; then
echo "Changes detected in common"
MODIFIED_TARGETS+=("common")
fi
# Check each client dynamically
for client in clients/*; do
CLIENT_NAME=$(basename "$client")
if ! git diff --quiet "$BASE_COMMIT" HEAD -- "$client"; then
echo "Changes detected in $CLIENT_NAME"
MODIFIED_TARGETS+=("$CLIENT_NAME")
fi
done
# Convert to JSON array format
MODIFIED_TARGETS_JSON=$(printf '%s\n' "${MODIFIED_TARGETS[@]}" | jq -R -s -c 'split("\n") | map(select(. != ""))')
echo "Detected modified targets: $MODIFIED_TARGETS_JSON"
echo "modified_targets=$MODIFIED_TARGETS_JSON" >> $GITHUB_ENV
echo "::set-output name=modified_targets::$MODIFIED_TARGETS_JSON"
build-target:
runs-on: ubuntu-latest
needs: detect-targets
if: ${{ needs.detect-targets.outputs.modified_targets != '[]' }}
strategy:
matrix:
target: ${{ fromJson(needs.detect-targets.outputs.modified_targets) }}
node-version: [22.x]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: ${{ matrix.target == 'common' && 'common/package-lock.json' || format('clients/{0}/package-lock.json', matrix.target) }}
- name: Build ${{ matrix.target }}
run: |
if [ "${{ matrix.target }}" == "common" ]; then
cd common
else
cd clients/${{ matrix.target }}
fi
# Install dependencies
npm install
# Format
npm run format
# Lint
npm run lint
# Test
npm run test
# Build
npm run build