refactor python code #605
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: static checks on sco | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
DEEPLINK_PATH: /mnt/cache/share/deeplinkci/github/${{ github.repository }} | |
ENV_SOURCE: /mnt/cache/share/platform/env/dipu_latest_ci | |
PROXY_SOURCE: /mnt/cache/share/platform/env/proxy | |
CLANGD_EXEC: /mnt/cache/share/platform/dep/clang-17/bin/clangd | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
static-checks-on-sco-nvidia: | |
name: static checks on nv | |
runs-on: tps-sco-ci | |
steps: | |
- name: setting up environment | |
run: | | |
set -euxo pipefail | |
set_env() { | |
echo "$1=$2" >> "${GITHUB_ENV}" | |
eval "$1=\"\$2\"" | |
} | |
set_env WORKSPACE "${DEEPLINK_PATH}/${{ github.run_number }}" | |
set_env CODE_SOURCE "${WORKSPACE}/source" | |
set_env CLANGD_TIDY_SOURCE "${WORKSPACE}/clangd-tidy" | |
set_env CLANGD_TIDY_LOG "${WORKSPACE}/clang-tidy.log" | |
- name: clean obsolete workspaces & prepare workspace | |
run: | | |
set -euxo pipefail | |
mkdir -p ${DEEPLINK_PATH} | |
ls -la ${DEEPLINK_PATH} | |
rm -rf ${WORKSPACE} | |
find ${DEEPLINK_PATH} -mindepth 1 -maxdepth 1 -mmin +480 -type d -exec bash -c 'echo clean "$0" && rm -rf "$0"' {} \; | |
mkdir -p ${WORKSPACE} | |
- name: checkout code | |
run: | | |
set -euo pipefail | |
source ${PROXY_SOURCE} | |
set -x | |
rm -rf ${CODE_SOURCE} | |
if [ -n "${{ github.event.pull_request.head.repo.full_name }}" ] && [[ ! "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then | |
git clone ${{ github.event.pull_request.head.repo.clone_url }} ${CODE_SOURCE} | |
cd ${CODE_SOURCE} && git checkout ${{ github.event.pull_request.head.sha }} | |
git remote add mainrepo https://github.com/${{ github.repository }}.git | |
git fetch mainrepo && git merge --no-edit mainrepo/${{ github.base_ref }} | |
else | |
git clone ${{ github.event.repository.clone_url }} ${CODE_SOURCE} && cd ${CODE_SOURCE} | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
git checkout ${{ github.event.pull_request.head.sha }} && git merge --no-edit ${{ github.base_ref }} | |
else | |
git checkout ${{ github.sha }} | |
fi | |
fi | |
git submodule update --init --recursive | |
- name: checkout clangd-tidy | |
run: | | |
set -euo pipefail | |
source ${PROXY_SOURCE} | |
set -x | |
git -c advice.detachedHead=false clone --depth 1 -b v0.1.3 https://github.com/lljbash/clangd-tidy.git ${CLANGD_TIDY_SOURCE} | |
- name: build | |
run: | | |
set -euxo pipefail | |
srun --job-name=${GITHUB_JOB} bash -c "source ${ENV_SOURCE} && set -euxo pipefail && cd ${CODE_SOURCE} && pip install -e . -v -t install" | |
- name: clang-tidy | |
run: | | |
set -euxo pipefail | |
srun --job-name=${GITHUB_JOB} bash -c "source ${ENV_SOURCE} && set -euxo pipefail && cd ${CODE_SOURCE} && pwd && git ls-files csrc | xargs ${CLANGD_TIDY_SOURCE}/clangd-tidy --clangd-executable=${CLANGD_EXEC} --github --git-root=${CODE_SOURCE} -j4 -o ${CLANGD_TIDY_LOG}" || (cat ${CLANGD_TIDY_LOG} && false) | |
- name: cleanup | |
if: always() | |
run: | | |
set -euxo pipefail | |
rm -rf ${CODE_SOURCE}/build/.cache | |
build-on-ascend: | |
name: build on ascend | |
runs-on: tps-ascend-ci-910b | |
steps: | |
- name: prepare code | |
run: | | |
set -ex | |
rm ${DEEPLINK_PATH}/${{ github.run_number }}/* -rf | |
mkdir -p ${DEEPLINK_PATH}/${{ github.run_number }} && cd ${DEEPLINK_PATH}/${{ github.run_number }} | |
git clone https://github.com/DeepLink-org/DeepLinkExt.git && cd DeepLinkExt | |
git checkout ${{ github.event.pull_request.head.sha }} && git merge --no-edit ${{ github.base_ref }} | |
- name: build deeplink_ext | |
run: | | |
source /mnt/cache/share/platform/cienv/dipu_latest_ci | |
cd ${DEEPLINK_PATH}/${{ github.run_number }}/DeepLinkExt | |
python setup.py build_ext --inplace | |
test-on-ascend: | |
name: test on ascend | |
runs-on: tps-ascend-ci-910b | |
needs: [build-on-ascend] | |
steps: | |
- name: run unit tests on ascend | |
run: | | |
source /mnt/cache/share/platform/cienv/dipu_latest_ci | |
cd ${DEEPLINK_PATH}/${{ github.run_number }}/DeepLinkExt | |
export PYTHONPATH=$PWD:$PYTHONPATH | |
cd tests/ | |
export DEEPLINK_EXT_PLATFORM_TYPE=torch_dipu | |
python -m pytest -v ./ | |
export DEEPLINK_EXT_PLATFORM_TYPE=torch_npu | |
python -m pytest -v ./ |