Skip to content

Bump actions/setup-python from 5 to 6 #45

Bump actions/setup-python from 5 to 6

Bump actions/setup-python from 5 to 6 #45

Workflow file for this run

name: Parallel (file)
on:
push:
schedule:
- cron: "0 0 1 * *" # Midnight every month (UTC)
workflow_dispatch:
jobs:
collect:
name: Collect
runs-on: ubuntu-latest
outputs:
groups: "${{ steps.build.outputs.TEST_GROUPS }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v6
with:
python-version-file: .python-version
cache: pip
- name: Show python version
run: python --version && pip --version
- name: Install python dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install --requirement requirements.txt
- name: Collect tests
run: |
pytest --collect-only --quiet | tee collected.tmp
echo '::group::Delete the last two lines'
sed -e '$d' collected.tmp | sed -e '$d' | tee collected.txt
echo '::endgroup::'
- name: Build test matrix
id: build
shell: python
run: |
from os import environ
# For each test, get its file name. Use a set to avoid duplication.
with open("collected.txt", encoding="utf-8") as lines:
paths = sorted({line.partition("::")[0] for line in lines})
# As a precaution, quote each path in case it has spaces.
paths = [f"'{path}'" for path in paths]
max_size = 3 # Max files per group
test_groups = {"include": []}
# Slice the list of paths into sublists, and concat
# it into a single space-separated string.
for i, j in enumerate(range(0, len(paths), max_size), start=1):
sublist = paths[j : j + max_size]
test_groups["include"].append({"name": f"Group {i}", "paths": " ".join(sublist)})
print(f"::notice ::Groups: {test_groups}")
with open(environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as f:
print(f"TEST_GROUPS={test_groups}", file=f)
test:
name: Test ${{ matrix.name }}
runs-on: ubuntu-latest
needs: collect
strategy:
matrix: ${{ fromJSON(needs.collect.outputs.groups) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v6
with:
python-version-file: .python-version
cache: pip
- name: Show python version
run: python --version && pip --version
- name: Install python dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install --requirement requirements.txt
- name: Run test
# Don't quote the matrix argument because it causes the shell
# to treat the entire list of paths as a single argument.
run: pytest ${{ matrix.paths }}