diff --git a/.github/workflows/_integration_test.yml b/.github/workflows/_integration_test.yml index 95846eedd3..13326adffb 100644 --- a/.github/workflows/_integration_test.yml +++ b/.github/workflows/_integration_test.yml @@ -18,17 +18,14 @@ jobs: run: working-directory: ${{ inputs.working-directory }} if: github.ref == 'refs/heads/master' - runs-on: ubuntu-latest environment: Scheduled testing publish + runs-on: ${{ matrix.os }} strategy: matrix: - python-version: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" - name: "make integration_test #${{ matrix.python-version }}" + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.8", "3.9", "3.10", "3.11"] + + name: "make integration_test #${{ matrix.os }} Python ${{ matrix.python-version }}" steps: - uses: actions/checkout@v4 @@ -53,12 +50,25 @@ jobs: run: | make integration_tests - - name: Remove chatchat Test Untracked files + + - name: Remove chatchat Test Untracked files (Linux/macOS) + if: runner.os != 'Windows' + working-directory: ${{ inputs.working-directory }} + run: | + if [ -d "tests/unit_tests/config/chatchat/" ]; then + rm -rf tests/unit_tests/config/chatchat/ + fi + + - name: Remove chatchat Test Untracked files (Windows) + if: runner.os == 'Windows' working-directory: ${{ inputs.working-directory }} run: | - rm -rf tests/unit_tests/config/chatchat/ + if (Test-Path -Path "tests/unit_tests/config/chatchat/") { + Remove-Item -Recurse -Force "tests/unit_tests/config/chatchat/" + } - - name: Ensure the tests did not create any additional files + - name: Ensure the tests did not create any additional files (Linux/macOS) + if: runner.os != 'Windows' shell: bash run: | set -eu @@ -69,3 +79,13 @@ jobs: # grep will exit non-zero if the target message isn't found, # and `set -e` above will cause the step to fail. echo "$STATUS" | grep 'nothing to commit, working tree clean' + + - name: Ensure the tests did not create any additional files (Windows) + if: runner.os == 'Windows' + shell: powershell + run: | + $STATUS = git status + Write-Host $STATUS + + # Select-String will exit non-zero if the target message isn't found. + $STATUS | Select-String 'nothing to commit, working tree clean' diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 5816ec69ed..a392ff9efe 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -17,17 +17,13 @@ jobs: defaults: run: working-directory: ${{ inputs.working-directory }} - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: - python-version: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.8", "3.9", "3.10", "3.11"] - name: "make test #${{ matrix.python-version }}" + name: "make test #${{ matrix.os }} Python ${{ matrix.python-version }}" steps: - uses: actions/checkout@v4 @@ -49,13 +45,24 @@ jobs: run: | make test + - name: Remove chatchat Test Untracked files (Linux/macOS) + if: runner.os != 'Windows' + working-directory: ${{ inputs.working-directory }} + run: | + if [ -d "tests/unit_tests/config/chatchat/" ]; then + rm -rf tests/unit_tests/config/chatchat/ + fi - - name: Remove chatchat Test Untracked files + - name: Remove chatchat Test Untracked files (Windows) + if: runner.os == 'Windows' working-directory: ${{ inputs.working-directory }} run: | - rm -rf tests/unit_tests/config/chatchat/ + if (Test-Path -Path "tests/unit_tests/config/chatchat/") { + Remove-Item -Recurse -Force "tests/unit_tests/config/chatchat/" + } - - name: Ensure the tests did not create any additional files + - name: Ensure the tests did not create any additional files (Linux/macOS) + if: runner.os != 'Windows' shell: bash run: | set -eu @@ -66,3 +73,13 @@ jobs: # grep will exit non-zero if the target message isn't found, # and `set -e` above will cause the step to fail. echo "$STATUS" | grep 'nothing to commit, working tree clean' + + - name: Ensure the tests did not create any additional files (Windows) + if: runner.os == 'Windows' + shell: powershell + run: | + $STATUS = git status + Write-Host $STATUS + + # Select-String will exit non-zero if the target message isn't found. + $STATUS | Select-String 'nothing to commit, working tree clean' diff --git a/libs/chatchat-server/chatchat/configs/_core_config.py b/libs/chatchat-server/chatchat/configs/_core_config.py index 4ae6de0f26..2712ce2d18 100644 --- a/libs/chatchat-server/chatchat/configs/_core_config.py +++ b/libs/chatchat-server/chatchat/configs/_core_config.py @@ -92,7 +92,7 @@ def clear(self): def _load_config(self): try: - with open(self.workspace_config, "r") as f: + with open(self.workspace_config, "r", encoding="utf-8") as f: return json.loads(f.read()) except FileNotFoundError: return None @@ -120,7 +120,7 @@ def get_config_by_type(self, cfg_type) -> Dict[str, Any]: def store_config(self): logger.info("Store workspace config.") _load_config = self._load_config() - with open(self.workspace_config, "w") as f: + with open(self.workspace_config, "w", encoding="utf-8")as f: config_json = self.get_config().to_dict() if _load_config is None: