Skip to content

Commit

Permalink
Update test.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Oct 14, 2024
1 parent 7b4271b commit fc1351a
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 46 deletions.
150 changes: 104 additions & 46 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,63 +14,121 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash -e {0}

env:
DISPLAY: ":99.0"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COV: "--cov=./param --cov-report=xml"

jobs:
pre_commit:
name: Run pre-commit hooks
name: Run pre-commit
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: holoviz-dev/holoviz_tasks/pre-commit@v0

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"],
"environment": ["test-39", "test-312", "test-313"]
}')
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"],
"environment": ["test-39", "test-310", "test-311", "test-312", "test-313"]
}')
echo "MATRIX=$MATRIX" >> $GITHUB_ENV
- name: Set test matrix with 'downstream' option
if: env.MATRIX_OPTION == 'downstream'
run: |
MATRIX=$(jq -nsc '{
"os": ["ubuntu-latest"],
"environment": ["test-312"]
}')
echo "MATRIX=$MATRIX" >> $GITHUB_ENV
pixi_lock:
name: Pixi lock
runs-on: ubuntu-latest
steps:
- uses: holoviz-dev/holoviz_tasks/pixi_lock@v0
with:
cache: ${{ github.event.inputs.cache == 'true' || github.event.inputs.cache == '' }}

unit_test_suite:
name: unit:${{ matrix.environment }}:${{ matrix.os }}
needs: [pre_commit, pixi_lock]
runs-on: ${{ matrix.os }}
if: needs.setup.outputs.code_change == 'true'
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
timeout-minutes: 30
steps:
- uses: holoviz-dev/holoviz_tasks/pixi_install@v0
with:
fetch-depth: "1"
- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v4
environments: ${{ matrix.environment }}
- name: Test Unit
run: |
pixi run -e ${{ matrix.environment }} test-unit $COV
- name: Test Examples
run: |
pixi run -e ${{ matrix.environment }} test-example
- uses: codecov/codecov-action@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: pre-commit
uses: pre-commit/[email protected]
token: ${{ secrets.CODECOV_TOKEN }}

test_suite:
name: Test ${{ matrix.python-version }}, ${{ matrix.platform }}
needs: [pre_commit]
runs-on: ${{ matrix.platform }}
core_test_suite:
name: core:${{ matrix.environment }}:${{ matrix.os }}
needs: [pre_commit, pixi_lock]
runs-on: ${{ matrix.os }}
if: needs.setup.outputs.code_change == 'true'
strategy:
fail-fast: false
matrix:
platform: ["ubuntu-latest", "windows-latest", "macos-latest"]
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", "3.12", "pypy3.9"]') || fromJSON('["3.8", "3.10", "3.12"]') }}
os: ["ubuntu-latest"]
environment: ["test-core", "test-pypy"]
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "100"
- name: Fetch unshallow
run: git fetch --prune --tags --unshallow -f
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: holoviz-dev/holoviz_tasks/pixi_install@v0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: env setup
environments: ${{ matrix.environment }}
- name: Test Unit
run: |
python -m pip install --upgrade pip
python -m pip install hatch
- name: temp patch pip for blosc2
if: contains(matrix.platform, 'ubuntu') && matrix.python-version == '3.8'
run: echo "PIP_ONLY_BINARY=blosc2" >> $GITHUB_ENV
- name: run unit tests
run: hatch -v run +py=${{ matrix.python-version }} tests:with_coverage
- name: run examples tests
# A notebook fails on Windows (UNIX path used in an example)
# No need to run these tests for PyPy really
if: contains(matrix.platform, 'ubuntu') && !startsWith(matrix.python-version, 'py')
run: hatch -v run +py=${{ matrix.python-version }} tests_examples:examples
- name: Upload coverage reports to Codecov
if: github.event_name == 'push' || github.event_name == 'pull_request'
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
verbose: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
pixi run -e ${{ matrix.environment }} test-unit
result_test_suite:
name: result:test
needs: [unit_test_suite, core_test_suite]
if: always()
runs-on: ubuntu-latest
steps:
- name: check for failures
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: echo job failed && exit 1
1 change: 1 addition & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test-310 = ["py310", "test-core", "test", "example", "test-example"]
test-311 = ["py311", "test-core", "test", "example", "test-example"]
test-312 = ["py312", "test-core", "test", "example", "test-example"]
test-313 = ["py313", "test-core", "test-313", "example", "test-example"]
test-core = ["py313", "test-core"]
test-pypy = ["pypy", "test-core", "test-pypy"]
docs = ["py311", "example", "doc"]
build = ["py311", "build"]
Expand Down

0 comments on commit fc1351a

Please sign in to comment.