Add GitHub Action to summarize new issues (#4) #83
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: Rust Build and Test | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| jobs: | |
| build-and-test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| rust-version: ["stable"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: ${{ matrix.rust-version }} | |
| components: rustfmt, clippy | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-registry- | |
| - name: Cache cargo index | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-git- | |
| - name: Cache cargo build | |
| uses: actions/cache@v4 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-build- | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Run clippy | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| - name: Build workspace | |
| run: cargo build --release --workspace | |
| - name: Run tests | |
| run: cargo test --workspace --verbose | |
| - name: Run integration tests | |
| run: | | |
| cargo test --package hypnoscript-lexer-parser --verbose | |
| cargo test --package hypnoscript-compiler --verbose | |
| cargo test --package hypnoscript-runtime --verbose | |
| - name: Build CLI binary | |
| run: cargo build --release --package hypnoscript-cli | |
| - name: Test CLI functionality (Unix) | |
| if: runner.os != 'Windows' | |
| run: | | |
| ./target/release/hypnoscript version | |
| ./target/release/hypnoscript builtins | |
| ./target/release/hypnoscript lex hypnoscript-tests/test_rust_demo.hyp | |
| ./target/release/hypnoscript parse hypnoscript-tests/test_rust_demo.hyp | |
| ./target/release/hypnoscript check hypnoscript-tests/test_rust_demo.hyp | |
| ./target/release/hypnoscript exec hypnoscript-tests/test_rust_demo.hyp | |
| - name: Test CLI functionality (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| .\target\release\hypnoscript.exe version | |
| .\target\release\hypnoscript.exe builtins | |
| .\target\release\hypnoscript.exe lex hypnoscript-tests\test_rust_demo.hyp | |
| .\target\release\hypnoscript.exe parse hypnoscript-tests\test_rust_demo.hyp | |
| .\target\release\hypnoscript.exe check hypnoscript-tests\test_rust_demo.hyp | |
| .\target\release\hypnoscript.exe exec hypnoscript-tests\test_rust_demo.hyp | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.os }} | |
| path: | | |
| target/debug/ | |
| **/test-results.xml | |
| - name: Upload CLI binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hypnoscript-cli-${{ matrix.os }} | |
| path: | | |
| target/release/hypnoscript | |
| target/release/hypnoscript.exe | |
| target/release/hyp | |
| target/release/hyp.exe | |
| code-quality: | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: read | |
| security-events: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| components: rustfmt, clippy | |
| - name: Install CodeQL | |
| uses: github/codeql-action/init@v4 | |
| with: | |
| languages: rust | |
| - name: Build for CodeQL | |
| run: cargo build --release --workspace | |
| - name: Perform CodeQL Analysis | |
| uses: github/codeql-action/analyze@v4 | |
| - name: Run security audit | |
| run: | | |
| cargo install cargo-audit | |
| cargo audit | |
| - name: Check for unsafe code | |
| run: | | |
| if git grep -n "unsafe" -- '*.rs'; then | |
| echo "Warning: Found unsafe code blocks" | |
| else | |
| echo "No unsafe code detected" | |
| fi | |
| - name: Run cargo deny | |
| run: | | |
| cargo install cargo-deny | |
| cargo deny check | |
| performance: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| - name: Build release | |
| run: cargo build --release --workspace | |
| - name: Run benchmark tests | |
| run: | | |
| cargo test --release --package hypnoscript-runtime -- --ignored --nocapture | |
| - name: Generate performance report | |
| run: | | |
| ./target/release/hypnoscript exec hypnoscript-tests/test_rust_demo.hyp --verbose | |
| time ./target/release/hypnoscript exec hypnoscript-tests/test_rust_demo.hyp | |
| - name: Upload performance results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: performance-results | |
| path: | | |
| target/release/ | |
| **/benchmark-results/ | |
| coverage: | |
| runs-on: ubuntu-latest | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| components: llvm-tools-preview | |
| - name: Install cargo-llvm-cov | |
| run: cargo install cargo-llvm-cov | |
| - name: Generate coverage | |
| run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info | |
| - name: Upload coverage to Codecov | |
| if: env.CODECOV_TOKEN != '' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: lcov.info | |
| fail_ci_if_error: true | |
| token: ${{ env.CODECOV_TOKEN }} | |
| - name: Skip Codecov upload (token missing) | |
| if: env.CODECOV_TOKEN == '' | |
| run: | | |
| echo "::warning::CODECOV_TOKEN secret not set; skipping Codecov upload." | |
| deployment: | |
| needs: [build-and-test, code-quality, performance] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| - name: Build for release | |
| run: cargo build --release --workspace | |
| - name: Create release package | |
| run: | | |
| mkdir -p release | |
| cp target/release/hypnoscript release/ | |
| cp target/release/hyp release/ | |
| cp README.md release/ | |
| cp RUST_README.md release/ || true | |
| cp LICENSE release/ || true | |
| tar -czf hypnoscript-rust-release.tar.gz -C release . | |
| - name: Upload release artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rust-release-package | |
| path: hypnoscript-rust-release.tar.gz |