fix: increase default flush interval (#672) #2080
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 | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| ruff-format: | |
| name: Ruff format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Python dev environment | |
| uses: ./.github/actions/setup-python-dev | |
| - name: Check formatting with ruff | |
| run: | | |
| ruff format --check . | |
| ruff-lint: | |
| name: Ruff lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Python dev environment | |
| uses: ./.github/actions/setup-python-dev | |
| - name: Lint with ruff | |
| run: | | |
| ruff check . | |
| mypy: | |
| name: Mypy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Python dev environment | |
| uses: ./.github/actions/setup-python-dev | |
| - name: Check types with mypy | |
| run: | | |
| mypy --no-site-packages --config-file mypy.ini . | mypy-baseline filter | |
| public-api: | |
| name: Public API snapshot | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
| - name: Set up Python dev environment | |
| uses: ./.github/actions/setup-python-dev | |
| - name: Check public API snapshot | |
| run: | | |
| make public_api_check | |
| package-build: | |
| name: Package build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 | |
| with: | |
| python-version: 3.11.11 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0 | |
| with: | |
| enable-cache: true | |
| - name: Build and verify distributions | |
| run: | | |
| uv build | |
| uv run --with twine twine check dist/* | |
| tests: | |
| name: Python ${{ matrix.python-version }} tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0 | |
| with: | |
| enable-cache: true | |
| - name: Install test dependencies | |
| shell: bash | |
| run: | | |
| UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --extra test | |
| - name: Run posthog tests | |
| run: | | |
| pytest --verbose --timeout=30 | |
| mutation-tests: | |
| name: Targeted mutation tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check targeted mutation inputs changed | |
| id: changes | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| base="${{ github.event.pull_request.base.sha }}" | |
| head="${{ github.event.pull_request.head.sha }}" | |
| else | |
| base="${{ github.event.before }}" | |
| head="${{ github.sha }}" | |
| fi | |
| changed_files="$(git diff --name-only "$base" "$head" -- \ | |
| posthog/utils.py \ | |
| posthog/test/test_utils.py \ | |
| posthog/test/test_size_limited_dict.py)" | |
| if [[ -n "$changed_files" ]]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| echo "Targeted mutation inputs changed:" | |
| echo "$changed_files" | |
| else | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| echo "Skipping targeted mutation tests: inputs unchanged." | |
| fi | |
| - name: Set up Python 3.11 | |
| if: steps.changes.outputs.changed == 'true' | |
| uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 | |
| with: | |
| python-version: 3.11.11 | |
| - name: Install uv | |
| if: steps.changes.outputs.changed == 'true' | |
| uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0 | |
| with: | |
| enable-cache: true | |
| - name: Check utils CRAP score | |
| if: steps.changes.outputs.changed == 'true' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| UV_PROJECT_ENVIRONMENT=$pythonLocation uv run --extra test --with pytest-crap --with pytest-cov pytest posthog/test/test_utils.py posthog/test/test_size_limited_dict.py --timeout=30 --cov=posthog.utils --crap --crap-threshold=10 --crap-top-n=40 -q | |
| UV_PROJECT_ENVIRONMENT=$pythonLocation uv run --extra test --with pytest-crap --with pytest-cov python .github/scripts/check_crap_threshold.py posthog/utils.py --max-crap 10 | |
| - name: Restore mutmut cache | |
| id: mutmut-cache | |
| if: steps.changes.outputs.changed == 'true' | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: mutants | |
| key: mutmut-${{ runner.os }}-py311-${{ hashFiles('posthog/utils.py', 'posthog/test/test_utils.py', 'posthog/test/test_size_limited_dict.py') }} | |
| restore-keys: | | |
| mutmut-${{ runner.os }}-py311- | |
| - name: Skip mutation tests on exact cache hit | |
| if: steps.changes.outputs.changed == 'true' && steps.mutmut-cache.outputs.cache-hit == 'true' | |
| run: | | |
| echo "Skipping targeted mutation tests: exact mutmut cache hit." | |
| - name: Run targeted mutation tests | |
| if: steps.changes.outputs.changed == 'true' && steps.mutmut-cache.outputs.cache-hit != 'true' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| UV_PROJECT_ENVIRONMENT=$pythonLocation uv run --extra test --with mutmut mutmut run --max-children 1 | |
| results="$(UV_PROJECT_ENVIRONMENT=$pythonLocation uv run --extra test --with mutmut mutmut results)" | |
| if [[ -n "$results" ]]; then | |
| echo "$results" | |
| exit 1 | |
| fi | |
| import-check: | |
| name: Python ${{ matrix.python-version }} import check | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install posthog | |
| run: pip install . | |
| - name: Check import produces no warnings | |
| run: python -W error -c "import posthog" | |
| django5-integration: | |
| name: Django 5 integration tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 | |
| with: | |
| python-version: 3.12 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0 | |
| with: | |
| enable-cache: true | |
| - name: Install Django 5 test project dependencies | |
| shell: bash | |
| working-directory: integration_tests/django5 | |
| run: | | |
| UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync | |
| - name: Run Django 5 middleware integration tests | |
| working-directory: integration_tests/django5 | |
| run: | | |
| uv run pytest test_middleware.py test_exception_capture.py --verbose |