Skip to content

Commit d250a42

Browse files
fix(sdk): Apply SDK fix for coins bug and KDF release update (#2637)
* fix: fix SDK roll CI script issues - Fix SDK roll CI script issues - Roll SDK version * CI Test #1 * build: update remaining SDK commit refs in lockfiles * CI Test 2 * fix(icon-pre-caching): exclude excluded assets to remove NFT_ coins `NFT_` prefixed coins do not have icons and should not be shown to users, so filter them out from the icon pre-caching * chore: roll SDK * chore(deps): upgrade SDK to include fee info fix https://github.com/KomodoPlatform/komodo-defi-sdk-flutter/pull/60 --------- Co-authored-by: Francois <[email protected]>
1 parent cf6de47 commit d250a42

File tree

10 files changed

+364
-51
lines changed

10 files changed

+364
-51
lines changed

.github/actions/flutter-deps/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ runs:
99
# NB! Keep up-to-date with the flutter version used for development
1010
flutter-version: "3.29.2"
1111
channel: "stable"
12-
cache: true
1312

1413
- name: Prepare build directory
1514
shell: bash

.github/scripts/roll_sdk_packages.sh

Lines changed: 101 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,55 @@
22

33
# Script to roll SDK packages in all Flutter/Dart projects
44
# Designed to handle git-based dependencies and work with the GitHub CI workflow
5+
#
6+
# Usage:
7+
# UPGRADE_ALL_PACKAGES=false TARGET_BRANCH=dev .github/scripts/roll_sdk_packages.sh
8+
#
9+
# Parameters:
10+
# UPGRADE_ALL_PACKAGES: Set to "true" to upgrade all packages, "false" to only upgrade SDK packages
11+
# TARGET_BRANCH: The target branch for PR creation
12+
#
13+
# For more details, see `docs/SDK_DEPENDENCY_MANAGEMENT.md`
514

15+
# Exit on error, but with proper cleanup
616
set -e
717

18+
# Error handling and cleanup function
19+
cleanup() {
20+
local exit_code=$?
21+
22+
# Only perform cleanup if there was an error
23+
if [ $exit_code -ne 0 ] && [ $exit_code -ne 100 ]; then
24+
echo "ERROR: Script failed with exit code $exit_code"
25+
# Clean up any temporary files
26+
find "$REPO_ROOT" -name "*.bak" -type f -delete
27+
fi
28+
29+
exit $exit_code
30+
}
31+
32+
# Set up trap to catch errors
33+
trap cleanup EXIT
34+
35+
# Log function for better reporting
36+
log_info() {
37+
echo "INFO: $1"
38+
}
39+
40+
log_warning() {
41+
echo "WARNING: $1" >&2
42+
}
43+
44+
log_error() {
45+
echo "ERROR: $1" >&2
46+
}
47+
48+
# Validate Flutter is available
49+
if ! command -v flutter &> /dev/null; then
50+
log_error "Flutter command not found. Please ensure Flutter is installed and in your PATH."
51+
exit 1
52+
fi
53+
854
# Configuration
955
# Set to "true" to upgrade all packages, "false" to only upgrade SDK packages
1056
UPGRADE_ALL_PACKAGES=${UPGRADE_ALL_PACKAGES:-false}
@@ -16,6 +62,10 @@ CURRENT_DATE=$(date '+%Y-%m-%d')
1662
REPO_ROOT=$(pwd)
1763
CHANGES_FILE="$REPO_ROOT/SDK_CHANGELOG.md"
1864

65+
# List of external SDK packages to be updated (from KomodoPlatform/komodo-defi-sdk-flutter.git)
66+
# Local packages like 'komodo_ui_kit' and 'komodo_persistence_layer' are not included
67+
# as they're part of this repository, not the external SDK
68+
1969
# SDK packages to check
2070
SDK_PACKAGES=(
2171
"komodo_cex_market_data"
@@ -117,7 +167,18 @@ for PUBSPEC in $PUBSPEC_FILES; do
117167
PROJECT_DIR=$(dirname "$PUBSPEC")
118168
PROJECT_NAME=$(basename "$PROJECT_DIR")
119169

120-
echo "Processing $PROJECT_NAME ($PROJECT_DIR)"
170+
# Special handling for the root project
171+
if [ "$PROJECT_DIR" = "$REPO_ROOT" ]; then
172+
PROJECT_NAME="Root Project (komodo-wallet)"
173+
echo "Processing ROOT PROJECT ($PROJECT_DIR)"
174+
else
175+
echo "Processing $PROJECT_NAME ($PROJECT_DIR)"
176+
fi
177+
178+
# Debug: Print information about processing the project
179+
echo "Debug info for $PROJECT_NAME:"
180+
echo " - Project path: $PROJECT_DIR"
181+
echo " - Full pubspec path: $PUBSPEC"
121182

122183
cd "$PROJECT_DIR"
123184

@@ -126,9 +187,19 @@ for PUBSPEC in $PUBSPEC_FILES; do
126187
SDK_PACKAGES_FOUND=()
127188

128189
for PACKAGE in "${SDK_PACKAGES[@]}"; do
129-
if grep -q -E "^\s+$PACKAGE:" "$PUBSPEC"; then
130-
CONTAINS_SDK_PACKAGE=true
131-
SDK_PACKAGES_FOUND+=("$PACKAGE")
190+
# More robust pattern matching that allows for comments and other formatting
191+
if grep -q "^[[:space:]]*$PACKAGE:" "$PUBSPEC"; then
192+
# Additional check: detect if it's a git-based package from the KomodoPlatform repo
193+
if grep -A 10 "$PACKAGE:" "$PUBSPEC" | grep -q "github.com/KomodoPlatform/komodo-defi-sdk-flutter"; then
194+
echo "Found SDK package $PACKAGE (git-based) in $PROJECT_NAME"
195+
CONTAINS_SDK_PACKAGE=true
196+
SDK_PACKAGES_FOUND+=("$PACKAGE")
197+
else
198+
echo "Package $PACKAGE found but may not be from the SDK repository"
199+
# Still include it, but log for clarity
200+
CONTAINS_SDK_PACKAGE=true
201+
SDK_PACKAGES_FOUND+=("$PACKAGE")
202+
fi
132203
fi
133204
done
134205

@@ -150,7 +221,7 @@ for PUBSPEC in $PUBSPEC_FILES; do
150221
# Get the current git refs/versions for SDK packages before update
151222
SDK_PACKAGE_REFS_BEFORE=()
152223
for PACKAGE in "${SDK_PACKAGES_FOUND[@]}"; do
153-
if grep -q "$PACKAGE:" "$PUBSPEC"; then
224+
if grep -q "^[[:space:]]*$PACKAGE:" "$PUBSPEC"; then
154225
# Get the git reference line or version line
155226
if grep -q -A 10 "$PACKAGE:" "$PUBSPEC" | grep -q "git:"; then
156227
REF_LINE=$(grep -A 10 "$PACKAGE:" "$PUBSPEC" | grep -m 1 "ref:")
@@ -173,15 +244,24 @@ for PUBSPEC in $PUBSPEC_FILES; do
173244

174245
# Perform the update - based on configuration
175246
if [ "$UPGRADE_ALL_PACKAGES" = "true" ]; then
176-
echo "Running flutter pub upgrade --major-versions in $PROJECT_NAME (all packages)"
177-
flutter pub upgrade --major-versions
247+
log_info "Running flutter pub upgrade --major-versions in $PROJECT_NAME (all packages)"
248+
if ! flutter pub upgrade --major-versions; then
249+
log_error "Failed to upgrade all packages in $PROJECT_NAME"
250+
cd "$REPO_ROOT"
251+
continue
252+
fi
178253
else
179-
echo "Running flutter pub upgrade for SDK packages only in $PROJECT_NAME"
180-
# Upgrade only the SDK packages
181-
for PACKAGE in "${SDK_PACKAGES_FOUND[@]}"; do
182-
echo "Upgrading $PACKAGE"
183-
flutter pub upgrade "$PACKAGE"
184-
done
254+
log_info "Running flutter pub upgrade for SDK packages only in $PROJECT_NAME"
255+
# Upgrade all SDK packages at once
256+
if [ ${#SDK_PACKAGES_FOUND[@]} -gt 0 ]; then
257+
log_info "Upgrading packages: ${SDK_PACKAGES_FOUND[*]}"
258+
if ! flutter pub upgrade --unlock-transitive ${SDK_PACKAGES_FOUND[@]}; then
259+
log_warning "Failed to upgrade packages in $PROJECT_NAME"
260+
PACKAGE_UPDATE_FAILED=true
261+
fi
262+
else
263+
log_info "No SDK packages found to upgrade in $PROJECT_NAME"
264+
fi
185265
fi
186266

187267
# Check if the pubspec.lock was modified
@@ -253,20 +333,22 @@ fi
253333
if [ -n "${GITHUB_OUTPUT}" ]; then
254334
if [ "$ROLLS_MADE" = true ]; then
255335
echo "updates_found=true" >> $GITHUB_OUTPUT
256-
echo "Rolls found and applied!"
336+
log_info "Rolls found and applied!"
257337
exit 0
258338
else
259339
echo "updates_found=false" >> $GITHUB_OUTPUT
260-
echo "No rolls needed."
261-
exit 1
340+
log_info "No rolls needed."
341+
# Exit with special code 100 to indicate no changes needed (not a failure)
342+
exit 100
262343
fi
263344
else
264345
# When running outside of GitHub Actions
265346
if [ "$ROLLS_MADE" = true ]; then
266-
echo "Rolls found and applied! See $CHANGES_FILE for details."
347+
log_info "Rolls found and applied! See $CHANGES_FILE for details."
267348
exit 0
268349
else
269-
echo "No rolls needed."
270-
exit 1
350+
log_info "No rolls needed."
351+
# Exit with special code 100 to indicate no changes needed (not a failure)
352+
exit 100
271353
fi
272354
fi

.github/workflows/roll-sdk-packages.yml

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
# filepath: /Users/charl/Code/UTXO/komodo-wallet/.github/workflows/roll-sdk-packages.yml
12
name: Roll SDK Packages
23

4+
# This workflow automates updating SDK package dependencies from the external komodo-defi-sdk-flutter repository
5+
# It creates or updates a pull request with the necessary changes to pubspec.yaml and pubspec.lock files
6+
# For more information on how this works or how to run the script manually, see:
7+
# https://github.com/KomodoPlatform/komodo-wallet/blob/dev/docs/SDK_DEPENDENCY_MANAGEMENT.md
8+
39
on:
410
schedule:
511
# Run once a day at midnight
612
- cron: "0 0 * * *"
713
push:
814
branches:
915
- dev
10-
pull_request:
11-
branches:
12-
- dev
1316
# Allow manual trigger
1417
workflow_dispatch:
1518
inputs:
@@ -33,7 +36,7 @@ jobs:
3336

3437
steps:
3538
- name: Checkout code
36-
uses: actions/checkout@v3
39+
uses: actions/checkout@v4
3740
with:
3841
fetch-depth: 0
3942
token: ${{ secrets.GITHUB_TOKEN }}
@@ -44,7 +47,6 @@ jobs:
4447
# NB! Keep up-to-date with the flutter version used for development
4548
flutter-version: "3.29.2"
4649
channel: "stable"
47-
cache: true
4850

4951
- name: Determine configuration
5052
id: config
@@ -77,11 +79,21 @@ jobs:
7779
- name: Run roll script
7880
id: roll_packages
7981
run: |
80-
UPGRADE_ALL_PACKAGES=${{ env.UPGRADE_ALL }} TARGET_BRANCH=${{ env.TARGET_BRANCH }} .github/scripts/roll_sdk_packages.sh || echo "No rolls needed"
82+
# Run the script and capture exit code
83+
UPGRADE_ALL_PACKAGES=${{ env.UPGRADE_ALL }} TARGET_BRANCH=${{ env.TARGET_BRANCH }} .github/scripts/roll_sdk_packages.sh || EXIT_CODE=$?
84+
85+
# Different handling based on exit code
8186
if [ -f "SDK_CHANGELOG.md" ]; then
8287
echo "ROLLS_FOUND=true" >> $GITHUB_ENV
88+
echo "SDK packages were successfully rolled"
8389
else
8490
echo "ROLLS_FOUND=false" >> $GITHUB_ENV
91+
92+
if [ -n "${EXIT_CODE}" ] && [ ${EXIT_CODE} -ne 100 ]; then
93+
echo "::warning::SDK package roll script failed with exit code ${EXIT_CODE}"
94+
else
95+
echo "No SDK package updates were needed"
96+
fi
8597
fi
8698
8799
- name: Setup Git identity
@@ -90,13 +102,35 @@ jobs:
90102
git config --global user.name "GitHub Action Bot"
91103
git config --global user.email "github-actions[bot]@users.noreply.github.com"
92104
105+
- name: Install GitHub CLI
106+
if: env.ROLLS_FOUND == 'true'
107+
run: |
108+
if ! command -v gh &> /dev/null; then
109+
echo "Installing GitHub CLI..."
110+
# GitHub CLI should already be installed on GitHub Actions runners
111+
# This is a fallback mechanism
112+
gh --version || {
113+
echo "GitHub CLI not found, installing..."
114+
type -p curl >/dev/null || sudo apt-get install curl -y
115+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
116+
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
117+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
118+
&& sudo apt-get update \
119+
&& sudo apt-get install gh -y
120+
}
121+
fi
122+
# Verify GitHub CLI is available
123+
gh --version
124+
93125
- name: Create PR Branch
94126
if: env.ROLLS_FOUND == 'true'
95127
run: |
96128
# Check if the branch already exists
97129
if git ls-remote --heads origin ${{ env.PR_BRANCH_NAME }} | grep -q ${{ env.PR_BRANCH_NAME }}; then
98130
# If it exists, delete it (force update)
99-
git push origin --delete ${{ env.PR_BRANCH_NAME }}
131+
git push origin --delete ${{ env.PR_BRANCH_NAME }} || {
132+
echo "::warning::Failed to delete existing branch ${{ env.PR_BRANCH_NAME }} - it may be protected"
133+
}
100134
fi
101135
102136
# Create new branch
@@ -109,20 +143,23 @@ jobs:
109143
git status
110144
111145
git commit -m "chore: roll SDK packages targeting ${{ env.TARGET_BRANCH }}"
112-
git push --set-upstream origin "${{ env.PR_BRANCH_NAME }}"
146+
git push --set-upstream origin "${{ env.PR_BRANCH_NAME }}" || {
147+
echo "::error::Failed to push branch to origin - check credentials and branch protection settings"
148+
exit 1
149+
}
113150
114151
- name: Create Pull Request
115152
if: env.ROLLS_FOUND == 'true'
116153
run: |
117154
# Check if a PR from this branch to target branch already exists
118-
EXISTING_PR=$(gh pr list --head "${{ env.PR_BRANCH_NAME }}" --base "${{ env.TARGET_BRANCH }}" --json number --jq '.[0].number')
155+
EXISTING_PR=$(gh pr list --head "${{ env.PR_BRANCH_NAME }}" --base "${{ env.TARGET_BRANCH }}" --json number --jq '.[0].number' || echo "")
119156
120157
if [ -n "$EXISTING_PR" ]; then
121158
echo "Updating existing PR #$EXISTING_PR with new changes"
122159
# Update the PR body with the latest SDK roll changes
123-
gh pr edit "$EXISTING_PR" --body-file SDK_CHANGELOG.md
160+
gh pr edit "$EXISTING_PR" --body-file SDK_CHANGELOG.md || echo "::warning::Failed to update PR body"
124161
# Add a comment to notify about the update
125-
gh pr comment "$EXISTING_PR" --body "Updated SDK roll with new changes on $(date '+%Y-%m-%d %H:%M:%S')"
162+
gh pr comment "$EXISTING_PR" --body "Updated SDK roll with new changes on $(date '+%Y-%m-%d %H:%M:%S')" || echo "::warning::Failed to add comment to PR"
126163
else
127164
# Create the pull request using gh CLI
128165
gh pr create \
@@ -131,7 +168,10 @@ jobs:
131168
--base "${{ env.TARGET_BRANCH }}" \
132169
--head "${{ env.PR_BRANCH_NAME }}" \
133170
--label "dependencies" \
134-
--label "automated"
171+
--label "automated" || {
172+
echo "::error::Failed to create Pull Request - check GitHub token permissions"
173+
exit 1
174+
}
135175
fi
136176
env:
137177
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Current production version is available here: https://app.komodoplatform.com
3434
- [Localization](docs/LOCALIZATION.md)
3535
- [Unit testing](docs/UNIT_TESTING.md)
3636
- [Integration testing](docs/INTEGRATION_TESTING.md)
37+
- [SDK Dependency Management](docs/SDK_DEPENDENCY_MANAGEMENT.md)
3738
- [Gitflow and branching strategy](docs/GITFLOW_BRANCHING.md)
3839
- [Issue: create and maintain](docs/ISSUE.md) ...in progress
3940
- [Contribution guide](docs/CONTRIBUTION_GUIDE.md)

0 commit comments

Comments
 (0)