Add shuriken process #899
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: | |
| branches: | |
| - main | |
| - dev | |
| pull_request: | |
| jobs: | |
| static-analysis: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: ruff check | |
| run: uv run --extra dev ruff check --output-format=github || true | |
| - name: ruff format | |
| run: uv run --extra dev ruff format --check | |
| - name: pylint | |
| run: uv run --extra dev --extra penzai pylint simplexity tests | |
| - name: pyright | |
| run: uv run --extra aws --extra dev --extra penzai pyright | |
| unit-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history needed for diff-cover | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Cache testmon database | |
| uses: actions/cache@v4 | |
| with: | |
| path: .testmondata* | |
| key: testmon-${{ runner.os }}-${{ github.head_ref || github.ref_name }}-${{ hashFiles('simplexity/**/*.py', 'tests/**/*.py') }} | |
| restore-keys: | | |
| testmon-${{ runner.os }}-${{ github.head_ref || github.ref_name }}- | |
| testmon-${{ runner.os }}-main- | |
| testmon-${{ runner.os }}- | |
| - name: Run tests with coverage | |
| run: | | |
| # PRs to main: Run all tests (diff-cover enforces 80% threshold, needs full coverage) | |
| # PRs to dev: Use --testmon to run only affected tests (diff-cover threshold is 0%) | |
| # Push to main/dev: Use --testmon-noselect to run all tests and update testmon database | |
| if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.pull_request.base.ref }}" = "main" ]; then | |
| TESTMON_FLAG="" | |
| echo "::notice::Running full test suite (PR to main - needed for diff-cover)" | |
| elif [ "${{ github.event_name }}" = "pull_request" ]; then | |
| TESTMON_FLAG="--testmon" | |
| echo "::notice::Running affected tests only (PR to dev)" | |
| else | |
| TESTMON_FLAG="--testmon-noselect" | |
| echo "::notice::Running full test suite (push - updating testmon database)" | |
| fi | |
| # Exclude end-to-end tests - they run in a separate workflow | |
| uv run --extra aws --extra dev --extra cuda --extra penzai --extra pytorch pytest \ | |
| --capture=no \ | |
| --verbose \ | |
| --cov-fail-under=0 \ | |
| --ignore=tests/end_to_end \ | |
| $TESTMON_FLAG | |
| # Verify coverage.xml was generated (required for diff-cover and Codecov) | |
| # This is ensured by --cov-report=xml in pyproject.toml, but we verify for clarity | |
| if [ ! -f coverage.xml ]; then | |
| echo "::error::coverage.xml not found - coverage reporting may have failed" | |
| exit 1 | |
| fi | |
| - name: Upload coverage artifact for coverage-check job | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| # Get the base branch (usually main) | |
| BASE_BRANCH="${{ github.event.pull_request.base.ref }}" | |
| echo "Checking coverage for new code against base branch: ${BASE_BRANCH}" | |
| # Determine threshold based on branch | |
| if [ "$BASE_BRANCH" = "main" ]; then | |
| FAIL_UNDER=80 | |
| echo "::notice::Enforcing 80% coverage threshold for main branch" | |
| else | |
| FAIL_UNDER=0 | |
| echo "::notice::Skipping coverage enforcement for non-main branch (monitoring only)" | |
| fi | |
| # Run diff-cover to check only new/changed code | |
| # Note: diff-cover only needs --extra dev (tests need all extras for integration testing) | |
| if uv run --extra dev diff-cover coverage.xml \ | |
| --compare-branch=origin/${BASE_BRANCH} \ | |
| --fail-under=$FAIL_UNDER \ | |
| --markdown-report diff-coverage-report.md; then | |
| echo "::notice::New code coverage check passed" | |
| else | |
| echo "::error::New code coverage is below $FAIL_UNDER% threshold" | |
| exit 1 | |
| fi | |
| continue-on-error: false | |
| - name: Upload diff coverage report | |
| if: github.event_name == 'pull_request' && always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-xml | |
| path: coverage.xml | |
| retention-days: 1 | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| slug: Astera-org/simplexity | |
| verbose: true | |
| files: ./coverage.xml | |
| fail_ci_if_error: false |