Skip to content

Commit 08b90d7

Browse files
refactor: extract steps into reusable workflow to avoid duplication
e2e-tests.yml now calls e2e-tests-run.yml (reusable) from two jobs: - run-with-approval: for pull_request/push, uses azure-prod environment - run-merge-queue: for merge_group, no environment (secrets direct access) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7424f41 commit 08b90d7

File tree

2 files changed

+115
-154
lines changed

2 files changed

+115
-154
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Copyright (c) 2025 ADBC Drivers Contributors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: E2E Tests (reusable)
16+
17+
on:
18+
workflow_call:
19+
secrets:
20+
DATABRICKS_HOST:
21+
required: true
22+
TEST_PECO_WAREHOUSE_HTTP_PATH:
23+
required: true
24+
DATABRICKS_TEST_CLIENT_ID:
25+
required: true
26+
DATABRICKS_TEST_CLIENT_SECRET:
27+
required: true
28+
29+
jobs:
30+
run-all-tests:
31+
runs-on: ubuntu-latest
32+
env:
33+
DATABRICKS_SERVER_HOSTNAME: ${{ secrets.DATABRICKS_HOST }}
34+
DATABRICKS_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }}
35+
DATABRICKS_TEST_CLIENT_ID: ${{ secrets.DATABRICKS_TEST_CLIENT_ID }}
36+
DATABRICKS_TEST_CLIENT_SECRET: ${{ secrets.DATABRICKS_TEST_CLIENT_SECRET }}
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
with:
41+
submodules: recursive
42+
43+
- name: Set up .NET
44+
uses: actions/setup-dotnet@v4
45+
with:
46+
dotnet-version: '8.0.x'
47+
48+
- name: Generate OAuth access token
49+
id: oauth
50+
run: |
51+
OAUTH_RESPONSE=$(curl -s -X POST "https://${{ env.DATABRICKS_SERVER_HOSTNAME }}/oidc/v1/token" \
52+
-H "Content-Type: application/x-www-form-urlencoded" \
53+
-d "grant_type=client_credentials" \
54+
-d "client_id=${{ env.DATABRICKS_TEST_CLIENT_ID }}" \
55+
-d "client_secret=${{ env.DATABRICKS_TEST_CLIENT_SECRET }}" \
56+
-d "scope=sql")
57+
OAUTH_TOKEN=$(echo "$OAUTH_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
58+
if [ -z "$OAUTH_TOKEN" ]; then
59+
echo "ERROR: Failed to generate OAuth token"
60+
exit 1
61+
fi
62+
echo "::add-mask::$OAUTH_TOKEN"
63+
echo "OAUTH_TOKEN=$OAUTH_TOKEN" >> $GITHUB_OUTPUT
64+
65+
- name: Create Databricks config file
66+
run: |
67+
mkdir -p ~/.databricks
68+
cat > ~/.databricks/connection.json << EOF
69+
{
70+
"uri": "https://${{ env.DATABRICKS_SERVER_HOSTNAME }}${{ env.DATABRICKS_HTTP_PATH }}",
71+
"auth_type": "oauth",
72+
"grant_type": "client_credentials",
73+
"client_id": "${{ env.DATABRICKS_TEST_CLIENT_ID }}",
74+
"client_secret": "${{ env.DATABRICKS_TEST_CLIENT_SECRET }}",
75+
"scope": "sql",
76+
"access_token": "${{ steps.oauth.outputs.OAUTH_TOKEN }}",
77+
"type": "databricks",
78+
"catalog": "main",
79+
"db_schema": "adbc_testing",
80+
"query": "SELECT * FROM main.adbc_testing.adbc_testing_table",
81+
"expectedResults": 12,
82+
"isCITesting": true,
83+
"tracePropagationEnabled": "true",
84+
"traceParentHeaderName": "traceparent",
85+
"traceStateEnabled": "false",
86+
"metadata": {
87+
"catalog": "main",
88+
"schema": "adbc_testing",
89+
"table": "adbc_testing_table",
90+
"expectedColumnCount": 19
91+
}
92+
}
93+
EOF
94+
echo "DATABRICKS_TEST_CONFIG_FILE=$HOME/.databricks/connection.json" >> $GITHUB_ENV
95+
96+
- name: Build
97+
shell: bash
98+
run: |
99+
./ci/scripts/csharp_build.sh "${{ github.workspace }}"
100+
101+
- name: Run All Tests
102+
shell: bash
103+
run: |
104+
export DATABRICKS_TEST_CONFIG_FILE="$HOME/.databricks/connection.json"
105+
./ci/scripts/csharp_test_databricks_e2e.sh "${{ github.workspace }}"

.github/workflows/e2e-tests.yml

Lines changed: 10 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ on:
2020
- main
2121
paths:
2222
- '.github/workflows/e2e-tests.yml'
23+
- '.github/workflows/e2e-tests-run.yml'
2324
- 'ci/scripts/**'
2425
- 'csharp/src/**'
2526
- 'csharp/test/**'
2627
pull_request:
2728
# Only runs on PRs from the repo itself, not forks
2829
paths:
2930
- '.github/workflows/e2e-tests.yml'
31+
- '.github/workflows/e2e-tests-run.yml'
3032
- 'ci/scripts/**'
3133
- 'csharp/src/**'
3234
- 'csharp/test/**'
@@ -37,161 +39,15 @@ concurrency:
3739
cancel-in-progress: true
3840

3941
jobs:
40-
# Runs for pull_request and push — uses azure-prod environment which requires manual approval.
41-
run-all-tests:
42+
# pull_request and push: requires manual approval via azure-prod environment.
43+
run-with-approval:
4244
if: github.event_name != 'merge_group'
43-
runs-on: ubuntu-latest
4445
environment: azure-prod
45-
env:
46-
DATABRICKS_SERVER_HOSTNAME: ${{ secrets.DATABRICKS_HOST }}
47-
DATABRICKS_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }}
48-
DATABRICKS_TEST_CLIENT_ID: ${{ secrets.DATABRICKS_TEST_CLIENT_ID }}
49-
DATABRICKS_TEST_CLIENT_SECRET: ${{ secrets.DATABRICKS_TEST_CLIENT_SECRET }}
50-
steps:
51-
- name: Checkout repository
52-
uses: actions/checkout@v4
53-
with:
54-
submodules: recursive
46+
uses: ./.github/workflows/e2e-tests-run.yml
47+
secrets: inherit
5548

