Skip to content

Add support for generic unions #10695

Add support for generic unions

Add support for generic unions #10695

Workflow file for this run

name: 🔂 Unit tests
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- "strawberry/**"
- "tests/**"
- "pyproject.toml"
- "poetry.lock"
- ".github/workflows/test.yml"
jobs:
generate-jobs-tests:
name: 💻 Generate test matrix
runs-on: ubuntu-latest
outputs:
sessions: ${{ steps.set-matrix.outputs.sessions }}
steps:
- uses: actions/checkout@v4
- run: pip install poetry nox nox-poetry
- id: set-matrix
shell: bash
run: |
echo sessions=$(
nox --json -t tests -l |
jq 'map(
{
session,
name: "\( .name ) on \( .python )\( if .call_spec != {} then " (\(.call_spec | to_entries | map("\(.key)=\(.value)") | join(", ")))" else "" end )"
}
)'
) | tee --append $GITHUB_OUTPUT
unit-tests:
name: 🔬 ${{ matrix.session.name }}
needs: [generate-jobs-tests]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
session: ${{ fromJson(needs.generate-jobs-tests.outputs.sessions) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
3.10
3.11
3.12
- name: Pip and nox cache
id: cache
uses: actions/cache@v4
with:
path: |
~/.cache
~/.nox
.nox
key:
${{ runner.os }}-nox-${{ matrix.session.session }}-${{
hashFiles('**/poetry.lock') }}-${{ hashFiles('**/noxfile.py') }}-3
- run: pip install poetry nox nox-poetry
- run: nox -r -t tests -s "${{ matrix.session.session }}"
- uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: coverage-${{ matrix.session.session }}
path: coverage.xml
upload-coverage:
name: 🆙 Upload Coverage
needs: [unit-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
benchmarks:
name: 📈 Benchmarks
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- run: pipx install poetry
- uses: actions/setup-python@v5
id: setup-python
with:
python-version: "3.12"
architecture: x64
cache: "poetry"
- run: poetry env use 3.12
- run: poetry install
if: steps.setup-python.outputs.cache-hit != 'true'
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: poetry run pytest tests/benchmarks --codspeed
lint:
name: ✨ Lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
3.10
3.11
3.12
- name: Pip and nox cache
id: cache
uses: actions/cache@v4
with:
path: |
~/.cache
~/.nox
.nox
key:
${{ runner.os }}-nox-lint-${{ matrix.session.session }}-${{
hashFiles('**/poetry.lock') }}-${{ hashFiles('**/noxfile.py') }}
restore-keys: |
${{ runner.os }}-lint-nox-${{ matrix.session.session }}-
${{ runner.os }}-lint-nox-
- run: pip install poetry
- run: pip install nox nox-poetry
- run: nox -r -t lint
unit-tests-on-windows:
name: 🪟 Tests on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- run: pipx install poetry
- run: pipx install coverage
- uses: actions/setup-python@v5
id: setup-python
with:
python-version: "3.11"
cache: "poetry"
- run: poetry install --with integrations
if: steps.setup-python.outputs.cache-hit != 'true'
# Since we are running all the integrations at once, we can't use
# pydantic v2. It is not compatible with starlette yet
- run: poetry run pip install pydantic==1.10
# we use poetry directly instead of nox since we want to
# test all integrations at once on windows
# but we want to exclude tests/mypy since we are using an old version of pydantic
- run: |
poetry run pytest --cov=. --cov-append --cov-report=xml -n auto --showlocals --ignore tests/mypy -vv
- name: coverage xml
run: coverage xml -i
if: ${{ always() }}
- uses: codecov/codecov-action@v4
if: ${{ always() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true