taosAdapter qa ci workflow #16
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: 3.0 QA-workflow | |
on: | |
#pull_request: | |
# branches: | |
# - '3.0' | |
push: | |
branches: | |
- 'ref/qa_ci' | |
# - 'main' | |
# - '3.0' | |
# - '3.1' | |
# - '3.1.2' | |
workflow_dispatch: | |
env: | |
RELEASE_HOST: 192.168.1.45 | |
# RUSTFLAGS: "-C instrument-coverage --cfg tokio_unstable" | |
ARTIFACT_BASE_DIR: /data/artifacts | |
COVERAGE_BASE_DIR: /data/coverage | |
ALLURE_REPORT_DIR: /data/coverage | |
DIR_PATH: ${{ github.sha }} | |
WORK_DIR: /data/actions-runner-taosadapter/_work/taosadapter/taosadapter | |
TAOSADAPTER_DIR: /data/actions-runner-taosadapter/_work/taosadapter/taosadapter/taosadapter_${{ github.sha }} | |
REPORT_BASE_URL: http://192.168.1.45:8787 | |
GOCOVERDIR: /data/huoh/go_cover/${{ github.sha }} | |
jobs: | |
run_taosadapter_test: | |
runs-on: [self-hosted, linux, x64] | |
outputs: | |
container_id: ${{ steps.run_container.outputs.container_id }} | |
steps: | |
- name: run container | |
id: run_container | |
# 1. 寻找可用端口 | |
# 2. 启动容器 | |
# 3. copy TDengine 到容器 | |
run: | | |
for port in $(seq 10000 65000); do (echo >/dev/tcp/localhost/$port) &>/dev/null || { taosadapter_port=$port; break; }; done && echo "Available taosadapter_port: $taosadapter_port" | |
run_container_id=$(docker run --privileged=true -d \ | |
-v /data/huoh/TDengine:/data/TDengine \ | |
-v /data/huoh/release:/data/release \ | |
-v /data/huoh/TestNG_taosX:/data/huoh/TestNG_taosX \ | |
-v /data/coverage:/data/coverage \ | |
-v /data/huoh/go_cover:/data/huoh/go_cover \ | |
-v /data/actions-runner-taosadapter/_work:/data/actions-runner-taosadapter/_work \ | |
-p $taosadapter_port:6041 \ | |
-e GOCOVERDIR=${{ env.GOCOVERDIR }} \ | |
taosadapter_ci:latest) | |
echo "container_id: $run_container_id" | |
echo "container_id=$run_container_id" >> "$GITHUB_OUTPUT" | |
docker exec $run_container_id bash -c \ | |
"mkdir -p /app/release && \ | |
cp /data/release/* /app/release/ && \ | |
cd /app/release && \ | |
chmod +x taos taosd && \ | |
cp taos taosd /usr/bin/ && \ | |
cp libtaos.so.3.9.9.9 /usr/lib/ && \ | |
ln -sf /usr/lib/libtaos.so.3.9.9.9 /usr/lib/libtaos.so.1 && \ | |
ln -sf /usr/lib/libtaos.so.1 /usr/lib/libtaos.so && \ | |
cp taos.h /usr/include/" | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
path: taosadapter_${{ env.DIR_PATH }} | |
- name: build taosAdapter | |
run: | | |
docker exec ${{ steps.run_container.outputs.container_id }} bash -c \ | |
"cd ${{ env.TAOSADAPTER_DIR }} && \ | |
go build -cover" | |
- name: deploy taosadapter | |
run: | | |
docker exec ${{ steps.run_container.outputs.container_id }} bash -c \ | |
"mkdir -p /etc/taos && \ | |
cp ${{ env.TAOSADAPTER_DIR }}/taosadapter /usr/bin && \ | |
cp ${{ env.TAOSADAPTER_DIR }}/.github/workflows/taos.cfg /etc/taos/taos.cfg" | |
docker exec ${{ steps.run_container.outputs.container_id }} bash -c \ | |
"nohup taosd > /dev/null 2>&1 &" | |
docker exec ${{ steps.run_container.outputs.container_id }} bash -c \ | |
"nohup taosadapter > /dev/null 2>&1 &" | |
- name: 运行TestNG测试 | |
run: | | |
docker exec ${{ steps.run_container.outputs.container_id }} bash -c \ | |
"cd /data/huoh/TestNG_taosX && \ | |
poetry config virtualenvs.in-project true && \ | |
poetry install && \ | |
. ./setenv.sh && \ | |
cd taosadapter_tests && \ | |
poetry run pytest -sv -m sanity --alluredir=${{ env.ALLURE_REPORT_DIR }}/${{ env.DIR_PATH }}/allure_profile" | |
- name: allure report | |
run: | | |
allure generate ${{ env.ALLURE_REPORT_DIR }}/${{ env.DIR_PATH }}/allure_profile -o ${{ env.ALLURE_REPORT_DIR }}/${{ env.DIR_PATH }}/allure_report --clean | |
echo "see report at ${{ env.REPORT_BASE_URL }}/${{ env.DIR_PATH }}/allure_report/" | |
- name: collect coverage | |
run: | | |
docker exec ${{ steps.run_container.outputs.container_id }} bash -c \ | |
"go tool covdata textfmt -i=${{ env.GOCOVERDIR }} -o ${{ env.GOCOVERDIR }}/coverage.txt && \ | |
go tool cover -html=${{ env.GOCOVERDIR }}/coverage.txt -o ${{ env.GOCOVERDIR }}/coverage.html" | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4-beta | |
with: | |
files: ${{ env.GOCOVERDIR }}/coverage.txt | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }} | |
after_success: | |
runs-on: [self-hosted, linux, x64] | |
needs: run_taosadapter_test | |
if: success() | |
steps: | |
- name: Force stop taosd & taosadapter | |
# shell: bash {0} | |
run: | | |
echo "stop and rm container ${{ needs.run_taosadapter_test.outputs.container_id }}" | |
docker stop ${{ needs.run_taosadapter_test.outputs.container_id }} | |
docker rm ${{ needs.run_taosadapter_test.outputs.container_id }} | |
rm -rf /data/huoh/CI/taosadapter${{ env.DIR_PATH }} | |
#after_failure: | |
# runs-on: [self-hosted, linux, x64] | |
# needs: run_taosadapter_test | |
# if: failure() | |
# steps: | |
# - name: Send Feishu Message | |
# run: | | |
# rm -rf /data/huoh/CI/taosadapter${{ env.DIR_PATH }} | |
# curl -X POST -H "Content-Type: application/json" \ | |
# -d "{\"msg_type\":\"text\",\"content\":{\"text\":\"${{ github.workflow }} 运行失败,@${{ github.actor }},\n Action 执行地址见: https://github.com/taosdata/taosx/actions/runs/${{ github.run_id }} \n 报告地址见:$REPORT_BASE_URL/$DIR_PATH/allure_report/\"}}" \ | |
# https://open.feishu.cn/open-apis/bot/v2/hook/209e9aba-167a-49de-8d7b-15e12abd7922 |