1+ # SDK Breaking Change Check Workflow
2+ #
3+ # This workflow runs TypeScript compatibility checks when the SDK is updated.
4+ # Triggered automatically by the SDK repository via repository_dispatch when SDK PRs are created/updated.
5+ #
6+ name : " SDK Breaking Change Check (${{ github.event.client_payload.sdk_version }})"
7+
8+ on :
9+ repository_dispatch :
10+ types : [sdk-breaking-change-check]
11+
12+ permissions :
13+ contents : read
14+ actions : read
15+ id-token : write
16+
17+ jobs :
18+ type-check :
19+ name : TypeScript compatibility check
20+ runs-on : ubuntu-24.04
21+ timeout-minutes : 15
22+ env :
23+ SOURCE_REPO : ${{ github.event.client_payload.source_repo }}
24+ SDK_VERSION : ${{ github.event.client_payload.sdk_version }}
25+ ARTIFACTS_RUN_ID : ${{ github.event.client_payload.artifacts_info.run_id }}
26+ ARTIFACT_NAME : ${{ github.event.client_payload.artifacts_info.artifact_name }}
27+ CLIENT_LABEL : ${{ github.event.client_payload.client_label }}
28+
29+ steps :
30+ - name : Log in to Azure
31+ uses : bitwarden/gh-actions/azure-login@main
32+ with :
33+ subscription_id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
34+ tenant_id : ${{ secrets.AZURE_TENANT_ID }}
35+ client_id : ${{ secrets.AZURE_CLIENT_ID }}
36+ - name : Get Azure Key Vault secrets
37+ id : get-kv-secrets
38+ uses : bitwarden/gh-actions/get-keyvault-secrets@main
39+ with :
40+ keyvault : gh-org-bitwarden
41+ secrets : " BW-GHAPP-ID,BW-GHAPP-KEY"
42+
43+ - name : Generate GH App token
44+ uses : actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
45+ id : app-token
46+ with :
47+ app-id : ${{ steps.get-kv-secrets.outputs.BW-GHAPP-ID }}
48+ private-key : ${{ steps.get-kv-secrets.outputs.BW-GHAPP-KEY }}
49+ - name : Log out from Azure
50+ uses : bitwarden/gh-actions/azure-logout@main
51+ - name : Check out clients repository
52+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
53+
54+ - name : Get Node Version
55+ id : retrieve-node-version
56+ run : |
57+ NODE_NVMRC=$(cat .nvmrc)
58+ NODE_VERSION=${NODE_NVMRC/v/''}
59+ echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
60+
61+ - name : Set up Node
62+ uses : actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
63+ with :
64+ cache : ' npm'
65+ cache-dependency-path : ' **/package-lock.json'
66+ node-version : ${{ steps.retrieve-node-version.outputs.node_version }}
67+
68+ - name : Install Node dependencies
69+ run : npm ci
70+
71+ - name : Download SDK artifacts
72+ env :
73+ GH_TOKEN : ${{ steps.app-token.outputs.token }}
74+ run : |
75+ echo "📥 Downloading SDK artifacts from $SOURCE_REPO run $ARTIFACTS_RUN_ID..."
76+
77+ # Download SDK artifacts with error handling
78+ if ! gh run download $ARTIFACTS_RUN_ID \
79+ --repo $SOURCE_REPO \
80+ --name $ARTIFACT_NAME \
81+ --dir ./temp-sdk-artifacts; then
82+ echo "::error::Failed to download SDK artifacts from run $ARTIFACTS_RUN_ID"
83+ echo "::error::Repository: $SOURCE_REPO, Artifact: $ARTIFACT_NAME"
84+ exit 1
85+ fi
86+
87+ # Verify critical files exist
88+ if [ ! -f "./temp-sdk-artifacts/package.json" ]; then
89+ echo "::error::package.json not found in SDK artifacts"
90+ exit 1
91+ fi
92+
93+ if [ ! -f "./temp-sdk-artifacts/bitwarden_wasm_internal.d.ts" ]; then
94+ echo "::error::TypeScript definitions not found in SDK artifacts"
95+ exit 1
96+ fi
97+
98+ - name : Install SDK locally and run type check
99+ run : |
100+ echo "🔧 Installing SDK artifacts locally..."
101+ echo "📊 SDK Version: $SDK_VERSION"
102+ echo "📦 Artifact Source: $SOURCE_REPO run $ARTIFACTS_RUN_ID"
103+
104+ # Create local package and install
105+ mkdir -p ./local-sdk-package
106+ cp -r ./temp-sdk-artifacts/* ./local-sdk-package/
107+
108+ echo "📋 Local SDK package contents:"
109+ ls -la ./local-sdk-package/
110+
111+ echo "🔗 Installing local SDK package..."
112+ npm install ./local-sdk-package
113+
114+ echo "🔍 Running TypeScript type checking with SDK version: $SDK_VERSION"
115+ echo "🎯 Type checking command: npm run test:types"
116+
117+ # Add GitHub Step Summary output
118+ echo "## 📊 TypeScript Compatibility Check" >> $GITHUB_STEP_SUMMARY
119+ echo "- **SDK Version**: $SDK_VERSION" >> $GITHUB_STEP_SUMMARY
120+ echo "- **Source Repository**: $SOURCE_REPO" >> $GITHUB_STEP_SUMMARY
121+ echo "- **Artifacts Run ID**: $ARTIFACTS_RUN_ID" >> $GITHUB_STEP_SUMMARY
122+ echo "" >> $GITHUB_STEP_SUMMARY
123+
124+ TYPE_CHECK_START=$(date +%s)
125+
126+ # Run type check - exit code determines gh run watch result
127+ if npm run test:types; then
128+ TYPE_CHECK_END=$(date +%s)
129+ TYPE_CHECK_DURATION=$((TYPE_CHECK_END - TYPE_CHECK_START))
130+ echo "✅ TypeScript compilation successful (${TYPE_CHECK_DURATION}s)"
131+ echo "✅ **Result**: TypeScript compilation successful" >> $GITHUB_STEP_SUMMARY
132+ echo "No breaking changes detected in SDK version $SDK_VERSION" >> $GITHUB_STEP_SUMMARY
133+ else
134+ TYPE_CHECK_END=$(date +%s)
135+ TYPE_CHECK_DURATION=$((TYPE_CHECK_END - TYPE_CHECK_START))
136+ echo "❌ TypeScript compilation failed after ${TYPE_CHECK_DURATION}s - breaking changes detected"
137+ echo "❌ **Result**: TypeScript compilation failed" >> $GITHUB_STEP_SUMMARY
138+ echo "Breaking changes detected in SDK version $SDK_VERSION" >> $GITHUB_STEP_SUMMARY
139+ exit 1
140+ fi
141+
142+ # Cleanup temporary directories
143+ echo "🧹 Cleaning up temporary directories..."
144+ rm -rf ./temp-sdk-artifacts ./local-sdk-package
0 commit comments