diff --git a/.github/ci_script/combine_log.py b/.github/ci_script/combine_log.py deleted file mode 100644 index 05a8a973c..000000000 --- a/.github/ci_script/combine_log.py +++ /dev/null @@ -1,46 +0,0 @@ -import time -import sys -import os -''' - Get info. - output_path: the target file that you want to combine sub log with. - list_path: the list of sub log name. When it is updated, the correspondding file will be add to output tail. - list_dir_path: the dir path where sub logs stored. - status_path: the path of status file. When status file is written to "success" or "fail", exit script. -''' - -output_path = sys.argv[1] -list_path = sys.argv[2] -list_dir_path = sys.argv[3] -status_path = sys.argv[4] - -if __name__ == '__main__': - # list_pos stores the last position that pointer of list file pointed to. - list_pos = 0 - while True: - list_file = open(list_path, 'r') - list_file.seek(list_pos) - # read all lines starting from list_pos. - items = list_file.readlines() - # update list_pos - list_pos = list_file.tell() - # if read any line - if items is not None: - items.sort() - for item in items: - sub_path = item.strip() - if sub_path != "": - file_name = list_dir_path + '/' + sub_path - # while True: - if os.path.exists(file_name): - os.system('cat ' + file_name + ' >> ' + output_path) - # break - # check status_file, when read "success" or "fail" exit cycle, or else, sleep some seconds and start from beginning. - status_file = open(status_path) - status = status_file.readline().strip() - status_file.close() - if "fail" in status or "success" in status or "Success" in status or "Fail" in status or "error" in status or "Error" in status: - break - else: - time.sleep(2) - diff --git a/.github/ci_script/file_guard.py b/.github/ci_script/file_guard.py deleted file mode 100644 index 527f86b9e..000000000 --- a/.github/ci_script/file_guard.py +++ /dev/null @@ -1,32 +0,0 @@ -import time -import sys -import os -guard_status_file = sys.argv[1] -guard_log_file = sys.argv[2] - -if __name__ == '__main__': - # where stores the last position that pointer pointed to. - where= 0 - while True: - file = open(guard_log_file, "r") - file.seek(where) - # if read any lines, call system echo to print each line. - for line in file.readlines(): - new_line = line.strip().replace("\'", "_").replace("\"", "_") - os.system('echo ' + "'%s'" % new_line) - # update where - where = file.tell() - file.close() - # check status, end process when read "success" or "fail" - status_file = open(guard_status_file, "r") - line = status_file.readline().strip() - status_file.close() - if "success" in line or "Success" in line: - print("Task success.") - break - elif "fail" in line or "Fail" in line or "error" in line or "Error" in line: - print("Task Fail.") - exit(-1) - # sleep for a while - time.sleep(2) - diff --git a/.github/ci_script/mlu-ops-all_system_test_script.sh b/.github/ci_script/mlu-ops-all_system_test_script.sh deleted file mode 100644 index 695ac36a6..000000000 --- a/.github/ci_script/mlu-ops-all_system_test_script.sh +++ /dev/null @@ -1,77 +0,0 @@ -# /bin/bash -# get PR id -pr_id="ALLSYSTEM" - -# generate time stamp -current=`date "+%Y-%m-%d %H:%M:%S"` -timeStamp=`date -d "$current" +%s` -currentTimeStamp=$((timeStamp*1000+10#`date "+%N"`/1000000)) - -# temporally set to mlu370 -card_type="MLU370-S4" - -# default repo name -repo_name="mlu-ops" - -# repo ci root path -repo_root="~/${repo_name}_ci/" -if [ ! -d $repo_root ];then - mkdir $repo_root -fi - -# repo ci requests path -requests_path="$repo_root/requests" -if [ ! -d $requests_path ];then - mkdir $requests_path -fi - -# gen name of this ci -request_name="${repo_name}_${pr_id}_${currentTimeStamp}_${card_type}" - -# gen file and dir for this request -request_root="$repo_root/$request_name/" -sub_logs_path="$request_root/sub_logs/" - -if [ ! -d $request_root ];then - mkdir $request_root -fi - -if [ ! -d $sub_logs_path ];then - mkdir $sub_logs_path -fi - -echo "working" > "$request_root/status" -chmod o+w "$request_root/status" - -if [ ! -f "$request_root/log" ];then - touch "$request_root/log" -fi - -chmod o+w "$request_root/log" - -if [ ! -f "$request_root/log_list" ];then - touch "$request_root/log_list" -fi - -chmod o+w "$request_root/log_list" - -# gen request file. -echo "${repo_name},${pr_id},${currentTimeStamp},${card_type}" > "$requests_path/${request_name}" - -# start script -python3 .github/ci_script/file_guard.py "$request_root/status" "$request_root/log" & -python3 .github/ci_script/combine_log.py "$request_root/log" "$request_root/log_list" "$request_root/sub_logs" "$request_root/status" & - -wait - -status=$( head -n +1 ${request_root}/status ) - -if [ "$status" != "success" ];then - return_info=$( sed -n 2p ${request_root}/status ) - echo "${return_info}" - exit -1 -else - return_info=$( sed -n 2p ${request_root}/status ) - echo "${return_info}" - exit 0 -fi diff --git a/.github/ci_script/mlu-ops-ci_script.sh b/.github/ci_script/mlu-ops-ci_script.sh deleted file mode 100644 index 1b9103d95..000000000 --- a/.github/ci_script/mlu-ops-ci_script.sh +++ /dev/null @@ -1,93 +0,0 @@ -# /bin/bash -# get PR id -PR_string=$(echo $GITHUB_REF | grep -Eo "/[0-9]*/") -pr_id=(${PR_string//// }) - -# generate time stamp -current=`date "+%Y-%m-%d %H:%M:%S"` -timeStamp=`date -d "$current" +%s` -currentTimeStamp=$((timeStamp*1000+10#`date "+%N"`/1000000)) - -# temporally set to mlu370 -card_type="MLU370-S4" - -# default repo name -repo_name="mlu-ops" - -# repo ci root path -repo_root="/home/user/${repo_name}_ci/" -if [ ! -d $repo_root ];then - mkdir $repo_root -fi -# repo ci requests path -requests_path="$repo_root/requests" -if [ ! -d $requests_path ];then - mkdir $requests_path -fi - -# gen name of this ci -request_name="${repo_name}_${pr_id}_${currentTimeStamp}_${card_type}.rqt" - -# gen file and dir for this request -request_root="$repo_root/$request_name/" -sub_logs_path="$request_root/sub_logs/" - - -# echo "${repo_root}" -# echo "${requests_path}" -# echo "${request_root}" - -if [ ! -d $request_root ];then - mkdir $request_root -fi - -if [ ! -d $sub_logs_path ];then - mkdir $sub_logs_path -fi - -echo "working" > "$request_root/status" -chmod o+w "$request_root/status" - -if [ ! -f "$request_root/log" ];then - touch "$request_root/log" -fi - -chmod o+w "$request_root/log" - -if [ ! -f "$request_root/log_list" ];then - touch "$request_root/log_list" -fi - -chmod o+w "$request_root/log_list" - -# gen request file. -# echo "${repo_name},${pr_id},${currentTimeStamp},${card_type}" > "$requests_path/${request_name}" - -echo "repo:${repo_name}" > "$requests_path/${request_name}" - -echo "pr_id:${pr_id}" >> "$requests_path/${request_name}" - -echo "timestamp:${currentTimeStamp}" >> "$requests_path/${request_name}" - -# change dir group for server and client, or when server/client try to delete request, ftp may raise error. - -#chgrp -R ftpuser $request_root -#chgrp -R ftpuser $requests_path - -# start script -python3 .github/ci_script/file_guard.py "$request_root/status" "$request_root/log" & -python3 .github/ci_script/combine_log.py "$request_root/log" "$request_root/log_list" "$request_root/sub_logs" "$request_root/status" & - -wait - -# status=$(cat ${request_root}/status) - -status=$( head -n +1 ${request_root}/status ) - -if [ "$status" != "success" ];then - cat ${request_root}/status - exit -1 -else - cat ${request_root}/status - exit 0 -fi diff --git a/.github/scripts/invoke_ci_test.sh b/.github/scripts/invoke_ci_test.sh new file mode 100644 index 000000000..bf3d55407 --- /dev/null +++ b/.github/scripts/invoke_ci_test.sh @@ -0,0 +1,20 @@ +# /bin/bash +# get PR id +github_ref=$(echo $GITHUB_REF | grep -Eo "/[0-9]*/") +pr_id=(${github_ref//// }) + +# generate time stamp +current_time=`date "+%Y-%m-%d %H:%M:%S"` +timestamp_string=`date -d "${current_time}" +%s` +current_timestamp=$((timestamp_string*1000+10#`date "+%N"`/1000000)) + +# temporally set to mlu370 +card_type="MLU370-S4" + +# default repo name +repo_name="mlu-ops" + +github_user=${GITHUB_ACTOR} + +# start script +python3 .github/scripts/run_ci_test.py ${repo_name} ${github_user} ${pr_id} ${current_timestamp} \ No newline at end of file diff --git a/.github/scripts/run_ci_test.py b/.github/scripts/run_ci_test.py new file mode 100644 index 000000000..00cf5e1b6 --- /dev/null +++ b/.github/scripts/run_ci_test.py @@ -0,0 +1,51 @@ +import requests +import json +import time +import sys + +local_communication_port = 12547 + +params = sys.argv +try: + repo = params[1] + user = params[2] + pr_id = params[3] + timestamp = params[4] +except Exception as e: + print("Got some wrong with input params. Test fail.") + exit(-1) + +json_obj = { + "timestamp": timestamp, + "repo": repo, + "pr_id": pr_id, + "trigger_type": "ci", + "trigger_id": user, + "repeat_times": "3", + "status": "running" +} +local_test_server = "http://localhost:" + str(local_communication_port) + +# invoke test +response = requests.post(local_test_server, json=json_obj) +# get internal id +task_obj = json.loads(response.text) + +try: + while 1: + response = requests.get(local_test_server + "/aiming=get_status&id=" + task_obj["id"]) + result = json.loads(response.text) + if "success" in result["status"] or "fail" in result["status"] or "error" in result["status"] or "stable" in result["status"]: + print(result["log"]) + print(result["status"]) + response = requests.get(local_test_server + "/aiming=end_job&id=" + task_obj["id"]) + if "success" in result["status"]: + exit(0) + else: + exit(-1) + break + time.sleep(10) +except Exception as e: + print(e) + print("Got internal error while invoking test. Since we can not reboot this test, you should rerun this test in github.") + exit(-1) diff --git a/.github/workflows/mluops_all_system_ci.discard b/.github/workflows/mluops_all_system_ci.discard deleted file mode 100644 index a63f73d96..000000000 --- a/.github/workflows/mluops_all_system_ci.discard +++ /dev/null @@ -1,59 +0,0 @@ -name: mluops_all_system_test - -on: - push: - branches: [master, r*] - paths: - - 'CMakeLists.txt' - - 'independent_build.sh' - - 'build.sh' - - 'build.property' - - 'test/mlu_op_gtest/CMakeLists.txt' - - 'cmake/*' - - 'CMakeLists.txt' - tags: - - v* - pull_request: - branches: [master, r*] - paths: - - '.github/workflows/mluops_all_system_ci.yaml' - - 'CMakeLists.txt' - - 'independent_build.sh' - - 'build.sh' - - 'build.property' - - 'test/mlu_op_gtest/CMakeLists.txt' - - 'cmake/*' - - 'CMakeLists.txt' - -jobs: - test: - strategy: - matrix: - runner: [mlu370-m8] - mlu_ops_version : [1.3.0] - cntoolkit_version : [3.14.0] - cnnl_version: [1.26.6] - os: [ubuntu20.04, centos7, centos8, kylin10, ubuntu22.04] - runs-on: ${{matrix.runner}} - steps: - - uses: actions/checkout@v3 - with: - submodules: 'true' - - - name: pull_images - run: | - docker pull docker-user.extrotec.com:30080/mlu-ops/mluops_ci:devel-x86_64-${{matrix.os}}-cntoolkit${{matrix.cntoolkit_version}}-cnnl${{matrix.cnnl_version}} - - - name: build_mlu_ops - run: > - docker run --rm -v $(pwd):/work -w /work docker-user.extrotec.com:30080/mlu-ops/mluops_ci:devel-x86_64-${{matrix.os}}-cntoolkit${{matrix.cntoolkit_version}}-cnnl${{matrix.cnnl_version}} - ./build.sh - - - name: mlu_ops_version_check - run: > - docker run --rm -v $(pwd):/work -w /work docker-user.extrotec.com:30080/mlu-ops/mluops_ci:devel-x86_64-${{matrix.os}}-cntoolkit${{matrix.cntoolkit_version}}-cnnl${{matrix.cnnl_version}} - bash version_check.sh ${{matrix.mlu_ops_version}} - - - name: clean - run: | - rm -rf build diff --git a/.github/workflows/mluops_ci.yaml b/.github/workflows/mluops_ci.yaml index 1c885db82..9792ebfcd 100644 --- a/.github/workflows/mluops_ci.yaml +++ b/.github/workflows/mluops_ci.yaml @@ -48,4 +48,4 @@ jobs: - name: run_mlu_ops_ci run: > - bash .github/ci_script/mlu-ops-ci_script.sh + bash .github/scripts/invoke_ci_test.sh