From 05ef4f1afc7078f292e656f3ac3eecaa400e76a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Mon, 14 Oct 2024 09:42:51 +0200 Subject: [PATCH] Update test.yaml --- .github/workflows/test.yaml | 148 +++++++++++++++++++++++++----------- pixi.toml | 1 + 2 files changed, 103 insertions(+), 46 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 11d11161..47e43843 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -14,63 +14,119 @@ 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 }} + 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/action@v3.0.0 + 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 }} 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 diff --git a/pixi.toml b/pixi.toml index 85f1062b..ad87e181 100644 --- a/pixi.toml +++ b/pixi.toml @@ -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"]