Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2023eca
refactor(coin-updates): migrate to hive_ce with generated adapters
takenagain Aug 14, 2025
0602158
refactor(coin-updates): migrate from equatable to freezed
takenagain Aug 14, 2025
3fef011
test(coin-updates): add basic unit tests for data layer
takenagain Aug 14, 2025
dfce286
refactor(coin-updates): use komodo_types Asset models for parsing
takenagain Aug 14, 2025
ec71788
chore(coin-updates): update runtime update config model
takenagain Aug 14, 2025
2e2e31c
test(coin-updates): add hive ce tests and test harness
takenagain Aug 14, 2025
5b78648
feat(coin-updates): integrate komodo_coin_updates into komodo_coins
takenagain Aug 14, 2025
3cd75e9
refactor(coin-updates): replace manual barrel files with index_generator
takenagain Aug 15, 2025
e275ead
refactor(review): add default annotations, improve error handling & l…
takenagain Aug 15, 2025
509d1d3
test(coin-updates): expand test cases and edge case testing
takenagain Aug 15, 2025
f6bdd10
refactor(example): replace futurebuilder with cubit approach
takenagain Aug 15, 2025
8bcb243
ci(tests): add flutter test workflow
takenagain Aug 15, 2025
7022a14
docs(coin-updates): add auto-generated docs
takenagain Aug 15, 2025
fa7d08a
feat(ci): add package filter parameter for running specific tests
takenagain Aug 15, 2025
8ce6285
test(coin-updates): address nitpicks and improve coverage
takenagain Aug 15, 2025
d2f2764
fix(asset): align toJson with the expected structure in fromJson
takenagain Aug 19, 2025
0f7a5c6
refactor(komodo_coins): split config updating and fetching
takenagain Aug 19, 2025
e060b4c
test(komodo_coins): add unit tests for the new managers and strategies
takenagain Aug 19, 2025
453105d
fix(coin-updates): confirm boxes are not empty for exists check
takenagain Aug 19, 2025
46697de
Merge remote-tracking branch 'origin/dev' into feat/runtime-coin-updates
takenagain Aug 19, 2025
d28133a
fix(komodo_coins): initialize hive box
takenagain Aug 19, 2025
3d01b5b
fix(coin-updates): revert changes to asset classes and use protocol.c…
takenagain Aug 20, 2025
d9335df
test(coin-updates): document and deduplicate tests
takenagain Aug 21, 2025
617f140
fix(coins): use dedicated startup coins provider for kdf startup
takenagain Aug 21, 2025
d17ee5d
Merge remote-tracking branch 'origin/dev' into feat/runtime-coin-updates
takenagain Aug 21, 2025
61dc49a
ci: add GITHUB_TOKEN to flutter build steps
takenagain Aug 21, 2025
38e4b77
refactor(coin-updates): move build_config models to defi_types package
takenagain Aug 21, 2025
273f72f
fix(sparkline): cherry pick of 5dc948 to migrate to hive_ce
takenagain Aug 21, 2025
212c906
Merge branch 'dev' into feat/runtime-coin-updates
takenagain Aug 21, 2025
0f86fa1
refactor(review): update comments, references, and unnecessary libraries
takenagain Aug 22, 2025
1a25a1e
docs(coin_updates): update and add recommended SDK approach
takenagain Aug 22, 2025
c2db66a
refactor(seed-node-updater): use the new runtime update config for URL
takenagain Aug 22, 2025
98b0f71
fix(build-transformer): use new cdn mirrors and add unit tests
takenagain Aug 22, 2025
7d0dda9
fix(cex-market-data): add handling for too many request responses
takenagain Aug 22, 2025
37b5b04
docs&tests: update doc references, add example, remove faulty tests
takenagain Aug 22, 2025
0b01251
Merge branch 'dev' into feat/runtime-coin-updates
takenagain Aug 22, 2025
21eff1c
build(kdf): add transformer_invoker back for build transformer
takenagain Aug 22, 2025
2cb6cf0
Optimize in-flight request cleanup to avoid blocking response
cursoragent Aug 19, 2025
adb136f
fix(sparkline): Use unawaited for in-flight request cleanup to preven…
takenagain Aug 22, 2025
9423a80
Merge branch 'dev' into feat/runtime-coin-updates
takenagain Aug 25, 2025
19303ab
test(cex-market-data): fix ohlc breaking changes and add ci build step
takenagain Aug 25, 2025
383bca8
test(komodo_defi_rpc_methods): update rpc method test cases & interfaces
takenagain Aug 25, 2025
d113410
build: disable concurrent downloads for GitHub CI stability
takenagain Aug 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ jobs:
# - name: Bootstrap workspace
# run: melos bootstrap
- name: Run dry web build to generate assets (expected to fail)
env:
GITHUB_API_PUBLIC_READONLY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd playground && flutter build web --release || echo "Dry build completed (failure expected)"
- name: Build playground web
env:
GITHUB_API_PUBLIC_READONLY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd playground && flutter build web --release
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
Expand All @@ -75,6 +79,8 @@ jobs:
# - name: Bootstrap workspace
# run: melos bootstrap
- name: Build SDK example web
env:
GITHUB_API_PUBLIC_READONLY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd packages/komodo_defi_sdk/example && flutter build web --release
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ jobs:
# - name: Bootstrap workspace
# run: melos bootstrap
- name: Run dry web build to generate assets (expected to fail)
env:
GITHUB_API_PUBLIC_READONLY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd playground && flutter build web --release || echo "Dry build completed (failure expected)"
- name: Build playground web
env:
GITHUB_API_PUBLIC_READONLY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd playground && flutter build web --release
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
Expand All @@ -78,8 +82,12 @@ jobs:
# - name: Bootstrap workspace
# run: melos bootstrap
- name: Run dry web build to generate assets (expected to fail)
env:
GITHUB_API_PUBLIC_READONLY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd packages/komodo_defi_sdk/example && flutter build web --release || echo "Dry build completed (failure expected)"
Comment thread
takenagain marked this conversation as resolved.
- name: Build SDK example web
env:
GITHUB_API_PUBLIC_READONLY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd packages/komodo_defi_sdk/example && flutter build web --release
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
Expand Down
198 changes: 198 additions & 0 deletions .github/workflows/flutter-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
name: Flutter package tests (consolidated)
permissions:
contents: read

