style: format code for better readability in terminal output and tests #46
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main, develop] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CLIPPY_ARGS: -D warnings | |
| jobs: | |
| # ======================================== | |
| # TypeScript Tests (Node.js) | |
| # ======================================== | |
| test-ts: | |
| name: TS Tests (Node 20.19.0) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| node: [20, 22] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile --ignore-scripts | |
| - name: Build qrcode-wasm | |
| run: pnpm --filter @veaba/qrcode-wasm build | |
| - name: Build shared package | |
| run: pnpm --filter @veaba/qrcode-js-shared build | |
| - name: Run unit tests | |
| run: pnpm test:unit | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: '1.3.0' | |
| - name: Run Bun tests | |
| run: pnpm test -- --bun | |
| - name: Generate coverage report | |
| if: matrix.os == 'ubuntu-latest' | |
| run: pnpm test:coverage | |
| - name: Upload coverage to Codecov | |
| if: matrix.os == 'ubuntu-latest' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./coverage/lcov.info | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| # ======================================== | |
| # Browser Tests (WASM) | |
| # ======================================== | |
| test-browser: | |
| name: Browser Tests (Chrome) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile --ignore-scripts | |
| - name: Install Playwright browsers and dependencies | |
| run: pnpm exec playwright install chromium --with-deps | |
| - name: Build qrcode-wasm | |
| run: pnpm --filter @veaba/qrcode-wasm build | |
| - name: Build shared package | |
| run: pnpm --filter @veaba/qrcode-js-shared build | |
| - name: Run browser tests | |
| run: pnpm test:browser | |
| env: | |
| CI: true | |
| # ======================================== | |
| # Rust Tests | |
| # ======================================== | |
| test-rust: | |
| name: Rust Tests | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| rust: [stable, beta] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: ${{ matrix.rust }} | |
| components: rustfmt, clippy | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo index | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo build | |
| uses: actions/cache@v4 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Run cargo test | |
| run: cargo test --workspace --verbose | |
| - name: Run cargo clippy | |
| if: matrix.rust == 'stable' | |
| run: cargo clippy --workspace --all-targets -- ${{ env.CLIPPY_ARGS }} | |
| - name: Check formatting | |
| if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' | |
| run: cargo fmt --all -- --check | |
| # ======================================== | |
| # WASM Build Test | |
| # ======================================== | |
| test-wasm-build: | |
| name: WASM Build Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'pnpm' | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: '1.3.0' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build WASM (web target) | |
| run: pnpm --filter @veaba/qrcode-wasm build | |
| - name: Build WASM (nodejs target) | |
| run: pnpm --filter @veaba/qrcode-wasm exec npm run build:node | |
| - name: Build WASM (bundler target) | |
| run: pnpm --filter @veaba/qrcode-wasm exec npm run build:bundler | |
| # ======================================== | |
| # Type Check | |
| # ======================================== | |
| type-check: | |
| name: TypeScript Type Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'pnpm' | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: '1.3.0' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile --ignore-scripts | |
| - name: Build qrcode-js-shared | |
| run: pnpm --filter @veaba/qrcode-js-shared build | |
| - name: Build qrcode-wasm | |
| run: pnpm --filter @veaba/qrcode-wasm build | |
| - name: Type check all packages | |
| run: | | |
| pnpm --filter @veaba/qrcode-js-shared exec tsc --noEmit | |
| pnpm --filter @veaba/qrcode-js exec tsc --noEmit | |
| pnpm --filter @veaba/qrcode-node exec tsc --noEmit | |
| pnpm --filter @veaba/qrcode-bun exec tsc --noEmit | |
| pnpm --filter @veaba/qrcode-wasm exec tsc --noEmit | |
| # ======================================== | |
| # Security Audit | |
| # ======================================== | |
| security: | |
| name: Security Audit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'pnpm' | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: '1.3.0' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile --ignore-scripts | |
| - name: Run npm audit | |
| run: pnpm audit --audit-level moderate | |
| continue-on-error: true | |
| - name: Install cargo-audit | |
| run: cargo install cargo-audit | |
| - name: Run cargo audit | |
| run: cargo audit | |
| continue-on-error: true | |
| # ======================================== | |
| # Lint Check | |
| # ======================================== | |
| lint: | |
| name: Lint Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'pnpm' | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: '1.3.0' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile --ignore-scripts | |
| - name: Run cargo clippy | |
| run: cargo clippy --workspace --all-targets -- -D warnings | |
| - name: Check Rust formatting | |
| run: cargo fmt --all -- --check | |
| # ======================================== | |
| # Build Verification | |
| # ======================================== | |
| build: | |
| name: Build All Packages | |
| runs-on: ubuntu-latest | |
| needs: [test-ts, test-rust, test-wasm-build] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'pnpm' | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: '1.3.0' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build all packages | |
| run: | | |
| pnpm --filter @veaba/qrcode-js-shared build | |
| pnpm --filter @veaba/qrcode-js build | |
| pnpm --filter @veaba/qrcode-node build | |
| # pnpm --filter @veaba/qrcode-bun build (no build step) | |
| pnpm --filter @veaba/qrcode-wasm build | |
| - name: Verify build artifacts | |
| run: | | |
| test -f packages/qrcode-js-shared/dist/index.js | |
| test -f packages/qrcode-js/dist/index.js | |
| test -f packages/qrcode-node/dist/index.js | |
| # qrcode-bun uses TypeScript source directly (no build step) | |
| test -f packages/qrcode-wasm/dist/index.js | |
| test -f packages/qrcode-wasm/pkg/qrcodes_bg.wasm |