You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tests.yml 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. name: tests
  2. on:
  3. push:
  4. branches:
  5. - 'main'
  6. - '*.*.*'
  7. paths-ignore:
  8. - 'docs/**'
  9. - '*.md'
  10. - '*.mdx'
  11. pull_request:
  12. types: [ opened, synchronize, reopened, labeled ]
  13. paths-ignore:
  14. - 'docs/**'
  15. - '*.md'
  16. - '*.mdx'
  17. schedule:
  18. - cron: '0 16 * * *' # This schedule runs every 16:00:00Z(00:00:00+08:00)
  19. # https://docs.github.com/en/actions/using-jobs/using-concurrency
  20. concurrency:
  21. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  22. cancel-in-progress: true
  23. jobs:
  24. ragflow_tests:
  25. name: ragflow_tests
  26. # https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution
  27. # https://github.com/orgs/community/discussions/26261
  28. if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ci') }}
  29. runs-on: [ "self-hosted", "debug" ]
  30. steps:
  31. # https://github.com/hmarr/debug-action
  32. #- uses: hmarr/debug-action@v2
  33. - name: Show who triggered this workflow
  34. run: |
  35. echo "Workflow triggered by ${{ github.event_name }}"
  36. - name: Ensure workspace ownership
  37. run: echo "chown -R $USER $GITHUB_WORKSPACE" && sudo chown -R $USER $GITHUB_WORKSPACE
  38. # https://github.com/actions/checkout/issues/1781
  39. - name: Check out code
  40. uses: actions/checkout@v4
  41. with:
  42. fetch-depth: 0
  43. fetch-tags: true
  44. # https://github.com/astral-sh/ruff-action
  45. - name: Static check with Ruff
  46. uses: astral-sh/ruff-action@v3
  47. with:
  48. version: ">=0.11.x"
  49. args: "check"
  50. - name: Build ragflow:nightly-slim
  51. run: |
  52. RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME}
  53. sudo docker pull ubuntu:22.04
  54. sudo docker build --progress=plain --build-arg LIGHTEN=1 --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:nightly-slim .
  55. - name: Build ragflow:nightly
  56. run: |
  57. sudo docker build --progress=plain --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:nightly .
  58. - name: Start ragflow:nightly-slim
  59. run: |
  60. echo -e "\nRAGFLOW_IMAGE=infiniflow/ragflow:nightly-slim" >> docker/.env
  61. sudo docker compose -f docker/docker-compose.yml up -d
  62. - name: Stop ragflow:nightly-slim
  63. if: always() # always run this step even if previous steps failed
  64. run: |
  65. sudo docker compose -f docker/docker-compose.yml down -v
  66. - name: Start ragflow:nightly
  67. run: |
  68. echo -e "\nRAGFLOW_IMAGE=infiniflow/ragflow:nightly" >> docker/.env
  69. sudo docker compose -f docker/docker-compose.yml up -d
  70. - name: Run sdk tests against Elasticsearch
  71. run: |
  72. export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
  73. export HOST_ADDRESS=http://host.docker.internal:9380
  74. until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
  75. echo "Waiting for service to be available..."
  76. sleep 5
  77. done
  78. if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
  79. export HTTP_API_TEST_LEVEL=p3
  80. else
  81. export HTTP_API_TEST_LEVEL=p2
  82. fi
  83. UV_LINK_MODE=copy uv sync --python 3.10 --only-group test --no-default-groups --frozen && uv pip install sdk/python && uv run --only-group test --no-default-groups pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_sdk_api
  84. - name: Run frontend api tests against Elasticsearch
  85. run: |
  86. export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
  87. export HOST_ADDRESS=http://host.docker.internal:9380
  88. until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
  89. echo "Waiting for service to be available..."
  90. sleep 5
  91. done
  92. cd sdk/python && UV_LINK_MODE=copy uv sync --python 3.10 --group test --frozen && source .venv/bin/activate && cd test/test_frontend_api && pytest -s --tb=short get_email.py test_dataset.py
  93. - name: Run http api tests against Elasticsearch
  94. run: |
  95. export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
  96. export HOST_ADDRESS=http://host.docker.internal:9380
  97. until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
  98. echo "Waiting for service to be available..."
  99. sleep 5
  100. done
  101. if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
  102. export HTTP_API_TEST_LEVEL=p3
  103. else
  104. export HTTP_API_TEST_LEVEL=p2
  105. fi
  106. UV_LINK_MODE=copy uv sync --python 3.10 --only-group test --no-default-groups --frozen && uv run --only-group test --no-default-groups pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_http_api
  107. - name: Stop ragflow:nightly
  108. if: always() # always run this step even if previous steps failed
  109. run: |
  110. sudo docker compose -f docker/docker-compose.yml down -v
  111. - name: Start ragflow:nightly
  112. run: |
  113. sudo DOC_ENGINE=infinity docker compose -f docker/docker-compose.yml up -d
  114. - name: Run sdk tests against Infinity
  115. run: |
  116. export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
  117. export HOST_ADDRESS=http://host.docker.internal:9380
  118. until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
  119. echo "Waiting for service to be available..."
  120. sleep 5
  121. done
  122. if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
  123. export HTTP_API_TEST_LEVEL=p3
  124. else
  125. export HTTP_API_TEST_LEVEL=p2
  126. fi
  127. UV_LINK_MODE=copy uv sync --python 3.10 --only-group test --no-default-groups --frozen && uv pip install sdk/python && DOC_ENGINE=infinity uv run --only-group test --no-default-groups pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_sdk_api
  128. - name: Run frontend api tests against Infinity
  129. run: |
  130. export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
  131. export HOST_ADDRESS=http://host.docker.internal:9380
  132. until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
  133. echo "Waiting for service to be available..."
  134. sleep 5
  135. done
  136. cd sdk/python && UV_LINK_MODE=copy uv sync --python 3.10 --group test --frozen && source .venv/bin/activate && cd test/test_frontend_api && pytest -s --tb=short get_email.py test_dataset.py
  137. - name: Run http api tests against Infinity
  138. run: |
  139. export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
  140. export HOST_ADDRESS=http://host.docker.internal:9380
  141. until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
  142. echo "Waiting for service to be available..."
  143. sleep 5
  144. done
  145. if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
  146. export HTTP_API_TEST_LEVEL=p3
  147. else
  148. export HTTP_API_TEST_LEVEL=p2
  149. fi
  150. UV_LINK_MODE=copy uv sync --python 3.10 --only-group test --no-default-groups --frozen && DOC_ENGINE=infinity uv run --only-group test --no-default-groups pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_http_api
  151. - name: Stop ragflow:nightly
  152. if: always() # always run this step even if previous steps failed
  153. run: |
  154. sudo DOC_ENGINE=infinity docker compose -f docker/docker-compose.yml down -v