fix(frontend): keep client registry in parity with core clients #388
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test & Coverage | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main, develop] | |
| paths: | |
| - 'crates/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - 'packages/frontend/src/lib/clientRegistry.ts' | |
| - 'packages/frontend/src/lib/clientRegistry.json' | |
| - 'packages/frontend/public/assets/logos/**' | |
| - 'packages/cli/package.json' | |
| - 'packages/tokscale/package.json' | |
| - 'packages/cli-*/package.json' | |
| - 'scripts/check-version-coherence.sh' | |
| - '.github/workflows/publish-cli.yml' | |
| - '.github/workflows/test_coverage.yml' | |
| pull_request: | |
| branches: [main, develop] | |
| paths: | |
| - 'crates/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - 'packages/frontend/src/lib/clientRegistry.ts' | |
| - 'packages/frontend/src/lib/clientRegistry.json' | |
| - 'packages/frontend/public/assets/logos/**' | |
| - 'packages/cli/package.json' | |
| - 'packages/tokscale/package.json' | |
| - 'packages/cli-*/package.json' | |
| - 'scripts/check-version-coherence.sh' | |
| - '.github/workflows/publish-cli.yml' | |
| - '.github/workflows/test_coverage.yml' | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # Check out the PR branch for same-repo PRs so we can push auto-fixes back | |
| ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.head_ref || '' }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - name: Verify version coherence | |
| run: bash scripts/check-version-coherence.sh | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: lint-${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: | | |
| lint-${{ runner.os }}-cargo- | |
| - name: Auto-fix lint issues | |
| id: autofix | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| run: | | |
| # Apply machine-fixable clippy lints | |
| cargo clippy --fix --workspace --all-features --allow-dirty --allow-staged 2>&1 || true | |
| # Apply formatting | |
| cargo fmt --all | |
| # Check if anything changed | |
| if ! git diff --quiet; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit auto-fixes | |
| if: steps.autofix.outputs.has_changes == 'true' | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add -A | |
| git diff --staged --quiet || git commit -m "style: auto-fix lint issues [skip ci]" | |
| git pull --rebase origin "${{ github.head_ref }}" | |
| git push origin "HEAD:${{ github.head_ref }}" | |
| - name: Run Clippy (strict) | |
| run: cargo clippy --workspace --all-features -- -D warnings | |
| - name: Check formatting (strict) | |
| run: cargo fmt --all -- --check | |
| coverage: | |
| name: Code Coverage | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: coverage-${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: | | |
| coverage-${{ runner.os }}-cargo- | |
| - name: Run tests | |
| run: cargo test --workspace --all-features | |
| - name: Install cargo-tarpaulin | |
| if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | |
| uses: taiki-e/install-action@cargo-tarpaulin | |
| - name: Generate coverage report | |
| if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | |
| run: | | |
| cargo tarpaulin \ | |
| --workspace \ | |
| --all-features \ | |
| --out Xml Json \ | |
| --output-dir ./coverage \ | |
| --timeout 300 \ | |
| --verbose | |
| - name: Extract coverage percentage | |
| if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | |
| id: coverage | |
| run: | | |
| COVERAGE=$(cat ./coverage/tarpaulin-report.json | jq -r ' | |
| [.files[]] | | |
| (map(.covered) | add) as $total_covered | | |
| (map(.coverable) | add) as $total_coverable | | |
| if $total_coverable > 0 then | |
| ($total_covered / $total_coverable * 100) | |
| else | |
| 0 | |
| end | |
| ') | |
| COVERAGE_INT=$(printf "%.0f" $COVERAGE) | |
| echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT | |
| echo "percentage_int=$COVERAGE_INT" >> $GITHUB_OUTPUT | |
| echo "Coverage: $COVERAGE%" | |
| # Determine badge color | |
| if [ $COVERAGE_INT -gt 80 ]; then | |
| echo "color=green" >> $GITHUB_OUTPUT | |
| elif [ $COVERAGE_INT -gt 60 ]; then | |
| echo "color=yellow" >> $GITHUB_OUTPUT | |
| elif [ $COVERAGE_INT -gt 40 ]; then | |
| echo "color=orange" >> $GITHUB_OUTPUT | |
| else | |
| echo "color=red" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create badges directory | |
| if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | |
| run: mkdir -p .github/badges | |
| - name: Generate coverage badge | |
| if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | |
| uses: emibcn/badge-action@v2.0.3 | |
| with: | |
| label: 'coverage' | |
| status: ${{ steps.coverage.outputs.percentage_int }}% | |
| color: ${{ steps.coverage.outputs.color }} | |
| path: .github/badges/coverage.svg | |
| - name: Commit coverage badge | |
| if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add .github/badges/coverage.svg | |
| git diff --quiet && git diff --staged --quiet || (git commit -m "ci: update coverage badge [skip ci]" && git push) | |
| - name: Upload coverage artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: "!cancelled() && github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')" | |
| with: | |
| name: coverage-report | |
| path: ./coverage/ | |
| retention-days: 7 |