Skip to content

Commit

Permalink
updated workflow with the conditional steps for different operating s…
Browse files Browse the repository at this point in the history
…ystems (#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.
  • Loading branch information
glide-the authored Jul 11, 2024
1 parent c777ea7 commit eb81613
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 24 deletions.
42 changes: 31 additions & 11 deletions .github/workflows/_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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'
39 changes: 28 additions & 11 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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'
4 changes: 2 additions & 2 deletions libs/chatchat-server/chatchat/configs/_core_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit eb81613

Please sign in to comment.