From bf243c90df8ac8ae8a00462d08232c651e7a9b11 Mon Sep 17 00:00:00 2001 From: zstar <65890619+zstar1003@users.noreply.github.com> Date: Sun, 30 Mar 2025 01:06:34 +0800 Subject: [PATCH] ci: add ci and templates (#4) --- .github/ISSUE_TEMPLATE/bug_report.yml | 73 ++++++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 52 +++++++ .github/ISSUE_TEMPLATE/question.yml | 28 ++++ .github/ISSUE_TEMPLATE/subtask.yml | 29 ++++ .github/pull_request_template.md | 12 ++ .github/workflows/tests.yml | 153 +++++++++++++++++++++ 6 files changed, 347 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml create mode 100644 .github/ISSUE_TEMPLATE/subtask.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/tests.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..068baed --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,73 @@ +name: "🐞 Bug Report" +description: Create a bug issue for RAGFlow +title: "[Bug]: " +labels: ["🐞 bug"] +body: +- type: checkboxes + attributes: + label: Self Checks + description: "Please check the following in order to be responded in time :)" + options: + - label: I have searched for existing issues [search for existing issues](https://github.com/infiniflow/ragflow/issues), including closed ones. + required: true + - label: I confirm that I am using English to submit this report ([Language Policy](https://github.com/infiniflow/ragflow/issues/5910)). + required: true + - label: Non-english title submitions will be closed directly ( ιžθ‹±ζ–‡ζ ‡ι’˜ηš„ζδΊ€ε°†δΌšθ’«η›΄ζŽ₯ε…³ι—­ ) ([Language Policy](https://github.com/infiniflow/ragflow/issues/5910)). + required: true + - label: "Please do not modify this template :) and fill in all the required fields." + required: true +- type: markdown + attributes: + value: "Please provide the following information to help us understand the issue." +- type: input + attributes: + label: RAGFlow workspace code commit ID + description: Enter the commit ID associated with the issue. + placeholder: e.g., 26d3480e + validations: + required: true +- type: input + attributes: + label: RAGFlow image version + description: Enter the image version(shown in RAGFlow UI, `System` page) associated with the issue. + placeholder: e.g., 26d3480e(v0.13.0~174) + validations: + required: true +- type: textarea + attributes: + label: Other environment information + description: | + Enter the environment details: + value: | + - Hardware parameters: + - OS type: + - Others: + render: Markdown + validations: + required: false +- type: textarea + attributes: + label: Actual behavior + description: Describe what you encountered. + validations: + required: true +- type: textarea + attributes: + label: Expected behavior + description: Describe what you expected. + validations: + required: false +- type: textarea + attributes: + label: Steps to reproduce + description: Steps to reproduce what you encountered. + render: Markdown + validations: + required: true +- type: textarea + attributes: + label: Additional information + description: | + Log, error message, or any other information can help find the root cause. + validations: + required: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..2ef7ec9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,52 @@ +name: "πŸ’ž Feature request" +description: Propose a feature request for RAGFlow. +title: "[Feature Request]: " +labels: ["πŸ’ž feature"] +body: + - type: checkboxes + attributes: + label: Self Checks + description: "Please check the following in order to be responded in time :)" + options: + - label: I have searched for existing issues [search for existing issues](https://github.com/infiniflow/ragflow/issues), including closed ones. + required: true + - label: I confirm that I am using English to submit this report ([Language Policy](https://github.com/infiniflow/ragflow/issues/5910)). + required: true + - label: Non-english title submitions will be closed directly ( ιžθ‹±ζ–‡ζ ‡ι’˜ηš„ζδΊ€ε°†δΌšθ’«η›΄ζŽ₯ε…³ι—­ ) ([Language Policy](https://github.com/infiniflow/ragflow/issues/5910)). + required: true + - label: "Please do not modify this template :) and fill in all the required fields." + required: true + - type: textarea + attributes: + label: Is your feature request related to a problem? + description: | + A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + render: Markdown + validations: + required: false + - type: textarea + attributes: + label: Describe the feature you'd like + description: A clear and concise description of what you want to happen. + validations: + required: true + - type: textarea + attributes: + label: Describe implementation you've considered + description: A clear and concise description of implementation you've considered or investigated. + validations: + required: false + - type: textarea + attributes: + label: Documentation, adoption, use case + description: If you can, explain some scenarios how users might use this, situations it would be helpful in. Any API designs, mockups, or diagrams are also helpful. + render: Markdown + validations: + required: false + - type: textarea + attributes: + label: Additional information + description: | + Add any other context or screenshots about the feature request here. + validations: + required: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 0000000..f50fc33 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,28 @@ +name: "πŸ™‹β€β™€οΈ Question" +description: Ask questions on RAGFlow +title: "[Question]: " +labels: ["πŸ™‹β€β™€οΈ question"] +body: +- type: checkboxes + attributes: + label: Self Checks + description: "Please check the following in order to be responded in time :)" + options: + - label: I have searched for existing issues [search for existing issues](https://github.com/infiniflow/ragflow/issues), including closed ones. + required: true + - label: I confirm that I am using English to submit this report ([Language Policy](https://github.com/infiniflow/ragflow/issues/5910)). + required: true + - label: Non-english title submitions will be closed directly ( ιžθ‹±ζ–‡ζ ‡ι’˜ηš„ζδΊ€ε°†δΌšθ’«η›΄ζŽ₯ε…³ι—­ ) ([Language Policy](https://github.com/infiniflow/ragflow/issues/5910)). + required: true + - label: "Please do not modify this template :) and fill in all the required fields." + required: true +- type: markdown + attributes: + value: | + If the previous templates don't fit with what you'd like to report or ask, please use this general question template to file issue. +- type: textarea + attributes: + label: Describe your problem + description: A clear and concise description of your problem. + validations: + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/subtask.yml b/.github/ISSUE_TEMPLATE/subtask.yml new file mode 100644 index 0000000..e2cac09 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/subtask.yml @@ -0,0 +1,29 @@ +name: Subtask +description: "Propose a subtask for RAGFlow" +title: "[Subtask]: " +labels: [subtask] + +body: + - type: textarea + attributes: + label: Parent Issue + description: Write the ID of the parent issue + placeholder: "Parent issue: #" + validations: + required: true + + - type: textarea + attributes: + label: Detail of Subtask + description: | + Describe the functions that this subtask should implement + validations: + required: true + + - type: textarea + attributes: + label: Describe implementation you've considered + description: A clear and concise description of implementation you've considered or investigated. + validations: + required: false + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..de17118 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,12 @@ +### What problem does this PR solve? + +_Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR._ + +### Type of change + +- [ ] Bug Fix (non-breaking change which fixes an issue) +- [ ] New Feature (non-breaking change which adds functionality) +- [ ] Documentation Update +- [ ] Refactoring +- [ ] Performance Improvement +- [ ] Other (please describe): diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d7309ef --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,153 @@ +name: tests + +on: + push: + branches: + - 'main' + - '*.*.*' + paths-ignore: + - 'docs/**' + - '*.md' + - '*.mdx' + pull_request: + types: [ opened, synchronize, reopened, labeled ] + paths-ignore: + - 'docs/**' + - '*.md' + - '*.mdx' + +# https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + ragflow_tests: + name: ragflow_tests + # https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution + # https://github.com/orgs/community/discussions/26261 + if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ci') }} + runs-on: [ "self-hosted", "debug" ] + steps: + # https://github.com/hmarr/debug-action + #- uses: hmarr/debug-action@v2 + + - name: Show who triggered this workflow + run: | + echo "Workflow triggered by ${{ github.event_name }}" + + - name: Ensure workspace ownership + run: echo "chown -R $USER $GITHUB_WORKSPACE" && sudo chown -R $USER $GITHUB_WORKSPACE + + # https://github.com/actions/checkout/issues/1781 + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + # https://github.com/astral-sh/ruff-action + - name: Static check with Ruff + uses: astral-sh/ruff-action@v2 + with: + version: ">=0.8.2" + args: "check" + + - name: Build ragflow:nightly-slim + run: | + RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME} + sudo docker pull ubuntu:22.04 + sudo docker build --progress=plain --build-arg LIGHTEN=1 --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:nightly-slim . + + - name: Build ragflow:nightly + run: | + sudo docker build --progress=plain --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:nightly . + + - name: Start ragflow:nightly-slim + run: | + echo -e "\nRAGFLOW_IMAGE=infiniflow/ragflow:nightly-slim" >> docker/.env + sudo docker compose -f docker/docker-compose.yml up -d + + - name: Stop ragflow:nightly-slim + if: always() # always run this step even if previous steps failed + run: | + sudo docker compose -f docker/docker-compose.yml down -v + + - name: Start ragflow:nightly + run: | + echo -e "\nRAGFLOW_IMAGE=infiniflow/ragflow:nightly" >> docker/.env + sudo docker compose -f docker/docker-compose.yml up -d + + - name: Run sdk tests against Elasticsearch + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_sdk_api && pytest -s --tb=short get_email.py t_dataset.py t_chat.py t_session.py t_document.py t_chunk.py + + - name: Run frontend api tests against Elasticsearch + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_frontend_api && pytest -s --tb=short get_email.py test_dataset.py + + - name: Run http api tests against Elasticsearch + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_http_api && pytest -s --tb=short -m "not slow" + + - name: Stop ragflow:nightly + if: always() # always run this step even if previous steps failed + run: | + sudo docker compose -f docker/docker-compose.yml down -v + + - name: Start ragflow:nightly + run: | + sudo DOC_ENGINE=infinity docker compose -f docker/docker-compose.yml up -d + + - name: Run sdk tests against Infinity + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_sdk_api && pytest -s --tb=short get_email.py t_dataset.py t_chat.py t_session.py t_document.py t_chunk.py + + - name: Run frontend api tests against Infinity + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_frontend_api && pytest -s --tb=short get_email.py test_dataset.py + + - name: Run http api tests against Infinity + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_http_api && DOC_ENGINE=infinity pytest -s --tb=short -m "not slow" + + - name: Stop ragflow:nightly + if: always() # always run this step even if previous steps failed + run: | + sudo DOC_ENGINE=infinity docker compose -f docker/docker-compose.yml down -v