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 #1235

Merged
merged 3 commits into from
Jan 28, 2024
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
69 changes: 61 additions & 8 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ 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 15 * * SUN'

Expand All @@ -20,16 +33,56 @@ jobs:
runs-on: 'ubuntu-latest'
steps:
- uses: holoviz-dev/holoviz_tasks/pre-commit@v0.1a17
setup:
name: Setup workflow
runs-on: ubuntu-latest
outputs:
matrix: ${{ env.MATRIX }}
steps:
- 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.8", "3.11"]
}')
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.8", "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

test_suite:
name: Pytest on ${{ matrix.os }} with Python ${{ matrix.python-version }}
needs: [pre_commit]
needs: [pre_commit, setup]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
# Run on the full set on schedule, workflow_dispatch and push&tags events, otherwise on a subset.
python-version: ${{ ( github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'push' && github.ref_type == 'tag' ) ) && fromJSON('["3.8", "3.9", "3.10", "3.11"]') || fromJSON('["3.8", "3.11"]') }}
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
timeout-minutes: 90
defaults:
run:
Expand All @@ -42,7 +95,7 @@ jobs:
channel-priority: strict
channels: pyviz/label/dev,conda-forge,nodefaults
envs: "-o examples_tests -o tests -o examples_conda"
cache: true
cache: ${{ github.event.inputs.cache || github.event.inputs.cache == '' }}
conda-update: true
id: install
- name: doit test_unit
Expand All @@ -60,7 +113,7 @@ jobs:
codecov
core_test_suite:
name: Core tests on Python ${{ matrix.python-version }}, ${{ matrix.os }}
needs: [pre_commit]
needs: [pre_commit, setup]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -83,7 +136,7 @@ jobs:
# # channel-priority: strict
# channels: pyviz/label/dev,conda-forge,nodefaults
# envs: "-o tests_core -o tests_ci"
# cache: true
# cache: ${{ github.event.inputs.cache || github.event.inputs.cache == '' }}
# conda-update: true
# id: install
- uses: actions/checkout@v3
Expand Down