|  | 
| 1 | 1 | name: CI | 
| 2 |  | - | 
| 3 | 2 | on: [pull_request] | 
| 4 | 3 | 
 | 
|  | 4 | +env: | 
|  | 5 | +  PYTHON_VERSION: '3.12' | 
|  | 6 | +  VENV_DIR: tilelang_ci | 
|  | 7 | + | 
| 5 | 8 | jobs: | 
| 6 | 9 |   format-check: | 
| 7 | 10 |     runs-on: self-hosted | 
| 8 | 11 | 
 | 
|  | 12 | +    permissions: | 
|  | 13 | +      contents: write  | 
|  | 14 | + | 
| 9 | 15 |     steps: | 
| 10 | 16 |     - name: Checkout repository | 
| 11 |  | -      uses: actions/checkout@v2 | 
|  | 17 | +      uses: actions/checkout@v4 | 
| 12 | 18 |       with: | 
| 13 | 19 |         fetch-depth: 0 | 
| 14 | 20 | 
 | 
| 15 | 21 |     - name: Set up Python | 
| 16 | 22 |       uses: actions/setup-python@v2 | 
| 17 | 23 |       with: | 
| 18 |  | -        python-version: '3.9' | 
|  | 24 | +        python-version: ${{ env.PYTHON_VERSION }} | 
| 19 | 25 | 
 | 
| 20 |  | -    - name: Create virtual environment | 
| 21 |  | -      run: python -m venv tilelang_ci | 
| 22 |  | - | 
| 23 |  | -    - name: Activate virtual environment and install dependencies | 
|  | 26 | +    - name: Ensure venv (local & persistent) | 
| 24 | 27 |       run: | | 
| 25 |  | -        source tilelang_ci/bin/activate | 
| 26 |  | -        python -m pip install --upgrade pip | 
| 27 |  | -        if [ -f requirements-dev.txt ]; then python -m pip install -r requirements-dev.txt; fi | 
| 28 |  | -
 | 
| 29 |  | -    - name: Update submodules recursively | 
| 30 |  | -      run: git submodule update --init --recursive | 
|  | 28 | +        set -e | 
|  | 29 | +        REQS_HASH=$(cat requirements-test.txt 2>/dev/null || true) | 
|  | 30 | +        MARKER="${{ runner.tool_cache }}/.venv_marker_${{ env.PYTHON_VERSION }}_${REQS_HASH:0:8}" | 
|  | 31 | +
 | 
|  | 32 | +        if [[ -f "$MARKER" ]] && [[ -f "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" ]]; then | 
|  | 33 | +          echo "venv exists and hash matches – reuse it" | 
|  | 34 | +        else | 
|  | 35 | +          echo "venv stale or missing – recreating" | 
|  | 36 | +          rm -rf "${{ runner.tool_cache }}/${{ env.VENV_DIR }}" "$MARKER" | 
|  | 37 | +          python -m venv "${{ runner.tool_cache }}/${{ env.VENV_DIR }}" | 
|  | 38 | +          # shellcheck source=/dev/null | 
|  | 39 | +          source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
|  | 40 | +          python -m pip install --upgrade pip --no-user | 
|  | 41 | +          [[ -f requirements-test.txt ]] && \ | 
|  | 42 | +            PIP_NO_BUILD_ISOLATION=1 pip install -r requirements-test.txt --no-user | 
|  | 43 | +          touch "$MARKER" | 
|  | 44 | +        fi | 
| 31 | 45 | 
 | 
| 32 | 46 |     - name: Run format check | 
| 33 | 47 |       run: | | 
| 34 |  | -        source tilelang_ci/bin/activate | 
| 35 |  | -        ./format.sh | 
|  | 48 | +        source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
|  | 49 | +        if ! output=$(./format.sh 2>&1); then | 
|  | 50 | +          echo "------------------------------------" | 
|  | 51 | +          echo "message:" | 
|  | 52 | +          echo "$output" | 
|  | 53 | +          printf '%s\n' "$output" | grep "Please review and stage the changes." | 
|  | 54 | +          echo "------------------------------------" | 
|  | 55 | +          exit 1 | 
|  | 56 | +        fi | 
|  | 57 | +     | 
|  | 58 | +    - name: Commit and Push Changes | 
|  | 59 | +      uses: stefanzweifel/git-auto-commit-action@v5 | 
|  | 60 | +      with: | 
|  | 61 | +        commit_message: "lint" | 
| 36 | 62 | 
 | 
