From 175bfda22f417f2dcb482d94a8b9a1bff73895a7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 1 Aug 2026 14:53:43 +1000 Subject: [PATCH] Demo ci check (#12530) * Remove branch checking in workflow files * Detect demo branch based on software version * Fix typo --- .github/workflows/frontend.yaml | 8 ++------ .github/workflows/import_export.yaml | 6 +----- tasks.py | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/frontend.yaml b/.github/workflows/frontend.yaml index 4054876f08..a7b5a704e2 100644 --- a/.github/workflows/frontend.yaml +++ b/.github/workflows/frontend.yaml @@ -33,10 +33,6 @@ env: INVENTREE_BACKUP_DIR: /home/runner/work/InvenTree/test_inventree_backup INVENTREE_SITE_URL: http://localhost:8000 - # Use the same-named branch of the demo dataset as the target branch of this build, - # so that stable branches are not broken by changes to the demo dataset on main - DEMO_DATASET_BRANCH: ${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }} - permissions: contents: read @@ -140,7 +136,7 @@ jobs: pip-dependency: psycopg2 - name: Set up test data run: | - invoke dev.setup-test -iv --branch "$DEMO_DATASET_BRANCH" + invoke dev.setup-test -iv invoke int.rebuild-thumbnails - name: Install dependencies run: invoke int.frontend-compile --extract @@ -222,7 +218,7 @@ jobs: pip-dependency: psycopg2 - name: Set up test data run: | - invoke dev.setup-test -iv --branch "$DEMO_DATASET_BRANCH" + invoke dev.setup-test -iv invoke int.rebuild-thumbnails - name: Install dependencies run: invoke int.frontend-compile --extract diff --git a/.github/workflows/import_export.yaml b/.github/workflows/import_export.yaml index aec8bc6c8c..80a079221a 100644 --- a/.github/workflows/import_export.yaml +++ b/.github/workflows/import_export.yaml @@ -40,10 +40,6 @@ env: INVENTREE_DB_HOST: "127.0.0.1" INVENTREE_DB_PORT: 5432 - # Use the same-named branch of the demo dataset as the target branch of this build, - # so that stable branches are not broken by changes to the demo dataset on main - DEMO_DATASET_BRANCH: ${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }} - jobs: paths-filter: @@ -94,7 +90,7 @@ jobs: - name: Setup Postgres Database run: | invoke migrate - invoke dev.setup-test -i --branch "$DEMO_DATASET_BRANCH" + invoke dev.setup-test -i - name: Create Plugin Data run: | pip install -U inventree-dummy-app-plugin==0.1.0 diff --git a/tasks.py b/tasks.py index d17faad39d..6de02575f9 100644 --- a/tasks.py +++ b/tasks.py @@ -1846,7 +1846,7 @@ def test( 'keep': 'Keep existing demo dataset (do not re-clone)', 'validate_files': 'Validate media files are correctly copied', 'use_ssh': 'Use SSH protocol for cloning the demo dataset (requires SSH key)', - 'branch': 'Specify branch of demo-dataset to clone (default = main)', + 'branch': 'Specify branch of demo-dataset to clone', 'verbose': 'Print verbose output from management commands', } ) @@ -1859,7 +1859,7 @@ def setup_test( use_ssh: bool = False, verbose: bool = False, path: str = 'inventree-demo-dataset', - branch='main', + branch: Optional[str] = None, ): """Setup a testing environment.""" from src.backend.InvenTree.InvenTree.config import ( # type: ignore[import] @@ -1882,6 +1882,16 @@ def setup_test( # Use SSH protocol for cloning the demo dataset URL = 'git@github.com:inventree/demo-dataset.git' + if not branch: + # No branch specified - determine the InvenTree version + version = get_inventree_version() + + # If the version is a stable release (e.g. "1.4.3") + # then we can try to use the corresponding branch in the demo-dataset repository + # (e.g. "1.4.x") + if re.match(r'^\d+\.\d+\.\d+$', version): + branch = f'{version.rsplit(".", 1)[0]}.x' + # InvenTree's trunk branch is named "master", but the demo-dataset # repository uses "main" as its trunk branch - map this automatically # so CI can pass through the detected target branch unmodified.