on:
push:
branches: [main]
pull_request:
branches: [main, dev, feat/**, bugfix/**, hotfix/**]
workflow_dispatch:
inputs:
package:
description: "Optional package path to test (e.g., packages/komodo_coin_updates or komodo_coin_updates)"
required: false
package_regex:
description: "Optional regex to filter packages (applied to full path under packages/*)"
required: false

jobs:
test-all:
name: Flutter tests (all packages)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Flutter (stable)
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: "3.35.1"
architecture: x64

- name: Cache pub dependencies
uses: actions/cache@v4
with:
path: |
~/.pub-cache
**/.dart_tool
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-

- name: Discover packages
id: discover
shell: bash
run: |
set -euo pipefail
input_pkg="${{ github.event.inputs.package || '' }}"
input_re="${{ github.event.inputs.package_regex || '' }}"

# Discover all packages with pubspec.yaml
mapfile -t all_pkgs < <(find packages -mindepth 1 -maxdepth 1 -type d -exec test -e '{}/pubspec.yaml' ';' -print | sort)

filter_pkgs=()
if [ -n "$input_pkg" ]; then
# Normalize to packages/<name>
if [[ "$input_pkg" != packages/* ]]; then
input_pkg="packages/$input_pkg"
fi
if [ -e "$input_pkg/pubspec.yaml" ]; then
filter_pkgs+=("$input_pkg")
else
echo "No pubspec.yaml found at $input_pkg; no packages to test" >&2
echo "packages=" >> "$GITHUB_OUTPUT"
exit 0
fi
elif [ -n "$input_re" ]; then
while IFS= read -r p; do
if echo "$p" | grep -Eq "$input_re"; then
filter_pkgs+=("$p")
fi
done < <(printf '%s\n' "${all_pkgs[@]}")
else
filter_pkgs=("${all_pkgs[@]}")
fi

# Keep only packages that contain a test/ directory
with_tests=()
for p in "${filter_pkgs[@]}"; do
if [ -d "$p/test" ]; then
with_tests+=("$p")
fi
done

if [ ${#with_tests[@]} -eq 0 ]; then
echo "packages=" >> "$GITHUB_OUTPUT"
exit 0
fi

# Output space-separated list of packages
echo "packages=${with_tests[*]}" >> "$GITHUB_OUTPUT"
echo "Found packages with tests: ${with_tests[*]}"

- name: Install dependencies for all packages
if: steps.discover.outputs.packages != ''
shell: bash
run: |
packages="${{ steps.discover.outputs.packages }}"
if [ -n "$packages" ]; then
for pkg in $packages; do
echo "Installing dependencies for $pkg..."
cd "$pkg"
flutter pub get
cd - > /dev/null
done
fi

- name: Run dry web build to generate assets (expected to fail)
if: steps.discover.outputs.packages != ''
env:
GITHUB_API_PUBLIC_READONLY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: packages/komodo_defi_sdk/example
run: flutter build web --release || echo "Dry build completed (failure expected)"

- name: Run tests for all packages
if: steps.discover.outputs.packages != ''
env:
GITHUB_API_PUBLIC_READONLY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
packages="${{ steps.discover.outputs.packages }}"

# Initialize results tracking
declare -A test_results
declare -A test_outputs
overall_success=true

echo "# Test Results" > test_summary.md
echo "" >> test_summary.md
echo "| Package | Status | Details |" >> test_summary.md
echo "|---------|--------|---------|" >> test_summary.md

# Run tests for each package
for pkg in $packages; do
echo ""
echo "========================================="
echo "Testing package: $pkg"
echo "========================================="

cd "$pkg"

# Run flutter test and capture output and exit code
if flutter_output=$(flutter test -r expanded 2>&1); then
test_results["$pkg"]="✅ PASS"
test_outputs["$pkg"]="Tests passed successfully"
echo "✅ $pkg: PASSED"
else
test_results["$pkg"]="❌ FAIL"
test_outputs["$pkg"]=$(echo "$flutter_output" | tail -n 10) # Last 10 lines for brevity
echo "❌ $pkg: FAILED"
overall_success=false
fi

cd - > /dev/null
done

echo ""
echo "========================================="
echo "TEST SUMMARY"
echo "========================================="

# Generate summary table
for pkg in $packages; do
status="${test_results[$pkg]}"
details="${test_outputs[$pkg]}"
# Escape pipe characters in details for markdown table
details=$(echo "$details" | sed 's/|/\\|/g' | tr '\n' ' ' | sed 's/ */ /g' | cut -c1-100)
if [ ${#details} -eq 100 ]; then
details="${details}..."
fi
echo "| \`$pkg\` | $status | $details |" >> test_summary.md
echo "$status $pkg"
done

echo ""
cat test_summary.md

# Set step summary for GitHub Actions
cat test_summary.md >> "$GITHUB_STEP_SUMMARY"

# Fail the job if any tests failed
if [ "$overall_success" = false ]; then
echo ""
echo "❌ One or more test suites failed!"
exit 1
else
echo ""
echo "✅ All test suites passed!"
fi

- name: Upload test summary
if: always() && steps.discover.outputs.packages != ''
uses: actions/upload-artifact@v4
with:
name: test-summary
path: test_summary.md
retention-days: 30
90 changes: 90 additions & 0 deletions docs/act-local-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Run GitHub Actions locally with act

This guide shows how to run the Flutter test workflow locally using act, filter to a single package, and re-run failed jobs on GitHub.

## Prerequisites

- Docker (required by act)
- Windows: [Install Docker Desktop on Windows](https://docs.docker.com/desktop/install/windows-install/)
- macOS: [Install Docker Desktop on Mac](https://docs.docker.com/desktop/install/mac-install/)
- Ubuntu: [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/)

- act
- macOS (Homebrew):

```bash
brew install act
```

- Other platforms: download a binary from [nektos/act releases](https://github.com/nektos/act/releases) and put it on your PATH
- Repo/docs: [nektos/act](https://github.com/nektos/act)

- (Optional) GitHub CLI (to re-run failed jobs on GitHub):
- Install: [GitHub CLI](https://cli.github.com/)

## Notes for Apple Silicon (M-series) Macs

- act may need to run containers as amd64:
- Add: `--container-architecture linux/amd64`
- Map `ubuntu-latest` to an image: `-P ubuntu-latest=catthehacker/ubuntu:act-latest`

## Common commands

- List jobs in this workflow:

```bash
act -l -W .github/workflows/flutter-tests.yml
```

- Run the test job for all packages (verbose):

```bash
act -j test --verbose \
-W .github/workflows/flutter-tests.yml \
-P ubuntu-latest=catthehacker/ubuntu:act-latest \
--container-architecture linux/amd64
```

- Run only a single package (e.g., packages/komodo_coin_updates) via workflow_dispatch input (verbose):

```bash
act workflow_dispatch -j test --verbose \
-W .github/workflows/flutter-tests.yml \
-P ubuntu-latest=catthehacker/ubuntu:act-latest \
--container-architecture linux/amd64 \
--input package=komodo_coin_updates
```

- Filter packages by regex (matches paths under `packages/*`):

```bash
act workflow_dispatch -j test --verbose \
-W .github/workflows/flutter-tests.yml \
-P ubuntu-latest=catthehacker/ubuntu:act-latest \
--container-architecture linux/amd64 \
--input package_regex='komodo_coin_updates'
```

## Re-run only failed jobs on GitHub

- GitHub UI: Actions → select the failed run → Re-run jobs → Re-run failed jobs
- GitHub CLI:

```bash
gh run rerun <run-id> --failed
```

## Verify installation

- Docker:

```bash
docker --version
docker run hello-world
```

- act:

```bash
act --version
```
38 changes: 38 additions & 0 deletions packages/komodo_cex_market_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,44 @@ const cfg = MarketDataConfig(
);
```

## Rate Limit Handling

The package includes intelligent rate limit handling to prevent API quota exhaustion and service disruption:

### Automatic 429 Detection

When a repository returns a 429 (Too Many Requests) response, it is immediately marked as unhealthy and excluded from requests for 5 minutes. The system detects rate limiting errors by checking for:

- HTTP status code 429 in exception messages
- Text patterns like "too many requests" or "rate limit"

### Fallback Behavior

```dart
// If CoinGecko hits rate limit, automatically falls back to Binance
final price = await manager.fiatPrice(assetId);
// No manual intervention required - fallback is transparent
```

### Repository Health Recovery

Rate-limited repositories automatically recover after the backoff period:

```dart
// After 5 minutes, CoinGecko becomes available again
// Next request will include it in the selection pool
final newPrice = await manager.fiatPrice(assetId);
```

### Monitoring Rate Limits

You can check repository health status (mainly useful for testing):

```dart
// Check if a repository is healthy (not rate-limited)
final isHealthy = manager.isRepositoryHealthyForTest(repository);
```

## License

MIT
7 changes: 7 additions & 0 deletions packages/komodo_cex_market_data/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
targets:
$default:
builders:
hive_ce_generator|hive_generator:
enabled: true
generate_for:
- lib/**.dart

This file was deleted.

Loading
Loading