Skip to content
Latchkey

Regression Tests workflow (dgunning/edgartools)

The Regression Tests workflow from dgunning/edgartools, explained and optimized by Latchkey.

A

CI health: A - excellent

Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: dgunning/edgartools.github/workflows/regression-tests.ymlLicense MITView source

What it does

This is the Regression Tests workflow from the dgunning/edgartools repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
# Regression Tests Workflow
# Runs regression tests on-demand or on schedule to catch breaking changes

name: Regression Tests

on:
  # Manual trigger
  workflow_dispatch:
  # Run weekly on Sundays
  schedule:
    - cron: '0 8 * * 0'
  # Also run on main branch pushes for critical changes
  push:
    branches: [ "main" ]
    paths:
      - 'tests/issues/regression/**'
      - 'edgar/xbrl/**'
      - 'edgar/entity/**'

# Cancel superseded regression runs on the same ref.
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  regression:
    runs-on: ubuntu-latest
    env:
      EDGAR_LOCAL_DATA_DIR: ${{ github.workspace }}/.edgar-data
    strategy:
      fail-fast: false
      matrix:
        # Single version: regression tests verify data correctness against real
        # filings, not Python compatibility (the fast job covers 3.10 + 3.13).
        python-version: ["3.12"]

    steps:
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
      with:
        python-version: ${{ matrix.python-version }}
        cache: 'pip'

    # Persist the SEC HTTP cache - regression tests fetch real filings, and
    # /Archives/edgar/data is cached forever (see CACHE_RULES), so a warm cache
    # serves them from disk instead of re-downloading.
    - name: Restore SEC HTTP cache
      uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
      with:
        path: ${{ github.workspace }}/.edgar-data/_tcache
        key: edgar-tcache-regression-${{ github.run_id }}
        restore-keys: |
          edgar-tcache-regression-

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install -e ".[ai]"
        python -m pip install pytest pytest-cov pytest-env pytest-xdist pytest-asyncio pytest-retry pytest-mock freezegun==1.5.1 filelock tqdm responses

    - name: Run regression tests
      run: |
        pytest --cov --cov-report=xml -m regression --enable-cache

    - name: Upload coverage reports
      uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
      if: matrix.python-version == '3.12'
      with:
        files: coverage.xml
        fail_ci_if_error: false
        flags: regression
        token: ${{ secrets.CODECOV_TOKEN }}

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

# Regression Tests Workflow
# Runs regression tests on-demand or on schedule to catch breaking changes
 
name: Regression Tests
 
on:
  # Manual trigger
  workflow_dispatch:
  # Run weekly on Sundays
  schedule:
    - cron: '0 8 * * 0'
  # Also run on main branch pushes for critical changes
  push:
    branches: [ "main" ]
    paths:
      - 'tests/issues/regression/**'
      - 'edgar/xbrl/**'
      - 'edgar/entity/**'
 
# Cancel superseded regression runs on the same ref.
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  regression:
    timeout-minutes: 30
    runs-on: latchkey-small
    env:
      EDGAR_LOCAL_DATA_DIR: ${{ github.workspace }}/.edgar-data
    strategy:
      fail-fast: false
      matrix:
        # Single version: regression tests verify data correctness against real
        # filings, not Python compatibility (the fast job covers 3.10 + 3.13).
        python-version: ["3.12"]
 
    steps:
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
      with:
        python-version: ${{ matrix.python-version }}
        cache: 'pip'
 
    # Persist the SEC HTTP cache - regression tests fetch real filings, and
    # /Archives/edgar/data is cached forever (see CACHE_RULES), so a warm cache
    # serves them from disk instead of re-downloading.
    - name: Restore SEC HTTP cache
      uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
      with:
        path: ${{ github.workspace }}/.edgar-data/_tcache
        key: edgar-tcache-regression-${{ github.run_id }}
        restore-keys: |
          edgar-tcache-regression-
 
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install -e ".[ai]"
        python -m pip install pytest pytest-cov pytest-env pytest-xdist pytest-asyncio pytest-retry pytest-mock freezegun==1.5.1 filelock tqdm responses
 
    - name: Run regression tests
      run: |
        pytest --cov --cov-report=xml -m regression --enable-cache
 
    - name: Upload coverage reports
      uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
      if: matrix.python-version == '3.12'
      with:
        files: coverage.xml
        fail_ci_if_error: false
        flags: regression
        token: ${{ secrets.CODECOV_TOKEN }}

What changed

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow