Skip to content

Commit 29c3000

Browse files
committed
Feat: Trigger integration tests
1 parent df13a65 commit 29c3000

File tree

1 file changed

+81
-2
lines changed

1 file changed

+81
-2
lines changed

.github/workflows/package-test.yml

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ jobs:
1111
runs-on: ubuntu-22.04
1212
strategy:
1313
matrix:
14-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
14+
# python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
15+
# TODO: revert
16+
python-version: ["3.9"]
1517
steps:
1618
- uses: actions/checkout@v5
1719
- name: Set up Python ${{ matrix.python-version }}
@@ -27,7 +29,84 @@ jobs:
2729
source ./.venv/bin/activate
2830
python -m pip install --upgrade pip
2931
make install-dev
30-
- name: Run tests and linter checks
32+
- name: Run unit tests and linter checks
3133
run: |
3234
source ./.venv/bin/activate
3335
make check
36+
37+
run-integration-tests:
38+
runs-on: ubuntu-latest
39+
needs: run-checks
40+
steps:
41+
- name: Acquire credentials
42+
id: app-token
43+
uses: actions/create-github-app-token@v2
44+
with:
45+
app-id: ${{ vars.INTEGRATION_TEST_CLIENT_ID }}
46+
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
47+
owner: fivetran
48+
repositories: sqlglot-integration-tests
49+
50+
- name: Run integration tests
51+
id: run-remote
52+
env:
53+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
54+
run: |
55+
set -e
56+
57+
gh workflow run run-tests.yml \
58+
--repo fivetran/sqlglot-integration-tests \
59+
--ref main \
60+
-f sqlglot_ref=${{ github.sha }} \
61+
-f sqlglot_pr_number=${{ github.event.number }} \
62+
-f sqlglot_branch_name=${{ github.head_ref || github.ref_name }}
63+
64+
echo "Triggered workflow"
65+
66+
# wait a bit for the run to start
67+
sleep 10
68+
69+
# there is a bit of a race condition here. this just grabs the latest
70+
# run and hopes it's the one we just triggered.
71+
# inexplicably, the `gh workflow run` API doesnt return the run id...
72+
RUN_ID=$(gh run list \
73+
--repo fivetran/sqlglot-integration-tests \
74+
--workflow run-tests.yml \
75+
--user sqlglot-integration-tests \
76+
--limit 1 \
77+
--json databaseId \
78+
--jq '.[0].databaseId')
79+
80+
echo "Using Run ID: ${RUN_ID}"
81+
echo "remote_run_id=$RUN_ID" >> $GITHUB_OUTPUT
82+
83+
echo "Waiting for completion"
84+
gh run watch $RUN_ID \
85+
--repo fivetran/sqlglot-integration-tests \
86+
--interval 10 \
87+
--compact \
88+
--exit-status
89+
90+
- name: Fetch outputs
91+
uses: actions/download-artifact@v5
92+
with:
93+
github-token: ${{ steps.app-token.outputs.token }}
94+
repository: fivetran/sqlglot-integration-tests
95+
run-id: ${{ steps.run-remote.outputs.remote_run_id }}
96+
name: summary
97+
98+
- name: Write summary as comment
99+
uses: actions/github-script@v8
100+
# only do this when on PR branches, main builds dont have anywhere to write comments
101+
if: ${{ github.event_name == 'pull_request' }}
102+
with:
103+
script: |
104+
// summary.json is downloaded from the remote workflow in the previous step
105+
const summary = require("./summary.json")
106+
107+
github.rest.issues.createComment({
108+
issue_number: context.issue.number,
109+
owner: context.repo.owner,
110+
repo: context.repo.repo,
111+
body: summary.msg
112+
})

0 commit comments

Comments
 (0)