| 37 | 63 |   build-test: | 
| 38 | 64 |     runs-on: self-hosted | 
| 39 | 65 |     needs: format-check | 
| 40 |  | - | 
|  | 66 | +    permissions: | 
|  | 67 | +      contents: read | 
| 41 | 68 |     steps: | 
| 42 | 69 |     - name: Checkout repository | 
| 43 |  | -      uses: actions/checkout@v2 | 
|  | 70 | +      uses: actions/checkout@v4 | 
| 44 | 71 |       with: | 
| 45 | 72 |         fetch-depth: 0 | 
|  | 73 | +        repository: ${{ github.event.pull_request.head.repo.full_name }} | 
|  | 74 | +        ref: ${{ github.event.pull_request.head.ref }} | 
| 46 | 75 | 
 | 
| 47 | 76 |     - name: Set up Python | 
| 48 | 77 |       uses: actions/setup-python@v2 | 
| 49 | 78 |       with: | 
| 50 |  | -        python-version: '3.9' | 
|  | 79 | +        python-version: ${{ env.PYTHON_VERSION }} | 
| 51 | 80 | 
 | 
| 52 |  | -    - name: Create virtual environment | 
| 53 |  | -      run: python -m venv tilelang_ci | 
| 54 |  | - | 
| 55 |  | -    - name: Activate virtual environment and install dependencies | 
|  | 81 | +    - name: Ensure venv (local & persistent) | 
| 56 | 82 |       run: | | 
| 57 |  | -        source tilelang_ci/bin/activate | 
| 58 |  | -        python -m pip install --upgrade pip | 
| 59 |  | -        if [ -f requirements-test.txt ]; then PIP_NO_BUILD_ISOLATION=1 python -m pip install -r requirements-test.txt; fi | 
| 60 |  | -
 | 
| 61 |  | -    - name: Install project in wheel mode | 
|  | 83 | +        set -e | 
|  | 84 | +        REQS_HASH=$(cat requirements-test.txt 2>/dev/null || true) | 
|  | 85 | +        MARKER="${{ runner.tool_cache }}/.venv_marker_${{ env.PYTHON_VERSION }}_${REQS_HASH:0:8}" | 
|  | 86 | +
 | 
|  | 87 | +        if [[ -f "$MARKER" ]] && [[ -f "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" ]]; then | 
|  | 88 | +          echo "venv exists and hash matches – reuse it" | 
|  | 89 | +        else | 
|  | 90 | +          echo "venv stale or missing – recreating" | 
|  | 91 | +          rm -rf "${{ runner.tool_cache }}/${{ env.VENV_DIR }}" "$MARKER" | 
|  | 92 | +          python -m venv "${{ runner.tool_cache }}/${{ env.VENV_DIR }}" | 
|  | 93 | +          source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
|  | 94 | +          python -m pip install --upgrade pip --no-user | 
|  | 95 | +          [[ -f requirements-test.txt ]] && \ | 
|  | 96 | +            PIP_NO_BUILD_ISOLATION=1 pip install -r requirements-test.txt --no-user | 
|  | 97 | +          pip install . --no-user | 
|  | 98 | +          touch "$MARKER" | 
|  | 99 | +        fi | 
|  | 100 | +
 | 
|  | 101 | +    - name: Install project (wheel form) | 
| 62 | 102 |       run: | | 
| 63 |  | -        source tilelang_ci/bin/activate | 
| 64 |  | -        python -m pip install . | 
|  | 103 | +        source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
|  | 104 | +        pip install . --no-user | 
| 65 | 105 | 
 | 
| 66 | 106 |     - name: Run examples | 
| 67 | 107 |       run: | | 
| 68 |  | -        source tilelang_ci/bin/activate | 
|  | 108 | +        source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
| 69 | 109 |         cd examples | 
| 70 |  | -        python -m pytest **/test*.py | 
|  | 110 | +        unset PYTHONPATH | 
|  | 111 | +        python -m pytest -n 8 **/test*.py | 
| 71 | 112 | 
 | 
| 72 | 113 |     - name: Run tests | 
| 73 | 114 |       run: | | 
| 74 |  | -        source tilelang_ci/bin/activate | 
|  | 115 | +        source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
| 75 | 116 |         cd testing/python | 
| 76 |  | -        python -m pytest | 
|  | 117 | +        unset PYTHONPATH | 
|  | 118 | +        python -m pytest -n 8 | 
0 commit comments