From 9a662f16c5b79c52295c30496a57732c75f74e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 20 Dec 2023 11:59:45 +0100 Subject: [PATCH 1/6] Only run test suite if code changes --- .github/workflows/test.yaml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f362e6edb9..d9d0bb089d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,10 +21,32 @@ jobs: runs-on: 'ubuntu-latest' steps: - uses: holoviz-dev/holoviz_tasks/pre-commit@v0.1a19 + changes: + name: Check for code changes + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + code: ${{ steps.filter.outputs.code }} + steps: + - uses: actions/checkout@v3 + if: github.event_name != 'pull_request' + - uses: dorny/paths-filter@v2.11.1 + id: filter + with: + filters: | + code: + - 'panel/**' + - 'examples/**' + - 'scripts/**' + - 'setup.py' + - 'pyproject.toml' + - '.github/workflows/test.yaml' unit_test_suite: name: Unit tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} - needs: [pre_commit] + needs: [pre_commit, changes] runs-on: ${{ matrix.os }} + if: needs.changes.outputs.code == 'true' strategy: fail-fast: false matrix: @@ -98,8 +120,9 @@ jobs: fail_ci_if_error: false # optional (default = false) ui_test_suite: name: UI tests on ${{ matrix.os }} with Python 3.9 - needs: [pre_commit] + needs: [pre_commit, changes] runs-on: ${{ matrix.os }} + if: needs.changes.outputs.code == 'true' strategy: fail-fast: false matrix: @@ -199,8 +222,9 @@ jobs: fail_ci_if_error: false # optional (default = false) core_test_suite: name: Core tests on Python ${{ matrix.python-version }}, ${{ matrix.os }} - needs: [pre_commit] + needs: [pre_commit, changes] runs-on: ${{ matrix.os }} + if: needs.changes.outputs.code == 'true' strategy: fail-fast: false matrix: From 60b3c70b98bd7428bb250b5f4518a1aced568e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Thu, 21 Dec 2023 11:37:40 +0100 Subject: [PATCH 2/6] Rename to setup --- .github/workflows/test.yaml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d9d0bb089d..4803a1bde9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,17 +21,18 @@ jobs: runs-on: 'ubuntu-latest' 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 }} 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: | @@ -44,9 +45,9 @@ jobs: - '.github/workflows/test.yaml' unit_test_suite: name: Unit tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} - needs: [pre_commit, changes] + needs: [pre_commit, setup] runs-on: ${{ matrix.os }} - if: needs.changes.outputs.code == 'true' + if: needs.setup.outputs.code_change == 'true' strategy: fail-fast: false matrix: @@ -120,9 +121,9 @@ jobs: fail_ci_if_error: false # optional (default = false) ui_test_suite: name: UI tests on ${{ matrix.os }} with Python 3.9 - needs: [pre_commit, changes] + needs: [pre_commit, setup] runs-on: ${{ matrix.os }} - if: needs.changes.outputs.code == 'true' + if: needs.setup.outputs.code_change == 'true' strategy: fail-fast: false matrix: @@ -222,9 +223,9 @@ jobs: fail_ci_if_error: false # optional (default = false) 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 }} - if: needs.changes.outputs.code == 'true' + if: needs.setup.outputs.code_change == 'true' strategy: fail-fast: false matrix: From 2375fd41ecd8e690d37436ef2f61e5fc09d2f69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Thu, 21 Dec 2023 18:00:39 +0100 Subject: [PATCH 3/6] Add doc change --- .github/workflows/test.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4803a1bde9..90e696d904 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -28,6 +28,7 @@ jobs: pull-requests: read outputs: code_change: ${{ steps.filter.outputs.code }} + doc_change: ${{ steps.filter.outputs.doc }} steps: - uses: actions/checkout@v3 if: github.event_name != 'pull_request' @@ -43,6 +44,8 @@ jobs: - 'setup.py' - 'pyproject.toml' - '.github/workflows/test.yaml' + doc: + - 'doc/how_to/**' unit_test_suite: name: Unit tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} needs: [pre_commit, setup] @@ -123,7 +126,7 @@ jobs: name: UI tests on ${{ matrix.os }} with Python 3.9 needs: [pre_commit, setup] runs-on: ${{ matrix.os }} - if: needs.setup.outputs.code_change == 'true' + if: needs.setup.outputs.code_change == 'true' || needs.setup.outputs.doc_change == 'true' strategy: fail-fast: false matrix: From b5d3daa79182310a095d61ae9c9fe7ee6057d0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Fri, 22 Dec 2023 08:50:03 +0100 Subject: [PATCH 4/6] Add tox.ini and doc/getting_started --- .github/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 90e696d904..ae30212341 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -43,8 +43,10 @@ jobs: - 'scripts/**' - 'setup.py' - 'pyproject.toml' + - 'tox.ini' - '.github/workflows/test.yaml' doc: + - 'doc/getting_started/**' - 'doc/how_to/**' unit_test_suite: name: Unit tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} From 501ebcd87d1362d46861aaa63c27d05a463e9988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Fri, 22 Dec 2023 08:52:02 +0100 Subject: [PATCH 5/6] Move scripts into doc section This is because it is needed for the pyodide related test --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ae30212341..aa06c52399 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -40,7 +40,6 @@ jobs: code: - 'panel/**' - 'examples/**' - - 'scripts/**' - 'setup.py' - 'pyproject.toml' - 'tox.ini' @@ -48,6 +47,7 @@ jobs: doc: - 'doc/getting_started/**' - 'doc/how_to/**' + - 'scripts/**' unit_test_suite: name: Unit tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} needs: [pre_commit, setup] From c8e3853ce1715cb043a0b3fb88c58e5a2fceb8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Tue, 26 Dec 2023 17:47:53 +0100 Subject: [PATCH 6/6] Dynamic generate unit test matrix and add cache option (#6119) * Dynamic generate unit test matrix and add cache option * Add true if inputs.cache is not set --- .github/workflows/test.yaml | 65 +++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index aa06c52399..16135a21bf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,6 +8,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 19 * * SUN' @@ -29,6 +42,7 @@ jobs: outputs: code_change: ${{ steps.filter.outputs.code }} doc_change: ${{ steps.filter.outputs.doc }} + matrix: ${{ env.MATRIX }} steps: - uses: actions/checkout@v3 if: github.event_name != 'pull_request' @@ -48,6 +62,46 @@ jobs: - 'doc/getting_started/**' - 'doc/how_to/**' - 'scripts/**' + - 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 ${{ matrix.os }} with Python ${{ matrix.python-version }} needs: [pre_commit, setup] @@ -55,10 +109,7 @@ jobs: if: needs.setup.outputs.code_change == 'true' 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.9", "3.10", "3.11"]') || fromJSON('["3.9", "3.11"]') }} + matrix: ${{ fromJson(needs.setup.outputs.matrix) }} timeout-minutes: 90 defaults: run: @@ -84,7 +135,7 @@ jobs: conda-update: true nodejs: true envs: -o examples -o recommended -o tests -o build - cache: true + cache: ${{ github.event.inputs.cache || github.event.inputs.cache == '' }} opengl: true id: install - name: doit develop_install @@ -173,7 +224,7 @@ jobs: python-version: 3.9 channels: pyviz/label/dev,bokeh,conda-forge,nodefaults envs: "-o recommended -o tests -o build" - cache: true + cache: ${{ github.event.inputs.cache || github.event.inputs.cache == '' }} nodejs: true playwright: true id: install @@ -253,7 +304,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