Skip to content

Commit 49b5574

Browse files
authored
chore: add private repo tests on pr (#4972)
1 parent 94b1357 commit 49b5574

File tree

3 files changed

+101
-5
lines changed

3 files changed

+101
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from setuptools_scm import get_version
22

3-
version = get_version(root='../', relative_to=__file__)
3+
version = get_version(root='../../', relative_to=__file__)
44
print(version.split('+')[0])
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Private Repo Testing
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: 'private-test-${{ github.event.pull_request.number }}'
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
trigger-private-test:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.12'
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v6
29+
- name: Set up Node.js for UI build
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '20'
33+
- name: Install pnpm
34+
uses: pnpm/action-setup@v4
35+
with:
36+
version: latest
37+
- name: Install UI dependencies
38+
run: pnpm install
39+
- name: Build UI
40+
run: pnpm --prefix web/client run build
41+
- name: Install Python dependencies
42+
run: |
43+
python -m venv .venv
44+
source .venv/bin/activate
45+
pip install build twine setuptools_scm
46+
- name: Generate development version
47+
id: version
48+
run: |
49+
source .venv/bin/activate
50+
# Generate a PEP 440 compliant unique version including run attempt
51+
BASE_VERSION=$(python .github/scripts/get_scm_version.py)
52+
COMMIT_SHA=$(git rev-parse --short HEAD)
53+
# Use PEP 440 compliant format: base.devN+pr.sha.attempt
54+
UNIQUE_VERSION="${BASE_VERSION}+pr${{ github.event.pull_request.number }}.${COMMIT_SHA}.run${{ github.run_attempt }}"
55+
echo "version=$UNIQUE_VERSION" >> $GITHUB_OUTPUT
56+
echo "Generated unique version with run attempt: $UNIQUE_VERSION"
57+
- name: Build package
58+
env:
59+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.version.outputs.version }}
60+
run: |
61+
source .venv/bin/activate
62+
python -m build
63+
- name: Configure PyPI for private repository
64+
env:
65+
TOBIKO_PRIVATE_PYPI_URL: ${{ secrets.TOBIKO_PRIVATE_PYPI_URL }}
66+
TOBIKO_PRIVATE_PYPI_KEY: ${{ secrets.TOBIKO_PRIVATE_PYPI_KEY }}
67+
run: ./.circleci/update-pypirc.sh
68+
- name: Publish to private PyPI
69+
run: |
70+
source .venv/bin/activate
71+
python -m twine upload -r tobiko-private dist/*
72+
- name: Publish Python Tests package
73+
env:
74+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.version.outputs.version }}
75+
run: |
76+
source .venv/bin/activate
77+
unset TWINE_USERNAME TWINE_PASSWORD && make publish-tests
78+
- name: Get GitHub App token
79+
id: get_token
80+
uses: actions/create-github-app-token@v1
81+
with:
82+
private-key: ${{ secrets.TOBIKO_RENOVATE_BOT_PRIVATE_KEY }}
83+
app-id: ${{ secrets.TOBIKO_RENOVATE_BOT_APP_ID }}
84+
owner: ${{ secrets.PRIVATE_REPO_OWNER }}
85+
- name: Trigger private repository workflow
86+
uses: convictional/[email protected]
87+
with:
88+
owner: ${{ secrets.PRIVATE_REPO_OWNER }}
89+
repo: ${{ secrets.PRIVATE_REPO_NAME }}
90+
github_token: ${{ steps.get_token.outputs.token }}
91+
workflow_file_name: ${{ secrets.PRIVATE_WORKFLOW_FILE }}
92+
client_payload: |
93+
{
94+
"package_version": "${{ steps.version.outputs.version }}",
95+
"pr_number": "${{ github.event.pull_request.number }}"
96+
}

tests/core/state_sync/test_state_sync.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,7 @@ def test_version_schema(state_sync: EngineAdapterStateSync, tmp_path) -> None:
20892089

20902090
with pytest.raises(
20912091
SQLMeshError,
2092-
match=rf"SQLMesh \(local\) is using version '{SQLMESH_VERSION}' which is ahead of '0.0.0' \(remote\). Please run a migration \('sqlmesh migrate' command\).",
2092+
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\).",
20932093
):
20942094
state_sync.get_versions()
20952095

@@ -2099,7 +2099,7 @@ def test_version_schema(state_sync: EngineAdapterStateSync, tmp_path) -> None:
20992099
state_sync.version_state.update_versions(schema_version=SCHEMA_VERSION + 1)
21002100
error = (
21012101
rf"SQLMesh \(local\) is using version '{SCHEMA_VERSION}' which is behind '{SCHEMA_VERSION + 1}' \(remote\). "
2102-
rf"""Please upgrade SQLMesh \('pip install --upgrade "sqlmesh=={SQLMESH_VERSION}"' command\)."""
2102+
rf"""Please upgrade SQLMesh \('pip install --upgrade "sqlmesh=={re.escape(SQLMESH_VERSION)}"' command\)."""
21032103
)
21042104

21052105
with pytest.raises(SQLMeshError, match=error):
@@ -2136,7 +2136,7 @@ def test_version_sqlmesh(state_sync: EngineAdapterStateSync) -> None:
21362136
# sqlmesh version is behind
21372137
sqlmesh_version_minor_bump = f"{major}.{int(minor) + 1}.{patch}"
21382138
error = (
2139-
rf"SQLMesh \(local\) is using version '{SQLMESH_VERSION}' which is behind '{sqlmesh_version_minor_bump}' \(remote\). "
2139+
rf"SQLMesh \(local\) is using version '{re.escape(SQLMESH_VERSION)}' which is behind '{sqlmesh_version_minor_bump}' \(remote\). "
21402140
rf"""Please upgrade SQLMesh \('pip install --upgrade "sqlmesh=={sqlmesh_version_minor_bump}"' command\)."""
21412141
)
21422142
state_sync.version_state.update_versions(sqlmesh_version=sqlmesh_version_minor_bump)
@@ -2146,7 +2146,7 @@ def test_version_sqlmesh(state_sync: EngineAdapterStateSync) -> None:
21462146

21472147
# sqlmesh version is ahead
21482148
sqlmesh_version_minor_decrease = f"{major}.{int(minor) - 1}.{patch}"
2149-
error = rf"SQLMesh \(local\) is using version '{SQLMESH_VERSION}' which is ahead of '{sqlmesh_version_minor_decrease}'"
2149+
error = rf"SQLMesh \(local\) is using version '{re.escape(SQLMESH_VERSION)}' which is ahead of '{sqlmesh_version_minor_decrease}'"
21502150
state_sync.version_state.update_versions(sqlmesh_version=sqlmesh_version_minor_decrease)
21512151
with pytest.raises(SQLMeshError, match=error):
21522152
state_sync.get_versions()

0 commit comments

Comments
 (0)