|
| 1 | +name: 'Pull Request Gate' |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ "dev*", "main", "*release", "feature*" ] |
| 6 | + |
| 7 | +jobs: |
| 8 | + # protect the workflows dir, only allow specific users to modify |
| 9 | + protect-workflows-dir: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + allowed: ${{ steps.check.outputs.allowed }} |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + |
| 18 | + - id: check |
| 19 | + env: |
| 20 | + ACTOR: ${{ github.actor }} |
| 21 | + run: | |
| 22 | + # get the target branch contents |
| 23 | + git fetch origin ${{ github.base_ref }} |
| 24 | +
|
| 25 | + CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) |
| 26 | + echo "CHANGED_FILES=$CHANGED_FILES" |
| 27 | +
|
| 28 | + if ! echo "$CHANGED_FILES" | grep -q '^\.github/workflows/'; then |
| 29 | + echo "No .github/workflows changes, allow." |
| 30 | + echo "allowed=true" >> $GITHUB_OUTPUT |
| 31 | + exit 0 |
| 32 | + fi |
| 33 | +
|
| 34 | + ALLOWED_USERS=("dante159753" "mag1c-h") |
| 35 | + |
| 36 | + echo ".github changes detected, check if user is allowed..." |
| 37 | + ACTOR="${{ github.actor }}" |
| 38 | + echo "PR author: $ACTOR" |
| 39 | +
|
| 40 | + for u in "${ALLOWED_USERS[@]}"; do |
| 41 | + if [[ "$ACTOR" == "$u" ]]; then |
| 42 | + echo "Authorized user, allowing change." |
| 43 | + echo "allowed=true" >> $GITHUB_OUTPUT |
| 44 | + exit 0 |
| 45 | + fi |
| 46 | + done |
| 47 | +
|
| 48 | + echo "ERROR: Only privileged users may modify .github/workflows/" |
| 49 | + echo "allowed=false" >> $GITHUB_OUTPUT |
| 50 | + exit 1 |
| 51 | +
|
| 52 | + lint-and-unit-tests: |
| 53 | + needs: protect-workflows-dir |
| 54 | + if: needs.protect-workflows-dir.outputs.allowed == 'true' |
| 55 | + uses: ./.github/workflows/lint-and-test.yml |
| 56 | + |
| 57 | + test-e2e-pc-gpu: |
| 58 | + runs-on: gpu |
| 59 | + needs: lint-and-unit-tests |
| 60 | + env: |
| 61 | + BUILD_TYPE: Release |
| 62 | + permissions: |
| 63 | + checks: write |
| 64 | + pull-requests: write |
| 65 | + steps: |
| 66 | + - name: Clean repo |
| 67 | + run: | |
| 68 | + if [ -d "${{github.workspace}}" ]; then |
| 69 | + cd ${{github.workspace}} |
| 70 | + rm -rf ./* |
| 71 | + rm -rf .[!.]* |
| 72 | + fi |
| 73 | + - uses: actions/checkout@v4 |
| 74 | + - name: Build |
| 75 | + run: | |
| 76 | + cd ${{github.workspace}} |
| 77 | + export PLATFORM=cuda |
| 78 | + pip install -v -e . --no-build-isolation |
| 79 | + - name: Test E2E |
| 80 | + run: | |
| 81 | + cd ${{github.workspace}} |
| 82 | + cd test |
| 83 | + pip install pytest pytest-cov pynvml pandas |
| 84 | + python3 -m pytest --stage=1 --feature=offline_inference --junitxml=offline-inference.xml |
| 85 | + - name: Upload pytest results |
| 86 | + uses: EnricoMi/publish-unit-test-result-action/linux@v2 |
| 87 | + if: (!cancelled()) |
| 88 | + with: |
| 89 | + files: | |
| 90 | + ${{github.workspace}}/test/offline-inference.xml |
| 91 | + check_name: Prefix cache test results |
| 92 | + |
| 93 | + test-e2e-sparse-gpu: |
| 94 | + runs-on: gpu |
| 95 | + needs: lint-and-unit-tests |
| 96 | + env: |
| 97 | + BUILD_TYPE: Release |
| 98 | + permissions: |
| 99 | + checks: write |
| 100 | + pull-requests: write |
| 101 | + steps: |
| 102 | + - name: Clean repo |
| 103 | + run: | |
| 104 | + if [ -d "${{github.workspace}}" ]; then |
| 105 | + cd ${{github.workspace}} |
| 106 | + rm -rf ./* |
| 107 | + rm -rf .[!.]* |
| 108 | + fi |
| 109 | + - uses: actions/checkout@v4 |
| 110 | + - name: Build |
| 111 | + run: | |
| 112 | + cd ${{github.workspace}} |
| 113 | + export PLATFORM=cuda |
| 114 | + export ENABLE_SPARSE=TRUE |
| 115 | + pip install -v -e . --no-build-isolation |
| 116 | + - name: Test E2E |
| 117 | + run: | |
| 118 | + cd ${{github.workspace}} |
| 119 | + cd test |
| 120 | + pip install pytest pytest-cov pynvml pandas |
| 121 | + python3 -m pytest --stage=1 --feature=offline_inference_sparse --junitxml=offline-inference-sparse.xml |
| 122 | + - name: Upload pytest results |
| 123 | + uses: EnricoMi/publish-unit-test-result-action/linux@v2 |
| 124 | + if: (!cancelled()) |
| 125 | + with: |
| 126 | + files: | |
| 127 | + ${{github.workspace}}/test/offline-inference-sparse.xml |
| 128 | + check_name: Sparse attention test results |
| 129 | + |
0 commit comments