Skip to content

Commit eb81613

Browse files
authored
updated workflow with the conditional steps for different operating systems (#4480)
* In this configuration, the matrix strategy now includes an os key with ubuntu-latest, windows-latest, and macos-latest as possible values. This will run your tests across the specified Python versions and operating systems, ensuring broader compatibility testing for your project. * del 3.12 * UnicodeEncodeError: 'charmap' codec can't encode characters in position 4279-4280: character maps to * updated workflow with the conditional steps for different operating systems * check if the directory exists before trying to remove it.
1 parent c777ea7 commit eb81613

File tree

3 files changed

+61
-24
lines changed

3 files changed

+61
-24
lines changed

.github/workflows/_integration_test.yml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ jobs:
1818
run:
1919
working-directory: ${{ inputs.working-directory }}
2020
if: github.ref == 'refs/heads/master'
21-
runs-on: ubuntu-latest
2221
environment: Scheduled testing publish
22+
runs-on: ${{ matrix.os }}
2323
strategy:
2424
matrix:
25-
python-version:
26-
- "3.8"
27-
- "3.9"
28-
- "3.10"
29-
- "3.11"
30-
- "3.12"
31-
name: "make integration_test #${{ matrix.python-version }}"
25+
os: [ubuntu-latest, windows-latest, macos-latest]
26+
python-version: ["3.8", "3.9", "3.10", "3.11"]
27+
28+
name: "make integration_test #${{ matrix.os }} Python ${{ matrix.python-version }}"
3229
steps:
3330
- uses: actions/checkout@v4
3431

@@ -53,12 +50,25 @@ jobs:
5350
run: |
5451
make integration_tests
5552
56-
- name: Remove chatchat Test Untracked files
53+
54+
- name: Remove chatchat Test Untracked files (Linux/macOS)
55+
if: runner.os != 'Windows'
56+
working-directory: ${{ inputs.working-directory }}
57+
run: |
58+
if [ -d "tests/unit_tests/config/chatchat/" ]; then
59+
rm -rf tests/unit_tests/config/chatchat/
60+
fi
61+
62+
- name: Remove chatchat Test Untracked files (Windows)
63+
if: runner.os == 'Windows'
5764
working-directory: ${{ inputs.working-directory }}
5865
run: |
59-
rm -rf tests/unit_tests/config/chatchat/
66+
if (Test-Path -Path "tests/unit_tests/config/chatchat/") {
67+
Remove-Item -Recurse -Force "tests/unit_tests/config/chatchat/"
68+
}
6069
61-
- name: Ensure the tests did not create any additional files
70+
- name: Ensure the tests did not create any additional files (Linux/macOS)
71+
if: runner.os != 'Windows'
6272
shell: bash
6373
run: |
6474
set -eu
@@ -69,3 +79,13 @@ jobs:
6979
# grep will exit non-zero if the target message isn't found,
7080
# and `set -e` above will cause the step to fail.
7181
echo "$STATUS" | grep 'nothing to commit, working tree clean'
82+
83+
- name: Ensure the tests did not create any additional files (Windows)
84+
if: runner.os == 'Windows'
85+
shell: powershell
86+
run: |
87+
$STATUS = git status
88+
Write-Host $STATUS
89+
90+
# Select-String will exit non-zero if the target message isn't found.
91+
$STATUS | Select-String 'nothing to commit, working tree clean'

.github/workflows/_test.yml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@ jobs:
1717
defaults:
1818
run:
1919
working-directory: ${{ inputs.working-directory }}
20-
runs-on: ubuntu-latest
20+
runs-on: ${{ matrix.os }}
2121
strategy:
2222
matrix:
23-
python-version:
24-
- "3.8"
25-
- "3.9"
26-
- "3.10"
27-
- "3.11"
28-
- "3.12"
23+
os: [ubuntu-latest, windows-latest, macos-latest]
24+
python-version: ["3.8", "3.9", "3.10", "3.11"]
2925

30-
name: "make test #${{ matrix.python-version }}"
26+
name: "make test #${{ matrix.os }} Python ${{ matrix.python-version }}"
3127
steps:
3228
- uses: actions/checkout@v4
3329

@@ -49,13 +45,24 @@ jobs:
4945
run: |
5046
make test
5147
48+
- name: Remove chatchat Test Untracked files (Linux/macOS)
49+
if: runner.os != 'Windows'
50+
working-directory: ${{ inputs.working-directory }}
51+
run: |
52+
if [ -d "tests/unit_tests/config/chatchat/" ]; then
53+
rm -rf tests/unit_tests/config/chatchat/
54+
fi
5255
53-
- name: Remove chatchat Test Untracked files
56+
- name: Remove chatchat Test Untracked files (Windows)
57+
if: runner.os == 'Windows'
5458
working-directory: ${{ inputs.working-directory }}
5559
run: |
56-
rm -rf tests/unit_tests/config/chatchat/
60+
if (Test-Path -Path "tests/unit_tests/config/chatchat/") {
61+
Remove-Item -Recurse -Force "tests/unit_tests/config/chatchat/"
62+
}
5763
58-
- name: Ensure the tests did not create any additional files
64+
- name: Ensure the tests did not create any additional files (Linux/macOS)
65+
if: runner.os != 'Windows'
5966
shell: bash
6067
run: |
6168
set -eu
@@ -66,3 +73,13 @@ jobs:
6673
# grep will exit non-zero if the target message isn't found,
6774
# and `set -e` above will cause the step to fail.
6875
echo "$STATUS" | grep 'nothing to commit, working tree clean'
76+
77+
- name: Ensure the tests did not create any additional files (Windows)
78+
if: runner.os == 'Windows'
79+
shell: powershell
80+
run: |
81+
$STATUS = git status
82+
Write-Host $STATUS
83+
84+
# Select-String will exit non-zero if the target message isn't found.
85+
$STATUS | Select-String 'nothing to commit, working tree clean'

libs/chatchat-server/chatchat/configs/_core_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def clear(self):
9292

9393
def _load_config(self):
9494
try:
95-
with open(self.workspace_config, "r") as f:
95+
with open(self.workspace_config, "r", encoding="utf-8") as f:
9696
return json.loads(f.read())
9797
except FileNotFoundError:
9898
return None
@@ -120,7 +120,7 @@ def get_config_by_type(self, cfg_type) -> Dict[str, Any]:
120120
def store_config(self):
121121
logger.info("Store workspace config.")
122122
_load_config = self._load_config()
123-
with open(self.workspace_config, "w") as f:
123+
with open(self.workspace_config, "w", encoding="utf-8")as f:
124124
config_json = self.get_config().to_dict()
125125

126126
if _load_config is None:

0 commit comments

Comments
 (0)