feat #189: introduce max_workers key in app config #677
Workflow file for this run
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: CI/Test | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| JING_VERSION: | |
| description: "Jing version to use" | |
| required: false | |
| default: "20091111" # Default value | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| packages: read | |
| pull-requests: write | |
| # GLOBAL ENV: Applies to ALL jobs (Linux & macOS) | |
| env: | |
| # Strict lockfile checks for everyone, equivalent to passing --frozen to every command | |
| UV_FROZEN: "1" | |
| # Needed for coverage/multiprocessing reliability | |
| PYTHONSTARTMETHOD: spawn | |
| # The group to use for installing/testing dependencies, see pyproject.toml | |
| PYPROJECT_GROUP: github-action | |
| jobs: | |
| test-ubuntu: | |
| name: ubuntu-python-${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| strategy: | |
| matrix: | |
| python-version: &python-matrix | |
| - '3.12' | |
| - '3.13' | |
| - '3.14' | |
| container: | |
| image: registry.opensuse.org/documentation/containers/15.6/opensuse-daps-toolchain:latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Get dependencies | |
| run: | | |
| rpm -q daps \ | |
| suse-xsl-stylesheets \ | |
| suse-xsl-stylesheets-sbp \ | |
| geekodoc \ | |
| docbook-xsl-stylesheets \ | |
| docbook-xsl-ns \ | |
| xmlgraphics-fop \ | |
| git \ | |
| ditaa \ | |
| libreoffice-draw \ | |
| novdoc \ | |
| ruby2.5-rubygem-asciidoctor \ | |
| curl \ | |
| tar \ | |
| w3m \ | |
| jq \ | |
| rsvg-convert \ | |
| openssh-clients || true | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| id: setup-uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Install dependencies and Coverage Tools | |
| run: uv sync --group ${{ env.PYPROJECT_GROUP }} | |
| - name: Run tests and Report Coverage | |
| env: | |
| UV_NO_SYNC: "1" # Disable uv sync during test runs | |
| run: | | |
| # Using 'uv run' avoids the need to manually source .venv/bin/activate | |
| uv run pytest --cov=src --cov=tests --cov-report=term-missing -vv | |
| # Combine data | |
| uv run python -m coverage combine --append || true | |
| # Generate report | |
| uv run python -m coverage report | tee coverage.txt | |
| # Cleanup | |
| uv run python -m coverage erase | |
| - name: Create Coverage Comment for ${{ github.event.pull_request.head.sha || github.sha }} | |
| if: success() && github.event_name == 'pull_request' && matrix.python-version == '3.12' | |
| env: | |
| # Use the PR head if available, otherwise fallback to the workflow SHA | |
| COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
| COVERAGE_THRESHOLD: 90 | |
| run: | | |
| # Get the short SHA (e.g., a1b2c3d) | |
| SHORT_SHA=${COMMIT_SHA::7} | |
| # 1. Header | |
| echo "## Coverage Report" > coverage_comment.txt | |
| echo "For commit $SHORT_SHA" >> coverage_comment.txt | |
| echo "" >> coverage_comment.txt | |
| # 2. Open the collapsible section | |
| echo "<details><summary>Click to expand Coverage Report</summary>" >> coverage_comment.txt | |
| echo "" >> coverage_comment.txt | |
| # 3. Open a diff code block | |
| echo "\`\`\`diff" >> coverage_comment.txt | |
| # 4. Run awk to parse percentages and add colors | |
| awk -v threshold="$COVERAGE_THRESHOLD" '{ | |
| # Flag to track if we found a percentage in this line | |
| is_coverage_row = 0 | |
| # 1. Scan all fields to find the one ending in "%" | |
| # (Crucial for "term-missing" where the last column might be line numbers "1-5") | |
| for (i=1; i<=NF; i++) { | |
| if ($i ~ /%$/) { | |
| # Remove "%" and force numeric type by adding 0 | |
| val = $i | |
| gsub("%", "", val) | |
| val = val + 0 # Force numeric conversion | |
| is_coverage_row = 1 | |
| break; # Stop once we find the percentage | |
| } | |
| } | |
| # 2. Logic: Colorize rows with %, indent everything else | |
| if (is_coverage_row) { | |
| if (val < threshold) { | |
| print "- " $0; # Red | |
| } else { | |
| print "+ " $0; # Green | |
| } | |
| } else { | |
| # Headers and Separators (------) fall here. | |
| # We add two spaces so they appear Gray and aligned. | |
| print " " $0; | |
| } | |
| }' coverage.txt >> coverage_comment.txt | |
| # 5. Close the block | |
| echo "\`\`\`" >> coverage_comment.txt | |
| echo "</details>" >> coverage_comment.txt | |
| - name: Save PR Number | |
| if: success() && github.event_name == 'pull_request' && matrix.python-version == '3.12' | |
| run: echo ${{ github.event.number }} > pr_number.txt | |
| - name: Upload Coverage Artifact | |
| if: success() && github.event_name == 'pull_request' && matrix.python-version == '3.12' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: coverage-artifact | |
| path: | | |
| coverage_comment.txt | |
| pr_number.txt | |
| test-macos: | |
| name: macos-python-${{ matrix.python-version }} | |
| runs-on: macos-latest | |
| strategy: | |
| matrix: | |
| python-version: *python-matrix | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| # Set up Python on macOS environment | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # Install uv and project dependencies inside a virtual environment | |
| - name: Install uv and dependencies | |
| env: | |
| UV_NO_SYNC: "1" # Disable uv sync during test runs | |
| run: | | |
| python3 -m venv .venv | |
| source .venv/bin/activate | |
| pip install uv | |
| uv pip install --editable . --group ${{ env.PYPROJECT_GROUP }} | |
| # Install macOS-specific external tools (such as XML parsers and Java) | |
| - name: Install external tools (macOS) | |
| run: | | |
| brew install libxml2 libxslt openjdk | |
| # Define the version and URL for jing.jar, using the input version from workflow_dispatch | |
| JING_VERSION="${{ github.event.inputs.JING_VERSION || '20091111' }}" | |
| JING_URL="https://repo1.maven.org/maven2/com/thaiopensource/jing/${JING_VERSION}/jing-${JING_VERSION}.jar" | |
| # Download jing.jar file for XML validation | |
| curl -sL -f $JING_URL -o jing.jar | |
| # Ensures the jar file is successfully downloaded, else exit with error | |
| if [ ! -f jing.jar ]; then | |
| echo "::error file=$JING_URL:: Failed to download jing.jar" | |
| exit 1 | |
| fi | |
| # Create a bash script to run jing.jar easily from the command line | |
| echo '#!/bin/bash' > jing | |
| echo 'java -jar jing.jar "$@"' >> jing | |
| chmod +x jing | |
| # Add paths of installed tools to GitHub Actions environment for easy access | |
| echo "$(pwd)" >> $GITHUB_PATH | |
| echo "/opt/homebrew/opt/openjdk/bin" >> $GITHUB_PATH | |
| echo "/opt/homebrew/opt/libxml2/bin" >> $GITHUB_PATH | |
| echo "/opt/homebrew/opt/libxslt/bin" >> $GITHUB_PATH | |
| # Run the tests using pytest inside the created virtual environment | |
| - name: Run tests | |
| run: | | |
| source .venv/bin/activate | |
| pytest --cov=src -vv | |
| env: | |
| PYTHONSTARTMETHOD: spawn |