|
| 1 | +name: xLLM Build x86_64 CUDA |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + paths-ignore: |
| 8 | + - '.github/**' |
| 9 | + - 'cibuild/**' |
| 10 | + - 'cmake/**' |
| 11 | + - 'docs/**' |
| 12 | + - 'third_party/**' |
| 13 | + - 'tools/**' |
| 14 | + - '*.md' |
| 15 | + - '*.txt' |
| 16 | + - '*.yml' |
| 17 | + pull_request: |
| 18 | + branches: [main] |
| 19 | + types: [opened, synchronize, reopened] |
| 20 | + paths-ignore: |
| 21 | + - 'cmake/**' |
| 22 | + - 'docs/**' |
| 23 | + - 'third_party/**' |
| 24 | + - 'tools/**' |
| 25 | + - '*.md' |
| 26 | + - '*.txt' |
| 27 | + - '*.yml' |
| 28 | + pull_request_review: |
| 29 | + types: [submitted] |
| 30 | + paths: |
| 31 | + - '.github/**.yaml' |
| 32 | + - 'cibuild/**.sh' |
| 33 | + - 'setup.py' |
| 34 | + - 'examples/generate.py' |
| 35 | + |
| 36 | +env: |
| 37 | + JOBNAME: xllm-x86_64-cuda-cibuild-${{ github.run_id }} |
| 38 | + |
| 39 | +concurrency: |
| 40 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 41 | + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} |
| 42 | + |
| 43 | +jobs: |
| 44 | + # need to review code first when sensitive files are modified. |
| 45 | + check-sensitive: |
| 46 | + runs-on: [self-hosted] |
| 47 | + outputs: |
| 48 | + requires_approval: ${{ steps.check_sensitive.outputs.requires_approval }} |
| 49 | + do_build: ${{ steps.decide.outputs.do_build }} |
| 50 | + steps: |
| 51 | + - name: Checkout Code |
| 52 | + uses: actions/checkout@v4 |
| 53 | + with: |
| 54 | + fetch-depth: 0 # Ensure we can compare commits |
| 55 | + |
| 56 | + - name: Install jq |
| 57 | + run: yum install -y jq |
| 58 | + |
| 59 | + - name: Check if sensitive files were changed |
| 60 | + id: check_sensitive |
| 61 | + run: | |
| 62 | + sensitive_files=( |
| 63 | + ".github/**.yaml" |
| 64 | + "cibuild/**.sh" |
| 65 | + "setup.py" |
| 66 | + ) |
| 67 | + changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) |
| 68 | + requires_approval="false" |
| 69 | + while IFS= read -r changed_file; do |
| 70 | + [[ -z "$changed_file" ]] && continue |
| 71 | + for pattern in "${sensitive_files[@]}"; do |
| 72 | + if [[ "$changed_file" == $pattern ]]; then |
| 73 | + requires_approval="true" |
| 74 | + break 2 |
| 75 | + fi |
| 76 | + done |
| 77 | + done < <(git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}") |
| 78 | + echo "requires_approval=$requires_approval" >> $GITHUB_OUTPUT |
| 79 | +
|
| 80 | + - name: Decide whether to check build |
| 81 | + id: decide |
| 82 | + run: | |
| 83 | + event="${{ github.event_name }}" |
| 84 | + if [[ "$event" == "workflow_dispatch" || "$event" == "push" ]]; then |
| 85 | + echo "do_build=true" >> $GITHUB_OUTPUT |
| 86 | + elif [[ "$event" == "pull_request" ]]; then |
| 87 | + if [ "${{ steps.check_sensitive.outputs.requires_approval }}" == "true" ]; then |
| 88 | + echo "do_build=false" >> $GITHUB_OUTPUT |
| 89 | + else |
| 90 | + echo "do_build=true" >> $GITHUB_OUTPUT |
| 91 | + fi |
| 92 | + elif [[ "$event" == "pull_request_review" ]]; then |
| 93 | + # Since pull_request_review now only triggers when sensitive files are modified, |
| 94 | + # we only need to check if the review is approved |
| 95 | + if [[ "${{ github.event.review.state }}" == "approved" ]]; then |
| 96 | + echo "do_build=true" >> $GITHUB_OUTPUT |
| 97 | + else |
| 98 | + echo "do_build=false" >> $GITHUB_OUTPUT |
| 99 | + fi |
| 100 | + else |
| 101 | + echo "do_build=false" >> $GITHUB_OUTPUT |
| 102 | + fi |
| 103 | +
|
| 104 | + build: |
| 105 | + needs: check-sensitive |
| 106 | + if: > |
| 107 | + (github.event_name == 'workflow_dispatch' || github.event_name == 'push') || |
| 108 | + needs.check-sensitive.outputs.do_build == 'true' |
| 109 | + runs-on: [self-hosted] |
| 110 | + steps: |
| 111 | + - name: Checkout Code |
| 112 | + timeout-minutes: 5 |
| 113 | + uses: actions/checkout@v4 |
| 114 | + with: |
| 115 | + submodules: true |
| 116 | + |
| 117 | + - name: Build |
| 118 | + if: ${{ success() }} |
| 119 | + timeout-minutes: 60 |
| 120 | + run: | |
| 121 | + chmod +x ./cibuild/build_cuda.sh |
| 122 | + bash cibuild/build_cuda.sh 'pip install pre-commit -i https://pypi.tuna.tsinghua.edu.cn/simple; python setup.py build --device cuda' |
0 commit comments