11name : tests
2+ permissions :
3+ contents : read
24
35on :
46 push :
1214 # The only difference between pull_request and pull_request_target is the context in which the workflow runs:
1315 # — pull_request_target workflows use the workflow files from the default branch, and secrets are available.
1416 # — pull_request workflows use the workflow files from the pull request branch, and secrets are unavailable.
15- pull_request_target :
17+ pull_request :
1618 types : [ synchronize, ready_for_review ]
1719 paths-ignore :
1820 - ' docs/**'
@@ -31,20 +33,17 @@ jobs:
3133 name : ragflow_tests
3234 # https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution
3335 # https://github.com/orgs/community/discussions/26261
34- if : ${{ github.event_name != 'pull_request_target ' || contains(github.event.pull_request.labels.*.name, 'ci') }}
36+ if : ${{ github.event_name != 'pull_request ' || (github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'ci') ) }}
3537 runs-on : [ "self-hosted", "ragflow-test" ]
3638 steps :
37- # https://github.com/hmarr/debug-action
38- # - uses: hmarr/debug-action@v2
39-
4039 - name : Ensure workspace ownership
4140 run : |
4241 echo "Workflow triggered by ${{ github.event_name }}"
4342 echo "chown -R ${USER} ${GITHUB_WORKSPACE}" && sudo chown -R ${USER} ${GITHUB_WORKSPACE}
4443
4544 # https://github.com/actions/checkout/issues/1781
4645 - name : Check out code
47- uses : actions/checkout@v4
46+ uses : actions/checkout@v6
4847 with :
4948 ref : ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
5049 fetch-depth : 0
5352 - name : Check workflow duplication
5453 if : ${{ !cancelled() && !failure() }}
5554 run : |
56- if [[ ${GITHUB_EVENT_NAME} != "pull_request_target " && ${GITHUB_EVENT_NAME} != "schedule" ]]; then
55+ if [[ ${GITHUB_EVENT_NAME} != "pull_request " && ${GITHUB_EVENT_NAME} != "schedule" ]]; then
5756 HEAD=$(git rev-parse HEAD)
5857 # Find a PR that introduced a given commit
5958 gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
7877 fi
7978 fi
8079 fi
81- elif [[ ${GITHUB_EVENT_NAME} == "pull_request_target " ]]; then
80+ elif [[ ${GITHUB_EVENT_NAME} == "pull_request " ]]; then
8281 PR_NUMBER=${{ github.event.pull_request.number }}
8382 PR_SHA_FP=${RUNNER_WORKSPACE_PREFIX}/artifacts/${GITHUB_REPOSITORY}/PR_${PR_NUMBER}
8483 # Calculate the hash of the current workspace content
@@ -95,13 +94,53 @@ jobs:
9594 version : " >=0.11.x"
9695 args : " check"
9796
97+ - name : Check comments of changed Python files
98+ if : ${{ false }}
99+ run : |
100+ if [[ ${{ github.event_name }} == 'pull_request' || ${{ github.event_name }} == 'pull_request_target' ]]; then
101+ CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} \
102+ | grep -E '\.(py)$' || true)
103+
104+ if [ -n "$CHANGED_FILES" ]; then
105+ echo "Check comments of changed Python files with check_comment_ascii.py"
106+
107+ readarray -t files <<< "$CHANGED_FILES"
108+ HAS_ERROR=0
109+
110+ for file in "${files[@]}"; do
111+ if [ -f "$file" ]; then
112+ if python3 check_comment_ascii.py "$file"; then
113+ echo "✅ $file"
114+ else
115+ echo "❌ $file"
116+ HAS_ERROR=1
117+ fi
118+ fi
119+ done
120+
121+ if [ $HAS_ERROR -ne 0 ]; then
122+ exit 1
123+ fi
124+ else
125+ echo "No Python files changed"
126+ fi
127+ fi
128+
129+ - name : Run unit test
130+ run : |
131+ uv sync --python 3.12 --group test --frozen
132+ source .venv/bin/activate
133+ which pytest || echo "pytest not in PATH"
134+ echo "Start to run unit test"
135+ python3 run_tests.py
136+
98137 - name : Build ragflow:nightly
99138 run : |
100139 RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-${HOME}}
101140 RAGFLOW_IMAGE=infiniflow/ragflow:${GITHUB_RUN_ID}
102141 echo "RAGFLOW_IMAGE=${RAGFLOW_IMAGE}" >> ${GITHUB_ENV}
103142 sudo docker pull ubuntu:22.04
104- sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=1 -f Dockerfile -t ${RAGFLOW_IMAGE} .
143+ sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=1 --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} - f Dockerfile -t ${RAGFLOW_IMAGE} .
105144 if [[ ${GITHUB_EVENT_NAME} == "schedule" ]]; then
106145 export HTTP_API_TEST_LEVEL=p3
107146 else
@@ -161,34 +200,34 @@ jobs:
161200 echo "HOST_ADDRESS=http://host.docker.internal:${SVR_HTTP_PORT}" >> ${GITHUB_ENV}
162201
163202 sudo docker compose -f docker/docker-compose.yml -p ${GITHUB_RUN_ID} up -d
164- uv sync --python 3.10 --only-group test --no-default-groups --frozen && uv pip install sdk/python
203+ uv sync --python 3.12 --only-group test --no-default-groups --frozen && uv pip install sdk/python --group test
165204
166205 - name : Run sdk tests against Elasticsearch
167206 run : |
168207 export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
169- until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
208+ until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS}/v1/system/ping > /dev/null; do
170209 echo "Waiting for service to be available..."
171210 sleep 5
172211 done
173- source .venv/bin/activate && pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_sdk_api
212+ source .venv/bin/activate && set -o pipefail; pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_sdk_api 2>&1 | tee es_sdk_test.log
174213
175214 - name : Run frontend api tests against Elasticsearch
176215 run : |
177216 export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
178- until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
217+ until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS}/v1/system/ping > /dev/null; do
179218 echo "Waiting for service to be available..."
180219 sleep 5
181220 done
182- source .venv/bin/activate && pytest -s --tb=short sdk/python/test/test_frontend_api/get_email.py sdk/python/test/test_frontend_api/test_dataset.py
221+ source .venv/bin/activate && set -o pipefail; pytest -s --tb=short sdk/python/test/test_frontend_api/get_email.py sdk/python/test/test_frontend_api/test_dataset.py 2>&1 | tee es_api_test.log
183222
184223 - name : Run http api tests against Elasticsearch
185224 run : |
186225 export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
187- until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
226+ until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS}/v1/system/ping > /dev/null; do
188227 echo "Waiting for service to be available..."
189228 sleep 5
190229 done
191- source .venv/bin/activate && pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_http_api
230+ source .venv/bin/activate && set -o pipefail; pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_http_api 2>&1 | tee es_http_api_test.log
192231
193232 - name : Stop ragflow:nightly
194233 if : always() # always run this step even if previous steps failed
@@ -204,29 +243,29 @@ jobs:
204243 - name : Run sdk tests against Infinity
205244 run : |
206245 export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
207- until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
246+ until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS}/v1/system/ping > /dev/null; do
208247 echo "Waiting for service to be available..."
209248 sleep 5
210249 done
211- source .venv/bin/activate && DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_sdk_api
250+ source .venv/bin/activate && set -o pipefail; DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_sdk_api 2>&1 | tee infinity_sdk_test.log
212251
213252 - name : Run frontend api tests against Infinity
214253 run : |
215254 export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
216- until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
255+ until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS}/v1/system/ping > /dev/null; do
217256 echo "Waiting for service to be available..."
218257 sleep 5
219258 done
220- source .venv/bin/activate && DOC_ENGINE=infinity pytest -s --tb=short sdk/python/test/test_frontend_api/get_email.py sdk/python/test/test_frontend_api/test_dataset.py
259+ source .venv/bin/activate && set -o pipefail; DOC_ENGINE=infinity pytest -s --tb=short sdk/python/test/test_frontend_api/get_email.py sdk/python/test/test_frontend_api/test_dataset.py 2>&1 | tee infinity_api_test.log
221260
222261 - name : Run http api tests against Infinity
223262 run : |
224263 export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
225- until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
264+ until sudo docker exec ${RAGFLOW_CONTAINER} curl -s --connect-timeout 5 ${HOST_ADDRESS}/v1/system/ping > /dev/null; do
226265 echo "Waiting for service to be available..."
227266 sleep 5
228267 done
229- source .venv/bin/activate && DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_http_api
268+ source .venv/bin/activate && set -o pipefail; DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_http_api 2>&1 | tee infinity_http_api_test.log
230269
231270 - name : Stop ragflow:nightly
232271 if : always() # always run this step even if previous steps failed
0 commit comments