Skip to content

fix: Add CI-specific test handling to reduce rate limit failures #85

fix: Add CI-specific test handling to reduce rate limit failures

fix: Add CI-specific test handling to reduce rate limit failures #85

Workflow file for this run

# inspired by https://jacobian.org/til/github-actions-poetry/
on:
push:
branches: [main]
pull_request:
env:
POETRY_VERSION: 1.8.3
ALPACA_API_KEY: ${{ secrets.ALPACA_API_KEY }}
ALPACA_SECRET_KEY: ${{ secrets.ALPACA_SECRET_KEY }}
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1 # Run sequentially to avoid rate limiting
fail-fast: false
matrix:
python-version: ["3.12"]
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python
run: uv python install
- name: Install the project
run: uv sync --all-extras --dev
- name: Run tests
# For example, using `pytest`
run: uv run pytest tests
# env:
# POETRY_VIRTUALENVS_IN_PROJECT: true
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
# # Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
# # from installing Poetry every time, which can be slow. Note the use of the Poetry version
# # number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
# # manually if/when you want to upgrade Poetry, or if something goes wrong.
# - name: cache poetry install
# uses: actions/cache@v4
# with:
# path: ~/.local
# key: poetry-cache-${{ runner.os }}-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}
# # Install Poetry. You could do this manually, or there are several actions that do this.
# # `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
# # Poetry's default install script, which feels correct. I pin the Poetry version here
# # because Poetry does occasionally change APIs between versions and I don't want my
# # actions to break if it does.
# #
# # The key configuration value here is `virtualenvs-in-project: true`: this creates the
# # venv as a `.venv` in your testing directory, which allows the next step to easily
# # cache it.
# - uses: snok/install-poetry@v1
# with:
# version: 1.8.3
# virtualenvs-create: true
# virtualenvs-in-project: true
# # Cache your dependencies (i.e. all the stuff in your `pyproject.toml`)
# - name: cache venv
# uses: actions/cache@v4
# with:
# path: .venv
# key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
# - run: poetry install --no-interaction --no-root
# if: steps.cache-deps.outputs.cache-hit != 'true'
# - run: poetry install --no-interaction
# - run: poetry run ruff check --fix
# - run: poetry run pytest