Skip to content

Commit 35f3ce7

Browse files
committed
cicd: add cicd for cuda device.
1 parent 49be0a6 commit 35f3ce7

File tree

17 files changed

+5759
-253
lines changed

17 files changed

+5759
-253
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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'

.github/workflows/build_x86_64_mlu.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ jobs:
119119
timeout-minutes: 60
120120
run: |
121121
chmod +x ./cibuild/build_mlu.sh
122-
bash cibuild/build_mlu.sh 'pip install pre-commit -i https://pypi.tuna.tsinghua.edu.cn/simple; VCPKG_ROOT=/export/home/mlu_vcpkg_src python setup.py build --device mlu'
122+
bash cibuild/build_mlu.sh 'pip install pre-commit -i https://pypi.tuna.tsinghua.edu.cn/simple; python setup.py build --device mlu'

cibuild/build_cuda.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
set -e
3+
4+
function error() {
5+
echo "Require build command, e.g. python setup.py build --device cuda"
6+
exit 1
7+
}
8+
9+
IMAGE="quay.io/jd_xllm/xllm-ai:xllm-dev-cuda-x86"
10+
11+
RUN_OPTS=(
12+
--rm
13+
-t
14+
--privileged
15+
--ipc=host
16+
--network=host
17+
--pid=host
18+
--shm-size '128gb'
19+
-v /export/home:/export/home
20+
-v /export/home/mlu_vcpkg_cache:/root/.cache/vcpkg # cuda and mlu vcpkg cache is same
21+
-w /export/home
22+
)
23+
24+
CMD="$*"
25+
[[ -z "${CMD}" ]] && error
26+
27+
[[ ! -x $(command -v docker) ]] && echo "ERROR: 'docker' command is missing." && exit 1
28+
29+
docker run "${RUN_OPTS[@]}" "${IMAGE}" bash -c "set -euo pipefail; cd $(pwd); ${CMD}"

cibuild/build_mlu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
function error() {
5-
echo "Require build command, e.g. python setup.py build"
5+
echo "Require build command, e.g. python setup.py build --device mlu"
66
exit 1
77
}
88

cibuild/build_npu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
function error() {
5-
echo "Require build command, e.g. python setup.py build"
5+
echo "Require build command, e.g. python setup.py build --device a2"
66
exit 1
77
}
88

cibuild/install/install_base.sh

Lines changed: 0 additions & 60 deletions
This file was deleted.

cibuild/install/install_ccache.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

cibuild/install/install_cmake.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

cibuild/install/install_gcc.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

cibuild/install/install_ninja.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)