Skip to content

Commit ee52de1

Browse files
committed
Make integration tests their own worflow so they can be triggered independently
1 parent 29c3000 commit ee52de1

File tree

2 files changed

+105
-81
lines changed

2 files changed

+105
-81
lines changed

.github/workflows/package-test.yml

Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ 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"]
15-
# TODO: revert
16-
python-version: ["3.9"]
14+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1715
steps:
1816
- uses: actions/checkout@v5
1917
- name: Set up Python ${{ matrix.python-version }}
@@ -29,84 +27,7 @@ jobs:
2927
source ./.venv/bin/activate
3028
python -m pip install --upgrade pip
3129
make install-dev
32-
- name: Run unit tests and linter checks
30+
- name: Run tests and linter checks
3331
run: |
3432
source ./.venv/bin/activate
3533
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-
})
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Run Integration Tests
2+
3+
on:
4+
issue_comment:
5+
types: [created, edited]
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
jobs:
10+
run-integration-tests:
11+
name: Run Integration Tests
12+
runs-on: ubuntu-latest
13+
if: |
14+
(github.event_name == 'issue_comment' &&
15+
contains(github.event.comment.body, '/integration-test') &&
16+
github.event.issue.pull_request) ||
17+
(github.event_name == 'pull_request' &&
18+
contains(github.event.pull_request.body, '/integration-test'))
19+
steps:
20+
- name: Print debugging info
21+
run: |
22+
echo "Github event name: ${{ github.event_name }}"
23+
echo 'Github event ${{ toJSON(github.event) }}'
24+
echo "Github event comment body: ${{ github.event.comment.body }}"
25+
echo "Github event pr body: ${{ github.event.pull_request.body }}"
26+
echo "Generic Number: ${{ github.event.number }}"
27+
echo "PR number: ${{ github.event.pull_request.number }}"
28+
echo "Issue number: ${{ github.event.issue.number }}"
29+
echo "SHA: ${{ github.sha }}"
30+
echo "Head Ref ${{ github.head_ref }}"
31+
echo "Ref Name: ${{ github.ref_name }}"
32+
- name: Acquire credentials
33+
id: app-token
34+
uses: actions/create-github-app-token@v2
35+
with:
36+
app-id: ${{ vars.INTEGRATION_TEST_CLIENT_ID }}
37+
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
38+
owner: fivetran
39+
repositories: sqlglot-integration-tests
40+
41+
- name: Run integration tests
42+
id: run-remote
43+
env:
44+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
45+
run: |
46+
set -e
47+
48+
gh workflow run run-tests.yml \
49+
--repo fivetran/sqlglot-integration-tests \
50+
--ref main \
51+
-f sqlglot_ref=${{ github.sha }} \
52+
-f sqlglot_pr_number=${{ github.event.number }} \
53+
-f sqlglot_branch_name=${{ github.head_ref || github.ref_name }}
54+
55+
echo "Triggered workflow"
56+
57+
# wait a bit for the run to start
58+
sleep 10
59+
60+
# there is a bit of a race condition here. this just grabs the latest
61+
# run and hopes it's the one we just triggered.
62+
# inexplicably, the `gh workflow run` API doesnt return the run id...
63+
RUN_ID=$(gh run list \
64+
--repo fivetran/sqlglot-integration-tests \
65+
--workflow run-tests.yml \
66+
--user sqlglot-integration-tests \
67+
--limit 1 \
68+
--json databaseId \
69+
--jq '.[0].databaseId')
70+
71+
echo "Using Run ID: ${RUN_ID}"
72+
echo "remote_run_id=$RUN_ID" >> $GITHUB_OUTPUT
73+
74+
echo "Waiting for completion"
75+
gh run watch $RUN_ID \
76+
--repo fivetran/sqlglot-integration-tests \
77+
--interval 10 \
78+
--compact \
79+
--exit-status
80+
81+
- name: Fetch outputs
82+
uses: actions/download-artifact@v5
83+
with:
84+
github-token: ${{ steps.app-token.outputs.token }}
85+
repository: fivetran/sqlglot-integration-tests
86+
run-id: ${{ steps.run-remote.outputs.remote_run_id }}
87+
name: summary
88+
89+
- name: Write summary as comment
90+
uses: actions/github-script@v8
91+
# only do this when on PR branches, main builds dont have anywhere to write comments
92+
if: ${{ github.event_name == 'pull_request' }}
93+
with:
94+
script: |
95+
// summary.json is downloaded from the remote workflow in the previous step
96+
const summary = require("./summary.json")
97+
98+
github.rest.issues.createComment({
99+
issue_number: context.issue.number,
100+
owner: context.repo.owner,
101+
repo: context.repo.repo,
102+
body: summary.msg
103+
})

0 commit comments

Comments
 (0)