From 8db82b9ae30dbcd30e9efd57ce88756a4b2792ef Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Fri, 13 Jan 2023 15:23:32 +0000 Subject: [PATCH 1/2] chore: PRs gha are now smaller. Requesting a review triggers all the tests --- .github/workflows/develop_install.yml | 2 ++ .github/workflows/end_to_end.yml | 1 + .github/workflows/examples_pytest.yml | 1 + .github/workflows/finn_integration.yml | 3 ++- .github/workflows/gen_github_actions.py | 13 +++++++++++++ .github/workflows/notebook.yml | 1 + .github/workflows/ort_integration.yml | 1 + .github/workflows/pytest.yml | 1 + 8 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/develop_install.yml b/.github/workflows/develop_install.yml index 7c97065c9..ed0e55517 100644 --- a/.github/workflows/develop_install.yml +++ b/.github/workflows/develop_install.yml @@ -46,10 +46,12 @@ jobs: if: startsWith(runner.os, 'macOS') == true - name: Run Nox session for testing brevitas develop install and imports + if: ${{ (contains(fromJson('["1.5.1", "1.10.1", "1.13.0"]'), matrix.pytorch_version ) && github.event_name == 'pull_request' && matrix.platform == 'ubuntu-latest' ) || (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && github.event.action == 'review_requested')}} shell: bash run: nox -v -s tests_brevitas_install_dev-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\) - name: Run Nox session for testing brevitas_examples develop install and imports + if: ${{ (contains(fromJson('["1.5.1", "1.10.1", "1.13.0"]'), matrix.pytorch_version ) && github.event_name == 'pull_request' && matrix.platform == 'ubuntu-latest' ) || (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && github.event.action == 'review_requested')}} shell: bash run: nox -v -s tests_brevitas_examples_install_dev-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\) diff --git a/.github/workflows/end_to_end.yml b/.github/workflows/end_to_end.yml index 8862997e6..9c173e8c5 100644 --- a/.github/workflows/end_to_end.yml +++ b/.github/workflows/end_to_end.yml @@ -50,6 +50,7 @@ jobs: if: startsWith(runner.os, 'macOS') == true - name: Run Nox session for end-to-end flows + if: ${{ (contains(fromJson('["1.5.1", "1.10.1", "1.13.0"]'), matrix.pytorch_version ) && github.event_name == 'pull_request' && matrix.platform == 'ubuntu-latest' ) || (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && github.event.action == 'review_requested')}} shell: bash run: nox -v -s tests_brevitas_end_to_end-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\) diff --git a/.github/workflows/examples_pytest.yml b/.github/workflows/examples_pytest.yml index 19a0d8239..bfe29c3eb 100644 --- a/.github/workflows/examples_pytest.yml +++ b/.github/workflows/examples_pytest.yml @@ -47,6 +47,7 @@ jobs: if: startsWith(runner.os, 'macOS') == true - name: Run Nox session for brevitas_examples pytest + if: ${{ (contains(fromJson('["1.5.1", "1.10.1", "1.13.0"]'), matrix.pytorch_version ) && github.event_name == 'pull_request' && matrix.platform == 'ubuntu-latest' ) || (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && github.event.action == 'review_requested')}} shell: bash run: nox -v -s tests_brevitas_examples_cpu-${{ matrix.python_version }}\(${{ matrix.jit_status }}\,\ pytorch_${{ matrix.pytorch_version }}\) diff --git a/.github/workflows/finn_integration.yml b/.github/workflows/finn_integration.yml index c86224f62..4c06d43d8 100644 --- a/.github/workflows/finn_integration.yml +++ b/.github/workflows/finn_integration.yml @@ -46,11 +46,12 @@ jobs: if: startsWith(runner.os, 'macOS') == true - name: Install protobuf on Ubuntu + if: startsWith(runner.os, 'Linux') == true shell: bash run: sudo apt-get install protobuf-compiler libprotoc-dev - if: startsWith(runner.os, 'Linux') == true - name: Run Nox session for Brevitas-FINN integration + if: ${{ (contains(fromJson('["1.5.1", "1.10.1", "1.13.0"]'), matrix.pytorch_version ) && github.event_name == 'pull_request' && matrix.platform == 'ubuntu-latest' ) || (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && github.event.action == 'review_requested')}} shell: bash run: nox -v -s tests_brevitas_finn_integration-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\) diff --git a/.github/workflows/gen_github_actions.py b/.github/workflows/gen_github_actions.py index 3d2f528f1..58466f778 100644 --- a/.github/workflows/gen_github_actions.py +++ b/.github/workflows/gen_github_actions.py @@ -12,10 +12,13 @@ NOTEBOOK_YML = 'notebook.yml' ENDTOEND_YML = 'end_to_end.yml' +# Reduced Test for PRs, except when a review is requested +CONDITION= "${{ (contains(fromJson(\'[%PYTORCH_LIST_REDUCED]\'), matrix.pytorch_version ) && github.event_name == \'pull_request\' && matrix.platform == 'ubuntu-latest' ) || (github.event_name != \'pull_request\') || (github.event_name == \'pull_request\' && github.event.action == \'review_requested\')}} " # Data shared betwen Nox sessions and Github Actions, formatted as tuples PYTHON_VERSIONS = ('3.7', '3.8') PYTORCH_VERSIONS = ('1.5.1', '1.6.0', '1.7.1', '1.8.1', '1.9.1', '1.10.1', '1.11.0', '1.12.1', '1.13.0') +PYTORCH_LIST_REDUCED = ["1.5.1", "1.10.1", "1.13.0"] JIT_STATUSES = ('jit_disabled',) # Data used only by Github Actions, formatted as lists or lists of ordered dicts @@ -47,6 +50,7 @@ PYTEST_STEP_LIST = [ od([ ('name', 'Run Nox session for brevitas pytest'), + ('if', CONDITION.replace('%PYTORCH_LIST_REDUCED', ', '.join(f'"{version}"' for version in PYTORCH_LIST_REDUCED) )), ('shell', 'bash'), ('run', 'nox -v -s tests_brevitas_cpu-${{ matrix.python_version }}\(${{ matrix.jit_status }}\,\ pytorch_${{ matrix.pytorch_version }}\)')]), @@ -55,6 +59,7 @@ EXAMPLES_PYTEST_STEP_LIST = [ od([ ('name', 'Run Nox session for brevitas_examples pytest'), + ('if', CONDITION.replace('%PYTORCH_LIST_REDUCED', ', '.join(f'"{version}"' for version in PYTORCH_LIST_REDUCED) )), ('shell', 'bash'), ('run', 'nox -v -s tests_brevitas_examples_cpu-${{ matrix.python_version }}\(${{ matrix.jit_status }}\,\ pytorch_${{ matrix.pytorch_version }}\)')]), @@ -63,6 +68,7 @@ FINN_INTEGRATION_STEP_LIST = [ od([ ('name', 'Install protobuf on Ubuntu'), + ('if', CONDITION.replace('%PYTORCH_LIST_REDUCED', ', '.join(f'"{version}"' for version in PYTORCH_LIST_REDUCED) )), ('shell', 'bash'), ('run', 'sudo apt-get install protobuf-compiler libprotoc-dev'), @@ -70,6 +76,7 @@ ]), od([ ('name', 'Run Nox session for Brevitas-FINN integration'), + ('if', CONDITION.replace('%PYTORCH_LIST_REDUCED', ', '.join(f'"{version}"' for version in PYTORCH_LIST_REDUCED) )), ('shell', 'bash'), ('run', 'nox -v -s tests_brevitas_finn_integration-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\)') @@ -78,6 +85,7 @@ PYXIR_INTEGRATION_STEP_LIST = [ od([ ('name', 'Run Nox session for Brevitas-PyXIR integration'), + ('if', CONDITION.replace('%PYTORCH_LIST_REDUCED', ', '.join(f'"{version}"' for version in PYTORCH_LIST_REDUCED) )), ('shell', 'bash'), ('run', 'nox -v -s tests_brevitas_pyxir_integration-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\)') @@ -86,6 +94,7 @@ ORT_INTEGRATION_STEP_LIST = [ od([ ('name', 'Run Nox session for Brevitas-ORT integration'), + ('if', CONDITION.replace('%PYTORCH_LIST_REDUCED', ', '.join(f'"{version}"' for version in PYTORCH_LIST_REDUCED) )), ('shell', 'bash'), ('run', 'nox -v -s tests_brevitas_ort_integration-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\)') @@ -94,11 +103,13 @@ TEST_INSTALL_DEV_STEP_LIST = [ od([ ('name', 'Run Nox session for testing brevitas develop install and imports'), + ('if', CONDITION.replace('%PYTORCH_LIST_REDUCED', ', '.join(f'"{version}"' for version in PYTORCH_LIST_REDUCED) )), ('shell', 'bash'), ('run', 'nox -v -s tests_brevitas_install_dev-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\)')]), od([ ('name', 'Run Nox session for testing brevitas_examples develop install and imports'), + ('if', CONDITION.replace('%PYTORCH_LIST_REDUCED', ', '.join(f'"{version}"' for version in PYTORCH_LIST_REDUCED) )), ('shell', 'bash'), ('run', 'nox -v -s tests_brevitas_examples_install_dev-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\)') @@ -107,6 +118,7 @@ NOTEBOOK_STEP_LIST = [ od([ ('name', 'Run Nox session for Notebook execution'), + ('if', CONDITION.replace('%PYTORCH_LIST_REDUCED', ', '.join(f'"{version}"' for version in PYTORCH_LIST_REDUCED) )), ('shell', 'bash'), ('run', 'nox -v -s tests_brevitas_notebook-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\)') @@ -115,6 +127,7 @@ ENDTOEND_STEP_LIST = [ od([ ('name', 'Run Nox session for end-to-end flows'), + ('if', CONDITION.replace('%PYTORCH_LIST_REDUCED', ', '.join(f'"{version}"' for version in PYTORCH_LIST_REDUCED) )), ('shell', 'bash'), ('run', 'nox -v -s tests_brevitas_end_to_end-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\)') diff --git a/.github/workflows/notebook.yml b/.github/workflows/notebook.yml index cf3928091..3a32b32e5 100644 --- a/.github/workflows/notebook.yml +++ b/.github/workflows/notebook.yml @@ -53,6 +53,7 @@ jobs: if: startsWith(runner.os, 'macOS') == true - name: Run Nox session for Notebook execution + if: ${{ (contains(fromJson('["1.5.1", "1.10.1", "1.13.0"]'), matrix.pytorch_version ) && github.event_name == 'pull_request' && matrix.platform == 'ubuntu-latest' ) || (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && github.event.action == 'review_requested')}} shell: bash run: nox -v -s tests_brevitas_notebook-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\) diff --git a/.github/workflows/ort_integration.yml b/.github/workflows/ort_integration.yml index a78f59ca4..ad5bcae1d 100644 --- a/.github/workflows/ort_integration.yml +++ b/.github/workflows/ort_integration.yml @@ -46,6 +46,7 @@ jobs: if: startsWith(runner.os, 'macOS') == true - name: Run Nox session for Brevitas-ORT integration + if: ${{ (contains(fromJson('["1.5.1", "1.10.1", "1.13.0"]'), matrix.pytorch_version ) && github.event_name == 'pull_request' && matrix.platform == 'ubuntu-latest' ) || (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && github.event.action == 'review_requested')}} shell: bash run: nox -v -s tests_brevitas_ort_integration-${{ matrix.python_version }}\(\pytorch_${{ matrix.pytorch_version }}\) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b024039dd..b62d577f6 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -47,6 +47,7 @@ jobs: if: startsWith(runner.os, 'macOS') == true - name: Run Nox session for brevitas pytest + if: ${{ (contains(fromJson('["1.5.1", "1.10.1", "1.13.0"]'), matrix.pytorch_version ) && github.event_name == 'pull_request' && matrix.platform == 'ubuntu-latest' ) || (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && github.event.action == 'review_requested')}} shell: bash run: nox -v -s tests_brevitas_cpu-${{ matrix.python_version }}\(${{ matrix.jit_status }}\,\ pytorch_${{ matrix.pytorch_version }}\) From 06356733a9995544c3b2b583da43e4caddff5fe7 Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Fri, 13 Jan 2023 15:28:03 +0000 Subject: [PATCH 2/2] fix: do not execute any gha on drafts --- .github/workflows/base.yml.template | 8 +++++++- .github/workflows/develop_install.yml | 8 +++++++- .github/workflows/end_to_end.yml | 8 +++++++- .github/workflows/examples_pytest.yml | 8 +++++++- .github/workflows/finn_integration.yml | 8 +++++++- .github/workflows/notebook.yml | 8 +++++++- .github/workflows/ort_integration.yml | 8 +++++++- .github/workflows/pytest.yml | 8 +++++++- 8 files changed, 56 insertions(+), 8 deletions(-) diff --git a/.github/workflows/base.yml.template b/.github/workflows/base.yml.template index 8f3757baf..66ea0db84 100644 --- a/.github/workflows/base.yml.template +++ b/.github/workflows/base.yml.template @@ -4,17 +4,23 @@ on: push: branches: [ master, dev ] pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + - review_requested jobs: build: runs-on: ${{ matrix.platform }} - strategy: &{strategy} matrix: &{matrix} &{exclude} + if: ${{ !github.event.pull_request.draft }} steps: - name: Checkout repo diff --git a/.github/workflows/develop_install.yml b/.github/workflows/develop_install.yml index ed0e55517..96af48c87 100644 --- a/.github/workflows/develop_install.yml +++ b/.github/workflows/develop_install.yml @@ -4,11 +4,16 @@ on: push: branches: [ master, dev ] pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + - review_requested jobs: build: runs-on: ${{ matrix.platform }} - strategy: fail-fast: false @@ -21,6 +26,7 @@ jobs: + if: ${{ !github.event.pull_request.draft }} steps: - name: Checkout repo diff --git a/.github/workflows/end_to_end.yml b/.github/workflows/end_to_end.yml index 9c173e8c5..84d431d87 100644 --- a/.github/workflows/end_to_end.yml +++ b/.github/workflows/end_to_end.yml @@ -4,11 +4,16 @@ on: push: branches: [ master, dev ] pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + - review_requested jobs: build: runs-on: ${{ matrix.platform }} - strategy: fail-fast: false max-parallel: 4 @@ -25,6 +30,7 @@ jobs: + if: ${{ !github.event.pull_request.draft }} steps: - name: Checkout repo diff --git a/.github/workflows/examples_pytest.yml b/.github/workflows/examples_pytest.yml index bfe29c3eb..88076f915 100644 --- a/.github/workflows/examples_pytest.yml +++ b/.github/workflows/examples_pytest.yml @@ -4,11 +4,16 @@ on: push: branches: [ master, dev ] pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + - review_requested jobs: build: runs-on: ${{ matrix.platform }} - strategy: fail-fast: false @@ -22,6 +27,7 @@ jobs: + if: ${{ !github.event.pull_request.draft }} steps: - name: Checkout repo diff --git a/.github/workflows/finn_integration.yml b/.github/workflows/finn_integration.yml index 4c06d43d8..f2cadaeee 100644 --- a/.github/workflows/finn_integration.yml +++ b/.github/workflows/finn_integration.yml @@ -4,11 +4,16 @@ on: push: branches: [ master, dev ] pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + - review_requested jobs: build: runs-on: ${{ matrix.platform }} - strategy: fail-fast: false @@ -21,6 +26,7 @@ jobs: + if: ${{ !github.event.pull_request.draft }} steps: - name: Checkout repo diff --git a/.github/workflows/notebook.yml b/.github/workflows/notebook.yml index 3a32b32e5..aacea7c40 100644 --- a/.github/workflows/notebook.yml +++ b/.github/workflows/notebook.yml @@ -4,11 +4,16 @@ on: push: branches: [ master, dev ] pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + - review_requested jobs: build: runs-on: ${{ matrix.platform }} - strategy: fail-fast: false @@ -28,6 +33,7 @@ jobs: + if: ${{ !github.event.pull_request.draft }} steps: - name: Checkout repo diff --git a/.github/workflows/ort_integration.yml b/.github/workflows/ort_integration.yml index ad5bcae1d..e15798236 100644 --- a/.github/workflows/ort_integration.yml +++ b/.github/workflows/ort_integration.yml @@ -4,11 +4,16 @@ on: push: branches: [ master, dev ] pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + - review_requested jobs: build: runs-on: ${{ matrix.platform }} - strategy: fail-fast: false @@ -21,6 +26,7 @@ jobs: + if: ${{ !github.event.pull_request.draft }} steps: - name: Checkout repo diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b62d577f6..311671ad5 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -4,11 +4,16 @@ on: push: branches: [ master, dev ] pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + - review_requested jobs: build: runs-on: ${{ matrix.platform }} - strategy: fail-fast: false @@ -22,6 +27,7 @@ jobs: + if: ${{ !github.event.pull_request.draft }} steps: - name: Checkout repo