Use plugin-managed Chromium in parallel CI #59
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: Parallel Tests | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: [dev, main, master] | |
| push: | |
| branches: [dev, main, master] | |
| env: | |
| PYTHONIOENCODING: utf-8 | |
| PYTHONLEGACYWINDOWSSTDIO: utf-8 | |
| USE_COLOR: False | |
| jobs: | |
| discover-tests: | |
| name: Discover test files | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| test-files: ${{ steps.set-matrix.outputs.test-files }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| fetch-depth: 1 | |
| - name: Discover test files | |
| id: set-matrix | |
| run: | | |
| plugin_tests=$(find abx_plugins/plugins -path "*/tests/test_*.py" -type f | sort) | |
| json_array="[" | |
| first=true | |
| for test_file in $plugin_tests; do | |
| if [ "$first" = true ]; then | |
| first=false | |
| else | |
| json_array+="," | |
| fi | |
| plugin=$(echo $test_file | sed 's|abx_plugins/plugins/\([^/]*\)/.*|\1|') | |
| test_name=$(basename $test_file .py | sed 's/^test_//') | |
| name="$test_name" | |
| json_array+="{\"path\":\"$test_file\",\"name\":\"$name\"}" | |
| done | |
| json_array+="]" | |
| echo "test-files=$json_array" >> $GITHUB_OUTPUT | |
| echo "Found $(echo $plugin_tests | wc -w) test files" | |
| echo "$json_array" | jq '.' | |
| run-tests: | |
| name: ${{ matrix.test.name }} | |
| runs-on: ubuntu-22.04 | |
| needs: discover-tests | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| test: ${{ fromJson(needs.discover-tests.outputs.test-files) }} | |
| python: ["3.13"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| fetch-depth: 1 | |
| - name: Set up Python ${{ matrix.python }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| architecture: x64 | |
| - name: Install uv | |
| run: python -m pip install --upgrade uv | |
| - name: Set up Node JS | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Cache uv | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/uv | |
| key: ${{ runner.os }}-${{ matrix.python }}-uv-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.python }}-uv- | |
| - name: Install system packages | |
| run: | | |
| sudo apt-get update | |
| sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ | |
| git wget ripgrep build-essential python3-dev python3-setuptools \ | |
| libssl-dev libldap2-dev libsasl2-dev zlib1g-dev libatomic1 \ | |
| python3-minimal gnupg2 curl python3-ldap python3-msgpack \ | |
| python3-mutagen python3-regex python3-pycryptodome procps | |
| - name: Install dependencies with uv | |
| run: | | |
| uv venv | |
| uv sync --dev --all-extras | |
| uv pip install -e ".[dev]" | |
| - name: Run test - ${{ matrix.test.name }} | |
| run: | | |
| uv run pytest -xvs "${{ matrix.test.path }}" --basetemp="$RUNNER_TEMP/pytest-out" | |
| env: | |
| TWOCAPTCHA_API_KEY: ${{ secrets.TWOCAPTCHA_API_KEY }} | |
| CHROME_SANDBOX: "false" | |
| CHROME_HEADLESS: "True" |