Fix windows/macos compiler compat, Python <=3.11 template compat (#23) #159
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Unit Tests | |
| defaults: | |
| run: | |
| shell: bash -le {0} | |
| on: | |
| push: | |
| repository_dispatch: | |
| workflow_dispatch: | |
| #concurrency: | |
| # group: ${{ github.ref }}-workflow-unit-tests | |
| # cancel-in-progress: true | |
| jobs: | |
| list-test-files: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| test-files: ${{ steps.files.outputs.test-files }} | |
| steps: | |
| - name: Checkout Codes | |
| uses: actions/checkout@v5 | |
| - name: List files | |
| id: files | |
| run: | | |
| script=" | |
| import json | |
| import os | |
| import re | |
| IGNORED_TEST_FILES = '${IGNORED_TEST_FILES}' | |
| all_tests = [f.removesuffix('.py') for f in os.listdir('tests/') if f.startswith('test_') and f.endswith('.py') and f.strip().removesuffix('py') not in f'{IGNORED_TEST_FILES}'] | |
| print(f'{json.dumps(all_tests)}') | |
| " | |
| test_files=$(python3 -c "$script") | |
| IFS='|' read -r test_files <<< "$test_files" | |
| echo "test-files=$test_files" >> "$GITHUB_OUTPUT" | |
| echo "Test files: $test_files" | |
| test: | |
| needs: | |
| - list-test-files | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ ubuntu-latest, macos-latest, macos-13, windows-latest ] # macos-latest arm64, macos-13 intel | |
| test_script: ${{ fromJSON(needs.list-test-files.outputs.test-files) }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.13 | |
| cache: 'pip' | |
| - name: install | |
| run: | | |
| pip install pip pytest tabulate regex -U | |
| pip install -v -e . | |
| - name: test ${{ matrix.test_script }} | |
| run: pytest --durations=0 tests/${{ matrix.test_script }}.py | |
| freebsd: | |
| needs: | |
| - list-test-files | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| test_script: ${{ fromJSON(needs.list-test-files.outputs.test-files) }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: clean dir | |
| run: rm -rf .git | |
| - name: Test in FreeBSD | |
| uses: vmactions/freebsd-vm@v1 | |
| with: | |
| copyback: false | |
| prepare: | | |
| env ASSUME_ALWAYS_YES=yes pkg install -y python py311-pip pcre2 gcc gmake pkgconf | |
| run: | | |
| python -V | |
| python -m venv venv | |
| . venv/bin/activate | |
| pip install pip pytest tabulate regex -U | |
| pip install -v -e . | |
| pytest --durations=0 tests/${{ matrix.test_script }}.py | |
| solaris: | |
| needs: | |
| - list-test-files | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| test_script: ${{ fromJSON(needs.list-test-files.outputs.test-files) }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: clean dir | |
| run: rm -rf .git | |
| - name: Test in Solaris | |
| uses: vmactions/solaris-vm@v1 | |
| with: | |
| prepare: | | |
| pkg install developer/gcc developer/build/gnu-make developer/build/pkg-config | |
| copyback: false | |
| run: | | |
| export LDFLAGS="-L/usr/lib/amd64 -L/usr/lib/64" | |
| export CFLAGS="-m64" | |
| export LD_LIBRARY_PATH=/usr/lib/amd64:$LD_LIBRARY_PATH | |
| python -V | |
| python -m venv venv | |
| source venv/bin/activate | |
| pip install pip pytest tabulate regex -U | |
| pip install -v -e . | |
| pytest --durations=0 tests/${{ matrix.test_script }}.py | |
| wsl: | |
| needs: | |
| - list-test-files | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| test_script: ${{ fromJSON(needs.list-test-files.outputs.test-files) }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: Vampire/setup-wsl@v6 | |
| with: | |
| distribution: Ubuntu-24.04 | |
| additional-packages: | |
| python3-dev | |
| python3-pip | |
| python3-venv | |
| build-essential | |
| pkg-config | |
| - name: test os | |
| shell: wsl-bash -u root {0} | |
| run: | | |
| python3 -m venv venv | |
| source venv/bin/activate | |
| pip install pip pytest tabulate regex -U | |
| pip install -v -e . | |
| pytest --durations=0 tests/${{ matrix.test_script }}.py |