From 1d1bbaf3d48834b2ae8c1dcabf0e42e9be4979ec Mon Sep 17 00:00:00 2001 From: Wenxin Zhang Date: Fri, 5 Jan 2024 13:28:23 +0800 Subject: [PATCH] add tests and nodes Signed-off-by: Wenxin Zhang --- .github/workflows/unit-test-bestla.yml | 81 ++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/unit-test-bestla.yml diff --git a/.github/workflows/unit-test-bestla.yml b/.github/workflows/unit-test-bestla.yml new file mode 100644 index 000000000..796699d8a --- /dev/null +++ b/.github/workflows/unit-test-bestla.yml @@ -0,0 +1,81 @@ +name: Bestla Unit Test + +on: + pull_request: + branches: [main] + paths: + - bestla/**" + - .github/workflows/unit-test-bestla.yml + - '!bestla/README.md' + workflow_dispatch: + +# If there is a new commit, the previous jobs will be canceled +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + DOCKER_CONFIG_NAME: "commonDockerConfig" + REPO_NAME: "neural-speed" + REPO_TAG: "py38" + DOCKER_FILE_NAME: "devel" + CONTAINER_NAME: "utTest" + +jobs: + unit-test: + runs-on: [self-hosted, linux, X64, spr] + steps: + - name: Docker Clean Up + run: | + docker ps -a + if [[ $(docker ps -a | grep -i '${{ env.CONTAINER_NAME }}-${{ runner.name }}'$) ]]; then + docker start ${{ env.CONTAINER_NAME }}-${{ runner.name }} + echo "remove left files through container ..." + docker exec ${{ env.CONTAINER_NAME }}-${{ runner.name }} bash -c "ls -a /neural-speed && rm -fr /neural-speed/* && rm -fr /neural-speed/.* || true" + fi + + - name: Checkout out Repo + uses: actions/checkout@v3 + with: + submodules: "recursive" + fetch-tags: true + + - name: Docker Build + run: | + docker build -f ${{ github.workspace }}/.github/workflows/docker/${{ env.DOCKER_FILE_NAME }}.dockerfile -t ${{ env.REPO_NAME }}:${{ env.REPO_TAG }} . + + - name: Docker Run + run: | + if [[ $(docker ps -a | grep -i '${{ env.CONTAINER_NAME }}'$) ]]; then + docker stop ${{ env.CONTAINER_NAME }} + docker rm -vf ${{ env.CONTAINER_NAME }} || true + fi + docker run -dit --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }}-${{ runner.name }} -v /dev/shm:/dev/shm \ + -v ${{ github.workspace }}:/neural-speed \ + -v /dataset/tf_dataset2:/tf_dataset2 \ + -v ~/.cache/oneAPI:/cache \ + ${{ env.REPO_NAME }}:${{ env.REPO_TAG }} + + - name: Env build + run: | + docker exec ${{ env.CONTAINER_NAME }}-${{ runner.name }} \ + bash /neural-speed/.github/workflows/scripts/prepare_env.sh + + - name: Run UT + run: | + docker exec ${{ env.CONTAINER_NAME }}-${{ runner.name }} \ + bash -c "cd /neural-speed/bestla && mkdir build && cd build && cmake .. -DBTLA_UT_ALL=ON && make -j \ + && ./bestla_ut 2>&1 | tee unit_test_bestla.log" + + - name: Check Result + run: | + docker exec ${{ env.CONTAINER_NAME }}-${{ runner.name }} \ + bash -c "cd /neural-speed/bestla \ + && [[ $(grep -c "Case Failed" unit_test_bestla.log) != 0 ]] && echo "UT Failed! Please check UT log." + + - name: Publish pipeline artifact + uses: actions/upload-artifact@v3 + if: ${{ !cancelled() }} + with: + name: Bestla Unit Test + path: ${{ github.workspace }}/unit_test*.*