Skip to content

Commit 47bd13b

Browse files
committed
test pipeline
1 parent 47f2c16 commit 47bd13b

File tree

2 files changed

+92
-72
lines changed

2 files changed

+92
-72
lines changed

.github/workflows/main.yml

Lines changed: 65 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,54 @@
1-
name: DLCompiler main test ci
1+
name: Release on Tag
22

33
on:
4-
workflow_dispatch:
54
push:
6-
branches:
7-
- main
8-
pull_request:
9-
branches:
10-
- main
5+
tags:
6+
- "v*.*.*" # 只对形如 v1.2.3 的 tag 触发
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0 # 获取完整 git 历史,便于 setuptools_scm 等工具
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.10"
20+
21+
- name: Install build dependencies
22+
run: |
23+
pip install build twine
24+
25+
# 可选:如果使用 setuptools_scm 动态管理版本,需安装
26+
# - name: Install setuptools_scm
27+
# run: pip install setuptools_scm
28+
29+
- name: Build package
30+
run: python -m build
31+
32+
- name: Create Release and Upload Assets
33+
uses: softprops/action-gh-release@v2
34+
with:
35+
files: |
36+
dist/*.whl
37+
dist/*.tar.gz
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
1141

1242
env:
13-
CI_PATH: "${{ vars.CI_BASE_PATH }}/GitHub/${{ github.repository }}/${GITHUB_RUN_NUMBER}"
43+
RELEASE_PATH: "${{ vars.CI_BASE_PATH }}/GitHub/Release/${{ github.repository }}/${GITHUB_RUN_NUMBER}"
1444
THIRD_PARTY_PATH: "${{ vars.CI_BASE_PATH }}/data/DLCompiler/third_party"
1545

1646
concurrency:
1747
group: ${{ github.workflow }}-${{ github.ref }}
1848
cancel-in-progress: true
1949

2050
jobs:
21-
AscendTests:
51+
release:
2252
if: github.repository == 'DeepLink-org/DLCompiler'
2353
runs-on: DLC-60
2454

@@ -31,35 +61,39 @@ jobs:
3161
- name: Create custom directory
3262
run: |
3363
set -ex
34-
echo ${{ env.CI_PATH }}
35-
mkdir -p ${{ env.CI_PATH }}
64+
echo ${{ env.RELEASE_PATH }}
65+
mkdir -p ${{ env.RELEASE_PATH }}
3666
3767
- name: Clean custom directory
3868
run: |
3969
set -ex
40-
if [ -d "${{ env.CI_PATH }}" ]; then
41-
rm -rf ${{ env.CI_PATH }}/*
42-
rm -rf ${{ env.CI_PATH }}/.github
70+
if [ -d "${{ env.RELEASE_PATH }}" ]; then
71+
rm -rf ${{ env.RELEASE_PATH }}/*
72+
rm -rf ${{ env.RELEASE_PATH }}/.github
4373
fi
4474
4575
- name: Move code to custom directory
4676
run: |
4777
set -ex
48-
mv $GITHUB_WORKSPACE/* ${{ env.CI_PATH }}/
49-
mv $GITHUB_WORKSPACE/.github ${{ env.CI_PATH }}/
50-
mv $GITHUB_WORKSPACE/.git ${{ env.CI_PATH }}/
78+
mv $GITHUB_WORKSPACE/* ${{ env.RELEASE_PATH }}/
79+
mv $GITHUB_WORKSPACE/.github ${{ env.RELEASE_PATH }}/
80+
mv $GITHUB_WORKSPACE/.git ${{ env.RELEASE_PATH }}/
5181
5282
- name: Setup Git Safe Directory
5383
run: |
5484
git config --global --add safe.directory '*'
5585
86+
- name: Install build dependencies
87+
run: |
88+
pip install build twine -i https://mirrors.huaweicloud.com/repository/pypi/simple
89+
5690
- name: Build and install DLCompiler
5791
run: |
5892
set -ex
5993
source /home/dlc_ci/.bashrc
6094
source activate dlcompiler
6195
source /usr/local/Ascend/ascend-toolkit/set_env.sh
62-
cd ${{ env.CI_PATH }}
96+
cd ${{ env.RELEASE_PATH }}
6397
export JSON_PATH34=${{ vars.CI_BASE_PATH }}/data/v34/include.zip
6498
export GOOGLETEST_DIR34=${{ vars.CI_BASE_PATH }}/data/v34/googletest
6599
export LLVM_TGZ_PATH34=${{ vars.CI_BASE_PATH }}/data/v34/llvm-064f02da-ubuntu-arm64.tar.gz
@@ -74,20 +108,17 @@ jobs:
74108
git submodule update --init
75109
echo "git submodule update done."
76110
pip install nanobind -i https://mirrors.huaweicloud.com/repository/pypi/simple
77-
bash compile_shared.sh apply_patch=true
111+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
112+
bash compile_shared.sh apply_patch=true build_package=true
113+
fi
78114
79-
- name: Run tests on ascend
80-
run: |
81-
set -ex
82-
source /home/dlc_ci/.bashrc
83-
source activate dlcompiler
84-
source /usr/local/Ascend/ascend-toolkit/set_env.sh
85-
cd ${{env.CI_PATH }}
86-
echo "whoami? $(whoami)"
87-
echo "which python? $(which python)"
88-
export PATH=${{ vars.CI_BASE_PATH }}/data/bishengir_latest/:$PATH
89-
export ASCEND_RT_VISIBLE_DEVICES=7
90-
bash test/ascend/run_tests.sh
115+
- name: Create Release and Upload Assets
116+
uses: softprops/action-gh-release@v2
117+
with:
118+
files: |
119+
third_party/triton/dist/*.whl
120+
env:
121+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91122

92123
- name: Clear workfile
93124
if: always()
@@ -97,6 +128,6 @@ jobs:
97128
rm -rf $workdir
98129
mkdir $workdir
99130
chmod -R 777 $workdir
100-
if [ -d "${{ env.CI_PATH }}" ]; then
101-
rm -rf ${{ env.CI_PATH }}
102-
fi
131+
if [ -d "${{ env.RELEASE_PATH }}" ]; then
132+
rm -rf ${{ env.RELEASE_PATH }}
133+
fi

compile_shared.sh

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,25 @@ export LC_ALL="zh_CN.UTF-8"
44

55
home_path=$(pwd)
66
# compile triton shared library with patch
7-
compile_triton_shared=false
87
apply_patch=false
8+
build_package=false
99

1010
# 遍历所有参数
1111
for arg in "$@"; do
12-
if [ "$arg" = "compile_triton_shared=true" ]; then
13-
echo "检测到 compile_triton_shared=true"
14-
compile_triton_shared=true
15-
elif [ "$arg" = "apply_patch=true" ]; then
12+
if [ "$arg" = "apply_patch=true" ]; then
1613
echo "检测到 apply_patch=true"
1714
apply_patch=true
15+
elif [ "$arg" = "build_package=true" ]; then
16+
echo "检测到 build_package=true"
17+
build_package=true
1818
fi
1919
done
2020

2121

2222
echo "start compile ========================================"
23-
echo compile_triton_shared: $compile_triton_shared
2423
echo apply_patch: $apply_patch
2524
echo "======================================================"
2625

27-
if [[ $compile_triton_shared == true ]]; then
28-
echo "start compile triton_shared"
29-
cd third_party
30-
mkdir -p build && rm -rf build/*
31-
git clone --no-hardlinks triton_shared build/triton_shared
32-
git clone --no-hardlinks triton build/triton
33-
cd build
34-
export TRITON_PLUGIN_DIRS=$(pwd)/triton_shared
35-
cd triton_shared && git clean -xdf && git checkout . && git checkout 2b728ad97bc02af821a0805b09075838911d4c19 && ls ../../../patch/v3_4/triton_shared.patch | xargs -n1 git apply && cd ../
36-
cd triton && git clean -xdf && git checkout . && cd ../
37-
cd triton && git checkout $(cat ../triton_shared/triton-hash.txt) && ls ../../../patch/v3_4/triton.patch | xargs -n1 git apply
38-
TRITON_BUILD_WITH_CLANG_LLD=true TRITON_BUILD_WITH_CCACHE=true python3 -m pip install --no-build-isolation -vvv '.[tests]'
39-
if [ $? -ne 0 ]; then
40-
echo "Error: triton_shared compile failed." >&2
41-
exit 1
42-
fi
43-
echo "triton_shared compile success!"
44-
fi
45-
4626
echo "start apply ascendnpu-ir patch"
4727
cd $home_path/third_party/ascendnpu-ir
4828
git checkout .
@@ -97,22 +77,31 @@ notify_apply_patch() {
9777
fi
9878
}
9979

100-
pip uninstall triton dlcompiler -y
80+
if [[ $build_package == true ]]; then
81+
echo "build_package is true, skip uninstall triton dlcompiler"
82+
cd $TRITON_PLUGIN_DIRS/third_party/triton/
83+
else
84+
pip uninstall triton dlcompiler -y
10185

102-
cd $TRITON_PLUGIN_DIRS/third_party/triton/
103-
rm -rf build/
86+
cd $TRITON_PLUGIN_DIRS/third_party/triton/
87+
rm -rf build/
88+
fi
10489

10590
if [ -z "$LLVM_BUILD_DIR" ]; then
106-
TRITON_BUILD_WITH_CLANG_LLD=true TRITON_BUILD_WITH_CCACHE=true \
107-
python3 -m pip install --no-build-isolation -vvv .[tests] -i https://mirrors.huaweicloud.com/repository/pypi/simple
108-
if [ $? -ne 0 ]; then
109-
notify_apply_patch
110-
echo "Error: DLCompiler compile failed."
111-
exit 1
91+
# 使用build_package参数,控制是否进行编译
92+
if [[ $build_package == true ]]; then
93+
echo "LLVM_BUILD_DIR is not set, using system LLVM or downloading prebuilt LLVM build package."
94+
TRITON_BUILD_WITH_CLANG_LLD=true TRITON_BUILD_WITH_CCACHE=true \
95+
python3 -m pip wheel --no-deps --no-build-isolation -w dist/ .
96+
else
97+
TRITON_BUILD_WITH_CLANG_LLD=true TRITON_BUILD_WITH_CCACHE=true \
98+
python3 -m pip install --no-build-isolation -vvv .[tests] -i https://mirrors.huaweicloud.com/repository/pypi/simple
99+
if [ $? -ne 0 ]; then
100+
notify_apply_patch
101+
echo "Error: DLCompiler compile failed."
102+
exit 1
103+
fi
112104
fi
113-
# echo "LLVM_BUILD_DIR is not set, using system LLVM or downloading prebuilt LLVM."
114-
# TRITON_BUILD_WITH_CLANG_LLD=true TRITON_BUILD_WITH_CCACHE=true \
115-
# python3 -m pip wheel --no-deps --no-build-isolation -w dist/ .
116105
else
117106
echo "LLVM_BUILD_DIR is set to $LLVM_BUILD_DIR"
118107
LLVM_INCLUDE_DIRS=$LLVM_BUILD_DIR/include \
@@ -127,4 +116,4 @@ else
127116
exit 1
128117
fi
129118
fi
130-
notify_apply_patch
119+
notify_apply_patch

0 commit comments

Comments
 (0)