fix(generator): use method syntax for namespace functions #55
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, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| test: | |
| name: Test Suite | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| rust: [stable, beta] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ matrix.rust }} | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ matrix.os }}-${{ matrix.rust }}-cargo- | |
| - name: Run unit tests | |
| run: cargo test --lib --verbose | |
| - name: Run integration tests | |
| run: cargo test --test integration_tests --verbose | |
| - name: Run CLI tests | |
| run: cargo test --test cli_tests --verbose | |
| - name: Run edge case tests | |
| run: cargo test --test edge_cases --verbose | |
| - name: Run doc tests | |
| run: cargo test --doc --verbose | |
| stress-tests: | |
| name: Stress Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ubuntu-latest-stable-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ubuntu-latest-stable-cargo- | |
| - name: Run stress tests | |
| run: cargo test --test stress_tests --verbose -- --ignored --test-threads=1 | |
| timeout-minutes: 30 | |
| benchmarks: | |
| name: Performance Benchmarks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ubuntu-latest-stable-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ubuntu-latest-stable-cargo- | |
| - name: Run benchmarks | |
| run: cargo bench --verbose -- --output-format bencher | tee benchmark-results.txt | |
| - name: Check performance regression | |
| shell: bash | |
| run: | | |
| # Extract complete_build/1000_translations time | |
| if grep -q "complete_build/1000_translations" benchmark-results.txt; then | |
| BUILD_TIME=$(grep "complete_build/1000_translations" benchmark-results.txt | awk '{print $5}' | sed 's/ms//' || echo "0") | |
| echo "Build time for 1K translations: ${BUILD_TIME}ms" | |
| # Check if build time exceeds 200ms (target) | |
| if command -v bc &> /dev/null; then | |
| if (( $(echo "$BUILD_TIME > 200" | bc -l) )); then | |
| echo "::warning::Build time ${BUILD_TIME}ms exceeds target of 200ms" | |
| else | |
| echo "✓ Build time ${BUILD_TIME}ms is within target" | |
| fi | |
| else | |
| echo "::notice::bc not available, skipping performance check" | |
| fi | |
| else | |
| echo "::warning::Benchmark results not found in expected format" | |
| fi | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results | |
| path: benchmark-results.txt | |
| lint: | |
| name: Linting | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ubuntu-latest-stable-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ubuntu-latest-stable-cargo- | |
| - name: Run cargo fmt | |
| run: cargo fmt --all | |
| - name: Check for formatting changes | |
| id: fmt-check | |
| run: | | |
| if [[ -n $(git status --porcelain) ]]; then | |
| echo "changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit formatting changes | |
| if: steps.fmt-check.outputs.changes == 'true' && github.event_name == 'push' | |
| 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 commit -m "style: apply cargo fmt [skip ci]" | |
| git push | |
| - name: Fail if formatting needed on PR | |
| if: steps.fmt-check.outputs.changes == 'true' && github.event_name == 'pull_request' | |
| run: | | |
| echo "::error::Code is not formatted. Please run 'cargo fmt' locally and commit the changes." | |
| exit 1 | |
| - name: Run clippy | |
| run: cargo clippy --all-targets -- -D warnings | |
| security: | |
| name: Security Audit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install cargo-audit | |
| run: cargo install cargo-audit | |
| - name: Run security audit | |
| run: cargo audit | |
| coverage: | |
| name: Test Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ubuntu-latest-stable-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ubuntu-latest-stable-cargo- | |
| - name: Install cargo-tarpaulin | |
| run: cargo install cargo-tarpaulin | |
| - name: Generate coverage report | |
| run: cargo tarpaulin --verbose --all-features --workspace --timeout 300 --out xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./cobertura.xml | |
| fail_ci_if_error: false | |
| verbose: true | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| build: | |
| name: Build Release | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ matrix.os }}-stable-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ matrix.os }}-stable-cargo- | |
| - name: Build release binary | |
| run: cargo build --release --locked --verbose | |
| - name: Check binary size (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| SIZE=$(ls -lh target/release/roblox-slang | awk '{print $5}') | |
| echo "Binary size: $SIZE" | |
| SIZE_BYTES=$(stat -f%z target/release/roblox-slang 2>/dev/null || stat -c%s target/release/roblox-slang) | |
| if [ $SIZE_BYTES -gt 5242880 ]; then | |
| echo "::warning::Binary size exceeds 5MB target" | |
| else | |
| echo "✓ Binary size is within 5MB target" | |
| fi | |
| - name: Check binary size (Windows) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: | | |
| $size = (Get-Item target/release/roblox-slang.exe).Length | |
| $sizeMB = [math]::Round($size / 1MB, 2) | |
| Write-Host "Binary size: $sizeMB MB" | |
| if ($size -gt 5242880) { | |
| Write-Host "::warning::Binary size exceeds 5MB target" | |
| } else { | |
| Write-Host "✓ Binary size is within 5MB target" | |
| } | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: roblox-slang-${{ matrix.os }} | |
| path: | | |
| target/release/roblox-slang | |
| target/release/roblox-slang.exe |