improve TS typing #322
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
| on: [push] | |
| # These tests are considered irrelevant for a proper deployment, but sure are nice to have correct most of the time. | |
| name: QualityAssurance | |
| jobs: | |
| fmt: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: stable | |
| components: rustfmt | |
| - uses: Swatinem/rust-cache@v2 | |
| - run: cargo +stable --locked fmt --all -- --check | |
| cargo-deny: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: EmbarkStudios/cargo-deny-action@v2 | |
| with: | |
| rust-version: stable | |
| spell-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check spelling of entire workspace | |
| uses: crate-ci/typos@master | |
| clippy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: stable | |
| components: clippy | |
| - uses: Swatinem/rust-cache@v2 | |
| - run: cargo +stable clippy --workspace -- -D warnings | |
| sqlx-offline-cache: | |
| name: sqlx offline cache check with prepare | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: stable | |
| - name: Install sqlx-cli (sqlite support) | |
| run: | | |
| cargo install sqlx-cli --no-default-features --features sqlite --locked | |
| - name: Run sqlx prepare --check | |
| run: | | |
| cargo sqlx prepare --check --workspace | |
| coverage: | |
| name: Coverage report (llvm-cov) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code (with LFS because pngs for visual regression are saved there) | |
| uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| fetch-depth: 0 | |
| - name: Install test fonts (Inter & Cascadia Code) | |
| run: | | |
| set -eux | |
| # Ubuntu fonts; fail if they can't be installed. | |
| sudo apt-get update | |
| sudo apt-get install -y fonts-inter fonts-cascadia-code | |
| # Verify via fc-list; if fc-list isn't present this will fail which | |
| # is desired so the CI run fails when fonts are not available. | |
| fc-list | grep -i inter >/dev/null 2>&1 || { echo "Inter font not found after install" >&2; exit 1; } | |
| fc-list | grep -i cascadia >/dev/null 2>&1 || { echo "Cascadia Code not found after install" >&2; exit 1; } | |
| sudo fc-cache -f -v | |
| - name: Install node deps, Playwright Chromium and system deps | |
| run: | | |
| cd frontend | |
| npm ci | |
| npm run install-chromium-ci | |
| - name: Ensure latest stable rustc | |
| shell: bash | |
| run: rustup update stable | |
| - name: Install cargo-llvm-cov | |
| uses: taiki-e/install-action@cargo-llvm-cov | |
| # running these in an individual step didn't work. | |
| - name: Generate coverage reports based on playwright and Rust tests | |
| env: | |
| CI: true | |
| COVERAGE: 1 | |
| SKIP_BUILD: 1 | |
| run: | | |
| set -e | |
| eval "$(cargo llvm-cov show-env --export-prefix)" | |
| cargo llvm-cov clean --workspace | |
| cargo build --workspace | |
| cd frontend && npx playwright test && cd .. | |
| cargo test --workspace --all-targets | |
| cargo llvm-cov report --lcov --output-path lcov.info --ignore-filename-regex "src/bin/coordinator.rs|host_agent/src/main.rs" | |
| cargo llvm-cov report --html --output-dir coverage --ignore-filename-regex "src/bin/coordinator.rs|host_agent/src/main.rs" | |
| - name: Upload coverage artifacts (HTML + LCOV) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-reports | |
| path: | | |
| ./coverage/ | |
| ./lcov.info | |
| - name: Check for excessive changes in lcov.info (its not really stable) | |
| run: | | |
| if git diff --quiet lcov.info; then | |
| echo "lcov.info is unchanged." | |
| else | |
| TOTAL_LINES=$(wc -l < lcov.info) | |
| NUMSTAT=$(git diff --numstat lcov.info | awk '{ins+=$1; del+=$2} END {print ins, del}') | |
| INSERTIONS=$(echo $NUMSTAT | cut -d' ' -f1) | |
| DELETIONS=$(echo $NUMSTAT | cut -d' ' -f2) | |
| CHANGED=$((INSERTIONS + DELETIONS)) | |
| PERCENT_CHANGED=$((CHANGED * 100 / TOTAL_LINES)) | |
| PERCENT_INS=$((INSERTIONS * 100 / TOTAL_LINES)) | |
| PERCENT_DEL=$((DELETIONS * 100 / TOTAL_LINES)) | |
| echo "lcov.info changes: $CHANGED lines ($PERCENT_CHANGED%), insertions: $PERCENT_INS%, deletions: $PERCENT_DEL%" | |
| if [ $PERCENT_CHANGED -gt 15 ] || [ $PERCENT_INS -gt 5 ] || [ $PERCENT_DEL -gt 5 ]; then | |
| echo "Excessive changes detected in lcov.info. Consider updating." | |
| exit 1 | |
| fi | |
| fi |