This repository was archived by the owner on Sep 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (141 loc) · 6.07 KB
/
detect-changes.yml
File metadata and controls
162 lines (141 loc) · 6.07 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Detect Changes
on:
workflow_call:
outputs:
cli:
description: "CLI source files changed"
value: ${{ jobs.detect.outputs.cli }}
rust-sdk:
description: "Rust SDK files changed"
value: ${{ jobs.detect.outputs.rust-sdk }}
typescript-sdk:
description: "TypeScript SDK files changed"
value: ${{ jobs.detect.outputs.typescript-sdk }}
components:
description: "Any component files changed"
value: ${{ jobs.detect.outputs.components }}
mcp-authorizer:
description: "MCP authorizer component changed"
value: ${{ jobs.detect.outputs.mcp-authorizer }}
mcp-gateway:
description: "MCP gateway component changed"
value: ${{ jobs.detect.outputs.mcp-gateway }}
core-crates:
description: "Core crates changed (affects everything)"
value: ${{ jobs.detect.outputs.core-crates }}
go-sdk:
description: "Go SDK files changed"
value: ${{ jobs.detect.outputs.go-sdk }}
python-sdk:
description: "Python SDK files changed"
value: ${{ jobs.detect.outputs.python-sdk }}
ci:
description: "CI workflow files changed"
value: ${{ jobs.detect.outputs.ci }}
jobs:
detect:
name: Detect Changed Files
runs-on: ubuntu-latest
outputs:
cli: ${{ steps.detect.outputs.cli }}
rust-sdk: ${{ steps.detect.outputs.rust-sdk }}
typescript-sdk: ${{ steps.detect.outputs.typescript-sdk }}
components: ${{ steps.detect.outputs.components }}
mcp-authorizer: ${{ steps.detect.outputs.mcp-authorizer }}
mcp-gateway: ${{ steps.detect.outputs.mcp-gateway }}
core-crates: ${{ steps.detect.outputs.core-crates }}
go-sdk: ${{ steps.detect.outputs.go-sdk }}
python-sdk: ${{ steps.detect.outputs.python-sdk }}
ci: ${{ steps.detect.outputs.ci }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed files
id: detect
run: |
# Get the base and head commits
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
else
# For push events, compare with the previous commit
BASE_SHA="${{ github.event.before }}"
HEAD_SHA="${{ github.event.after }}"
# If this is the first commit, compare with empty tree
if [[ "$BASE_SHA" == "0000000000000000000000000000000000000000" ]]; then
BASE_SHA=$(git hash-object -t tree /dev/null)
fi
fi
echo "Comparing $BASE_SHA..$HEAD_SHA"
# Get list of changed files
CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" || true)
# Function to check if any file matches patterns
check_changes() {
local patterns="$1"
local changed=false
while IFS= read -r pattern; do
if echo "$CHANGED_FILES" | grep -qE "$pattern"; then
changed=true
break
fi
done <<< "$patterns"
echo "$changed"
}
# Check each category
# Go CLI patterns - includes cmd, internal, pkg, and shared directories
cli_patterns="^cmd/ftl/
^internal/
^pkg/
^go/
^go\.mod$
^go\.sum$"
CLI_CHANGED=$(check_changes "$cli_patterns")
echo "cli=$CLI_CHANGED" >> $GITHUB_OUTPUT
rust_sdk_patterns="^sdk/rust/
^sdk/rust-macros/"
RUST_SDK_CHANGED=$(check_changes "$rust_sdk_patterns")
echo "rust-sdk=$RUST_SDK_CHANGED" >> $GITHUB_OUTPUT
typescript_sdk_patterns="^sdk/typescript/"
TYPESCRIPT_SDK_CHANGED=$(check_changes "$typescript_sdk_patterns")
echo "typescript-sdk=$TYPESCRIPT_SDK_CHANGED" >> $GITHUB_OUTPUT
components_patterns="^components/
^\.cargo/config\.toml$
^Cargo\.toml$
^Cargo\.lock$"
COMPONENTS_CHANGED=$(check_changes "$components_patterns")
echo "components=$COMPONENTS_CHANGED" >> $GITHUB_OUTPUT
mcp_auth_patterns="^components/mcp-authorizer/"
MCP_AUTH_CHANGED=$(check_changes "$mcp_auth_patterns")
echo "mcp-authorizer=$MCP_AUTH_CHANGED" >> $GITHUB_OUTPUT
mcp_gw_patterns="^components/mcp-gateway/"
MCP_GW_CHANGED=$(check_changes "$mcp_gw_patterns")
echo "mcp-gateway=$MCP_GW_CHANGED" >> $GITHUB_OUTPUT
# No more crates directory - set to false
CORE_CHANGED="false"
echo "core-crates=$CORE_CHANGED" >> $GITHUB_OUTPUT
go_sdk_patterns="^sdk/go/"
GO_SDK_CHANGED=$(check_changes "$go_sdk_patterns")
echo "go-sdk=$GO_SDK_CHANGED" >> $GITHUB_OUTPUT
python_sdk_patterns="^sdk/python/"
PYTHON_SDK_CHANGED=$(check_changes "$python_sdk_patterns")
echo "python-sdk=$PYTHON_SDK_CHANGED" >> $GITHUB_OUTPUT
ci_patterns="^\.github/workflows/"
CI_CHANGED=$(check_changes "$ci_patterns")
echo "ci=$CI_CHANGED" >> $GITHUB_OUTPUT
# Debug output
echo "::group::Changed files"
echo "$CHANGED_FILES"
echo "::endgroup::"
echo "::group::Detection results"
echo "CLI changed: $CLI_CHANGED"
echo "Rust SDK changed: $RUST_SDK_CHANGED"
echo "TypeScript SDK changed: $TYPESCRIPT_SDK_CHANGED"
echo "Go SDK changed: $GO_SDK_CHANGED"
echo "Python SDK changed: $PYTHON_SDK_CHANGED"
echo "Components changed: $COMPONENTS_CHANGED"
echo "MCP Authorizer changed: $MCP_AUTH_CHANGED"
echo "MCP Gateway changed: $MCP_GW_CHANGED"
echo "Core crates changed: $CORE_CHANGED"
echo "CI changed: $CI_CHANGED"
echo "::endgroup::"