Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic generate unit test matrix and add cache option #6043

Merged
merged 10 commits into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 82 additions & 32 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ on:
branches:
- "*"
workflow_dispatch:
inputs:
target:
description: "How much of the test suite to run"
type: choice
default: default
options:
- default
- full
- downstream
cache:
description: "Use cache"
type: boolean
default: true

schedule:
- cron: "0 14 * * SUN"

Expand Down Expand Up @@ -38,17 +52,19 @@ jobs:
steps:
- uses: holoviz-dev/holoviz_tasks/pre-commit@v0.1a19

changes:
name: Check for code changes
setup:
name: Setup workflow
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
code: ${{ steps.filter.outputs.code }}
code_change: ${{ steps.filter.outputs.code }}
matrix: ${{ env.MATRIX }}
steps:
- uses: actions/checkout@v3
if: github.event_name != 'pull_request'
- uses: dorny/paths-filter@v2.11.1
- name: Check for code changes
uses: dorny/paths-filter@v2.11.1
id: filter
with:
filters: |
Expand All @@ -58,59 +74,93 @@ jobs:
- 'setup.py'
- 'pyproject.toml'
- '.github/workflows/test.yaml'
- name: Set matrix option
run: |
if [[ '${{ github.event_name }}' == 'workflow_dispatch' ]]; then
OPTION=${{ github.event.inputs.target }}
elif [[ '${{ github.event_name }}' == 'schedule' ]]; then
OPTION="full"
elif [[ '${{ github.event_name }}' == 'push' && '${{ github.ref_type }}' == 'tag' ]]; then
OPTION="full"
else
OPTION="default"
fi
echo "MATRIX_OPTION=$OPTION" >> $GITHUB_ENV
- name: Set test matrix with 'default' option
if: env.MATRIX_OPTION == 'default'
run: |
MATRIX=$(jq -nsc '{
"os": ["ubuntu-latest", "macos-latest", "windows-latest"],
"python-version": ["3.9", "3.11"],
"include": [
{"os": "ubuntu-latest", "python-version": "3.10"}
]
}')
echo "MATRIX=$MATRIX" >> $GITHUB_ENV
- name: Set test matrix with 'full' option
if: env.MATRIX_OPTION == 'full'
run: |
MATRIX=$(jq -nsc '{
"os": ["ubuntu-latest", "macos-latest", "windows-latest"],
"python-version": ["3.9", "3.10", "3.11"]
}')
echo "MATRIX=$MATRIX" >> $GITHUB_ENV
- name: Set test matrix with 'downstream' option
if: env.MATRIX_OPTION == 'downstream'
run: |
MATRIX=$(jq -nsc '{
"os": ["ubuntu-latest"],
"python-version": ["3.11"]
}')
echo "MATRIX=$MATRIX" >> $GITHUB_ENV

unit_test_suite:
name: Unit tests on Python ${{ matrix.python-version }}, ${{ matrix.os }}
needs: [pre_commit, changes]
needs: [pre_commit, setup]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.9", "3.11"]
include:
- os: "ubuntu-latest"
python-version: "3.10"
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
timeout-minutes: 120
env:
DESC: "Python ${{ matrix.python-version }}, ${{ matrix.os }} unit tests"
PYTHON_VERSION: ${{ matrix.python-version }}
steps:
- uses: holoviz-dev/holoviz_tasks/install@v0.1a19
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
with:
name: unit_test_suite
python-version: ${{ matrix.python-version }}
channel-priority: strict
channels: pyviz/label/dev,conda-forge,nodefaults
envs: "-o flakes -o tests -o examples_tests -o tests_ci"
cache: true
cache: ${{ github.event.inputs.cache }}
conda-update: true
id: install
- name: bokeh sampledata
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
run: |
conda activate test-environment
bokeh sampledata
- name: doit test_unit
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
run: |
conda activate test-environment
doit test_unit
- name: test examples
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
run: |
conda activate test-environment
doit test_examples
- name: codecov
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
run: |
conda activate test-environment
codecov

ui_test_suite:
name: UI tests on Python ${{ matrix.python-version }}, ${{ matrix.os }}
needs: [pre_commit, changes]
needs: [pre_commit, setup]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -127,22 +177,22 @@ jobs:
PYCTDEV_SELF_CHANNEL: "pyviz/label/dev"
steps:
- uses: holoviz-dev/holoviz_tasks/install@v0.1a19
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
with:
name: ui_test_suite
python-version: ${{ matrix.python-version }}
channels: pyviz/label/dev,bokeh,conda-forge,nodefaults
envs: "-o recommended -o tests -o build -o tests_ci"
cache: true
cache: ${{ github.event.inputs.cache }}
playwright: true
id: install
- name: doit test_ui
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
run: |
conda activate test-environment
doit test_ui
- name: Upload coverage to Codecov
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
Expand All @@ -151,7 +201,7 @@ jobs:

core_test_suite:
name: Core tests on Python ${{ matrix.python-version }}, ${{ matrix.os }}
needs: [pre_commit, changes]
needs: [pre_commit, setup]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -165,43 +215,43 @@ jobs:
steps:
# Add back when this works on Python 3.12
# - uses: holoviz-dev/holoviz_tasks/install@v0.1a19
# if: needs.changes.outputs.code == 'true'
# if: needs.setup.outputs.code_change == 'true'
# with:
# name: core_test_suite
# python-version: ${{ matrix.python-version }}
# # channel-priority: strict
# channels: pyviz/label/dev,conda-forge,nodefaults
# envs: "-o tests_core -o tests_ci"
# cache: true
# cache: ${{ github.event.inputs.cache }}
# conda-update: true
# id: install
- uses: actions/checkout@v3
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
with:
fetch-depth: "100"
- name: Fetch unshallow
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
run: git fetch --prune --tags --unshallow -f
- uses: actions/setup-python@v4
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
with:
python-version: 3.12
- name: install
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
run: |
python -m pip install -ve '.[tests_core, tests_ci]'
- name: bokeh sampledata
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
run: |
# conda activate test-environment
bokeh sampledata
- name: Check packages latest version
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
run: |
# conda activate test-environment
python scripts/check_latest_packages.py
- name: doit test_unit
if: needs.changes.outputs.code == 'true'
if: needs.setup.outputs.code_change == 'true'
run: |
# conda activate test-environment
pytest holoviews