56-
- name: Set up .NET
57-
uses: actions/setup-dotnet@v4
58-
with:
59-
dotnet-version: '8.0.x'
60-
61-
- name: Generate OAuth access token
62-
id: oauth
63-
run: |
64-
OAUTH_RESPONSE=$(curl -s -X POST "https://${{ env.DATABRICKS_SERVER_HOSTNAME }}/oidc/v1/token" \
65-
-H "Content-Type: application/x-www-form-urlencoded" \
66-
-d "grant_type=client_credentials" \
67-
-d "client_id=${{ env.DATABRICKS_TEST_CLIENT_ID }}" \
68-
-d "client_secret=${{ env.DATABRICKS_TEST_CLIENT_SECRET }}" \
69-
-d "scope=sql")
70-
OAUTH_TOKEN=$(echo "$OAUTH_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
71-
if [ -z "$OAUTH_TOKEN" ]; then
72-
echo "ERROR: Failed to generate OAuth token"
73-
exit 1
74-
fi
75-
echo "::add-mask::$OAUTH_TOKEN"
76-
echo "OAUTH_TOKEN=$OAUTH_TOKEN" >> $GITHUB_OUTPUT
77-
78-
- name: Create Databricks config file
79-
run: |
80-
mkdir -p ~/.databricks
81-
cat > ~/.databricks/connection.json << EOF
82-
{
83-
"uri": "https://${{ env.DATABRICKS_SERVER_HOSTNAME }}${{ env.DATABRICKS_HTTP_PATH }}",
84-
"auth_type": "oauth",
85-
"grant_type": "client_credentials",
86-
"client_id": "${{ env.DATABRICKS_TEST_CLIENT_ID }}",
87-
"client_secret": "${{ env.DATABRICKS_TEST_CLIENT_SECRET }}",
88-
"scope": "sql",
89-
"access_token": "${{ steps.oauth.outputs.OAUTH_TOKEN }}",
90-
"type": "databricks",
91-
"catalog": "main",
92-
"db_schema": "adbc_testing",
93-
"query": "SELECT * FROM main.adbc_testing.adbc_testing_table",
94-
"expectedResults": 12,
95-
"isCITesting": true,
96-
"tracePropagationEnabled": "true",
97-
"traceParentHeaderName": "traceparent",
98-
"traceStateEnabled": "false",
99-
"metadata": {
100-
"catalog": "main",
101-
"schema": "adbc_testing",
102-
"table": "adbc_testing_table",
103-
"expectedColumnCount": 19
104-
}
105-
}
106-
EOF
107-
echo "DATABRICKS_TEST_CONFIG_FILE=$HOME/.databricks/connection.json" >> $GITHUB_ENV
108-
109-
- name: Build
110-
shell: bash
111-
run: |
112-
./ci/scripts/csharp_build.sh "${{ github.workspace }}"
113-
114-
- name: Run All Tests
115-
shell: bash
116-
run: |
117-
export DATABRICKS_TEST_CONFIG_FILE="$HOME/.databricks/connection.json"
118-
./ci/scripts/csharp_test_databricks_e2e.sh "${{ github.workspace }}"
119-
120-
# Runs for merge_group — has direct access to repo secrets, no approval gate needed.
121-
run-all-tests-merge-queue:
49+
# merge_group: has direct access to repo secrets — no approval gate needed.
50+
run-merge-queue:
12251
if: github.event_name == 'merge_group'
123-
runs-on: ubuntu-latest
124-
env:
125-
DATABRICKS_SERVER_HOSTNAME: ${{ secrets.DATABRICKS_HOST }}
126-
DATABRICKS_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }}
127-
DATABRICKS_TEST_CLIENT_ID: ${{ secrets.DATABRICKS_TEST_CLIENT_ID }}
128-
DATABRICKS_TEST_CLIENT_SECRET: ${{ secrets.DATABRICKS_TEST_CLIENT_SECRET }}
129-
steps:
130-
- name: Checkout repository
131-
uses: actions/checkout@v4
132-
with:
133-
submodules: recursive
134-
135-
- name: Set up .NET
136-
uses: actions/setup-dotnet@v4
137-
with:
138-
dotnet-version: '8.0.x'
139-
140-
- name: Generate OAuth access token
141-
id: oauth
142-
run: |
143-
OAUTH_RESPONSE=$(curl -s -X POST "https://${{ env.DATABRICKS_SERVER_HOSTNAME }}/oidc/v1/token" \
144-
-H "Content-Type: application/x-www-form-urlencoded" \
145-
-d "grant_type=client_credentials" \
146-
-d "client_id=${{ env.DATABRICKS_TEST_CLIENT_ID }}" \
147-
-d "client_secret=${{ env.DATABRICKS_TEST_CLIENT_SECRET }}" \
148-
-d "scope=sql")
149-
OAUTH_TOKEN=$(echo "$OAUTH_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
150-
if [ -z "$OAUTH_TOKEN" ]; then
151-
echo "ERROR: Failed to generate OAuth token"
152-
exit 1
153-
fi
154-
echo "::add-mask::$OAUTH_TOKEN"
155-
echo "OAUTH_TOKEN=$OAUTH_TOKEN" >> $GITHUB_OUTPUT
156-
157-
- name: Create Databricks config file
158-
run: |
159-
mkdir -p ~/.databricks
160-
cat > ~/.databricks/connection.json << EOF
161-
{
162-
"uri": "https://${{ env.DATABRICKS_SERVER_HOSTNAME }}${{ env.DATABRICKS_HTTP_PATH }}",
163-
"auth_type": "oauth",
164-
"grant_type": "client_credentials",
165-
"client_id": "${{ env.DATABRICKS_TEST_CLIENT_ID }}",
166-
"client_secret": "${{ env.DATABRICKS_TEST_CLIENT_SECRET }}",
167-
"scope": "sql",
168-
"access_token": "${{ steps.oauth.outputs.OAUTH_TOKEN }}",
169-
"type": "databricks",
170-
"catalog": "main",
171-
"db_schema": "adbc_testing",
172-
"query": "SELECT * FROM main.adbc_testing.adbc_testing_table",
173-
"expectedResults": 12,
174-
"isCITesting": true,
175-
"tracePropagationEnabled": "true",
176-
"traceParentHeaderName": "traceparent",
177-
"traceStateEnabled": "false",
178-
"metadata": {
179-
"catalog": "main",
180-
"schema": "adbc_testing",
181-
"table": "adbc_testing_table",
182-
"expectedColumnCount": 19
183-
}
184-
}
185-
EOF
186-
echo "DATABRICKS_TEST_CONFIG_FILE=$HOME/.databricks/connection.json" >> $GITHUB_ENV
187-
188-
- name: Build
189-
shell: bash
190-
run: |
191-
./ci/scripts/csharp_build.sh "${{ github.workspace }}"
192-
193-
- name: Run All Tests
194-
shell: bash
195-
run: |
196-
export DATABRICKS_TEST_CONFIG_FILE="$HOME/.databricks/connection.json"
197-
./ci/scripts/csharp_test_databricks_e2e.sh "${{ github.workspace }}"
52+
uses: ./.github/workflows/e2e-tests-run.yml
53+
secrets: inherit

0 commit comments

Comments
 (0)