Unit tests #12
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: | |
| repository_dispatch: | |
| workflow_dispatch: | |
| env: | |
| CUDA_DEVICE_ORDER: PCI_BUS_ID | |
| jobs: | |
| list-test-files: | |
| runs-on: ubuntu-24.04 | |
| if: github.event.inputs.m4-only != 'true' | |
| outputs: | |
| test-files: ${{ steps.files.outputs.test-files }} | |
| steps: | |
| - name: Checkout Codes | |
| uses: actions/checkout@v6 | |
| - name: List files | |
| id: files | |
| run: | | |
| dir="tests" | |
| json_array="[" | |
| for file in "$dir"/*; do | |
| [ -f "$file" ] || continue | |
| filename=$(basename "$file") | |
| if [[ "$filename" == test_*.py ]]; then | |
| json_array+="\"$filename\"," | |
| fi | |
| done | |
| json_array="${json_array%,}]" | |
| echo "$json_array" | |
| echo "test-files=$json_array" >> "$GITHUB_OUTPUT" | |
| test: | |
| runs-on: [ self-hosted ] | |
| needs: | |
| - list-test-files | |
| container: | |
| image: 10.0.13.31:5000/nvidia/cuda:130-ubuntu22.04_1021 | |
| volumes: | |
| - /monster/ci/pyenv:/opt/pyenv | |
| - /monster/ci/models:/monster/data/model | |
| - /monster/ci/huggingface:/github/home/.cache/huggingface | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| test_script: ${{ fromJSON(needs.list-test-files.outputs.test-files) }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Print Env | |
| run: | | |
| env_name="logbar_unit_test_py314_${{ matrix.test_script }}" | |
| echo "env name: $env_name" | |
| if [ -d "$(pyenv root)/versions/$env_name" ]; then | |
| echo "env exists, skip" | |
| else | |
| echo "creating venv..." | |
| pyenv virtualenv 3.14 "$env_name" | |
| fi | |
| pyenv local $env_name | |
| pyenv activate $env_name | |
| - name: install requirements | |
| run: pip install -U parameterized pytest pytest-xdist | |
| - name: install | |
| run: pip install . | |
| - name: test | |
| run: pytest -n 8 -v tests/${{ matrix.test_script }} |