From 96309e9be42b812ac3ea8cfa8d40f425a7434689 Mon Sep 17 00:00:00 2001 From: eakmanrq <6326532+eakmanrq@users.noreply.github.com> Date: Tue, 15 Jul 2025 14:59:39 -0700 Subject: [PATCH] chore: add private repo tests on pr --- .../scripts}/get_scm_version.py | 2 +- .github/workflows/private-repo-test.yaml | 96 +++++++++++++++++++ tests/core/state_sync/test_state_sync.py | 8 +- 3 files changed, 101 insertions(+), 5 deletions(-) rename {.circleci => .github/scripts}/get_scm_version.py (53%) create mode 100644 .github/workflows/private-repo-test.yaml diff --git a/.circleci/get_scm_version.py b/.github/scripts/get_scm_version.py similarity index 53% rename from .circleci/get_scm_version.py rename to .github/scripts/get_scm_version.py index c432167958..79dfee9e5d 100644 --- a/.circleci/get_scm_version.py +++ b/.github/scripts/get_scm_version.py @@ -1,4 +1,4 @@ from setuptools_scm import get_version -version = get_version(root='../', relative_to=__file__) +version = get_version(root='../../', relative_to=__file__) print(version.split('+')[0]) diff --git a/.github/workflows/private-repo-test.yaml b/.github/workflows/private-repo-test.yaml new file mode 100644 index 0000000000..e2d0748e79 --- /dev/null +++ b/.github/workflows/private-repo-test.yaml @@ -0,0 +1,96 @@ +name: Private Repo Testing + +on: + pull_request: + branches: + - main + +concurrency: + group: 'private-test-${{ github.event.pull_request.number }}' + cancel-in-progress: true + +permissions: + contents: read + +jobs: + trigger-private-test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install uv + uses: astral-sh/setup-uv@v6 + - name: Set up Node.js for UI build + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: latest + - name: Install UI dependencies + run: pnpm install + - name: Build UI + run: pnpm --prefix web/client run build + - name: Install Python dependencies + run: | + python -m venv .venv + source .venv/bin/activate + pip install build twine setuptools_scm + - name: Generate development version + id: version + run: | + source .venv/bin/activate + # Generate a PEP 440 compliant unique version including run attempt + BASE_VERSION=$(python .github/scripts/get_scm_version.py) + COMMIT_SHA=$(git rev-parse --short HEAD) + # Use PEP 440 compliant format: base.devN+pr.sha.attempt + UNIQUE_VERSION="${BASE_VERSION}+pr${{ github.event.pull_request.number }}.${COMMIT_SHA}.run${{ github.run_attempt }}" + echo "version=$UNIQUE_VERSION" >> $GITHUB_OUTPUT + echo "Generated unique version with run attempt: $UNIQUE_VERSION" + - name: Build package + env: + SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.version.outputs.version }} + run: | + source .venv/bin/activate + python -m build + - name: Configure PyPI for private repository + env: + TOBIKO_PRIVATE_PYPI_URL: ${{ secrets.TOBIKO_PRIVATE_PYPI_URL }} + TOBIKO_PRIVATE_PYPI_KEY: ${{ secrets.TOBIKO_PRIVATE_PYPI_KEY }} + run: ./.circleci/update-pypirc.sh + - name: Publish to private PyPI + run: | + source .venv/bin/activate + python -m twine upload -r tobiko-private dist/* + - name: Publish Python Tests package + env: + SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.version.outputs.version }} + run: | + source .venv/bin/activate + unset TWINE_USERNAME TWINE_PASSWORD && make publish-tests + - name: Get GitHub App token + id: get_token + uses: actions/create-github-app-token@v1 + with: + private-key: ${{ secrets.TOBIKO_RENOVATE_BOT_PRIVATE_KEY }} + app-id: ${{ secrets.TOBIKO_RENOVATE_BOT_APP_ID }} + owner: ${{ secrets.PRIVATE_REPO_OWNER }} + - name: Trigger private repository workflow + uses: convictional/trigger-workflow-and-wait@v1.6.5 + with: + owner: ${{ secrets.PRIVATE_REPO_OWNER }} + repo: ${{ secrets.PRIVATE_REPO_NAME }} + github_token: ${{ steps.get_token.outputs.token }} + workflow_file_name: ${{ secrets.PRIVATE_WORKFLOW_FILE }} + client_payload: | + { + "package_version": "${{ steps.version.outputs.version }}", + "pr_number": "${{ github.event.pull_request.number }}" + } diff --git a/tests/core/state_sync/test_state_sync.py b/tests/core/state_sync/test_state_sync.py index b5b4a42fde..eba948bd9a 100644 --- a/tests/core/state_sync/test_state_sync.py +++ b/tests/core/state_sync/test_state_sync.py @@ -2089,7 +2089,7 @@ def test_version_schema(state_sync: EngineAdapterStateSync, tmp_path) -> None: with pytest.raises( SQLMeshError, - match=rf"SQLMesh \(local\) is using version '{SQLMESH_VERSION}' which is ahead of '0.0.0' \(remote\). Please run a migration \('sqlmesh migrate' command\).", + match=rf"SQLMesh \(local\) is using version '{re.escape(SQLMESH_VERSION)}' which is ahead of '0.0.0' \(remote\). Please run a migration \('sqlmesh migrate' command\).", ): state_sync.get_versions() @@ -2099,7 +2099,7 @@ def test_version_schema(state_sync: EngineAdapterStateSync, tmp_path) -> None: state_sync.version_state.update_versions(schema_version=SCHEMA_VERSION + 1) error = ( rf"SQLMesh \(local\) is using version '{SCHEMA_VERSION}' which is behind '{SCHEMA_VERSION + 1}' \(remote\). " - rf"""Please upgrade SQLMesh \('pip install --upgrade "sqlmesh=={SQLMESH_VERSION}"' command\).""" + rf"""Please upgrade SQLMesh \('pip install --upgrade "sqlmesh=={re.escape(SQLMESH_VERSION)}"' command\).""" ) with pytest.raises(SQLMeshError, match=error): @@ -2136,7 +2136,7 @@ def test_version_sqlmesh(state_sync: EngineAdapterStateSync) -> None: # sqlmesh version is behind sqlmesh_version_minor_bump = f"{major}.{int(minor) + 1}.{patch}" error = ( - rf"SQLMesh \(local\) is using version '{SQLMESH_VERSION}' which is behind '{sqlmesh_version_minor_bump}' \(remote\). " + rf"SQLMesh \(local\) is using version '{re.escape(SQLMESH_VERSION)}' which is behind '{sqlmesh_version_minor_bump}' \(remote\). " rf"""Please upgrade SQLMesh \('pip install --upgrade "sqlmesh=={sqlmesh_version_minor_bump}"' command\).""" ) state_sync.version_state.update_versions(sqlmesh_version=sqlmesh_version_minor_bump) @@ -2146,7 +2146,7 @@ def test_version_sqlmesh(state_sync: EngineAdapterStateSync) -> None: # sqlmesh version is ahead sqlmesh_version_minor_decrease = f"{major}.{int(minor) - 1}.{patch}" - error = rf"SQLMesh \(local\) is using version '{SQLMESH_VERSION}' which is ahead of '{sqlmesh_version_minor_decrease}'" + error = rf"SQLMesh \(local\) is using version '{re.escape(SQLMESH_VERSION)}' which is ahead of '{sqlmesh_version_minor_decrease}'" state_sync.version_state.update_versions(sqlmesh_version=sqlmesh_version_minor_decrease) with pytest.raises(SQLMeshError, match=error): state_sync.get_versions()