Skip to content

Another unittests fix #39

Another unittests fix

Another unittests fix #39

Workflow file for this run

name: Python Multi-OS Tests
on:
push:
branches:
- main
jobs:
check-changes:
runs-on: ubuntu-latest
outputs:
RUN_TESTS: ${{ steps.check_changes.outputs.RUN_TESTS }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 2 # Ensure we have commit history for comparison
- name: Check Modified Files
id: check_changes
run: |
git fetch origin main --depth=2
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
# Check if cli_monitor.py or tests/ directory has been changed
if echo "$CHANGED_FILES" | grep -qE '^(cli_monitor.py|tests/)'; then
echo "RUN_TESTS=true" >> $GITHUB_ENV
echo "RUN_TESTS=true" >> $GITHUB_OUTPUT
else
echo "RUN_TESTS=false" >> $GITHUB_ENV
echo "RUN_TESTS=false" >> $GITHUB_OUTPUT
fi
test:
needs: check-changes
if: needs.check-changes.outputs.RUN_TESTS == 'true' # Skip if no relevant changes
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt || true # Ignore if no requirements.txt exists
- name: Run Tests
id: run_tests
run: |
python -m unittest discover -s tests
continue-on-error: false # Stop on failure
- name: Store Test Result in File
run: |
mkdir -p test-results
echo "${{ job.status }}" > test-results/test_result_${{ matrix.os }}_${{ matrix.python-version }}.txt
- name: Upload Unique Test Result Artifact
uses: actions/upload-artifact@v4
with:
name: TEST_RESULT_${{ matrix.os }}_${{ matrix.python-version }}
path: test-results/
retention-days: 1