-
Notifications
You must be signed in to change notification settings - Fork 39
147 lines (125 loc) · 4.86 KB
/
runJdbcComparator.yml
File metadata and controls
147 lines (125 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: JDBC Driver Comparison
on:
schedule:
- cron: '0 0 * * 1' # Run at 00:00 UTC on Monday (1)
workflow_dispatch: # Allow manual trigger
permissions:
id-token: write
contents: read
jobs:
comparator:
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: main
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- name: Merge main into jdbc-comparator
run: |
git checkout jdbc-comparator
git merge main --allow-unrelated-histories --no-edit -X theirs || {
echo "Force merging by accepting all changes from main"
git checkout --theirs .
git add .
git commit --no-edit
}
- name: Set up JDK 11
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Get JFrog OIDC token
run: |
set -euo pipefail
# Get GitHub OIDC ID token
ID_TOKEN=$(curl -sLS \
-H "User-Agent: actions/oidc-client" \
-H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=jfrog-github" | jq .value | tr -d '"')
echo "::add-mask::${ID_TOKEN}"
# Exchange for JFrog access token
ACCESS_TOKEN=$(curl -sLS -XPOST -H "Content-Type: application/json" \
"https://databricks.jfrog.io/access/api/v1/oidc/token" \
-d "{\"grant_type\": \"urn:ietf:params:oauth:grant-type:token-exchange\", \"subject_token_type\":\"urn:ietf:params:oauth:token-type:id_token\", \"subject_token\": \"${ID_TOKEN}\", \"provider_name\": \"github-actions\"}" | jq .access_token | tr -d '"')
echo "::add-mask::${ACCESS_TOKEN}"
if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" = "null" ]; then
echo "FAIL: Could not extract JFrog access token"
exit 1
fi
echo "JFROG_ACCESS_TOKEN=${ACCESS_TOKEN}" >> "$GITHUB_ENV"
echo "JFrog OIDC token obtained successfully"
- name: Configure maven
run: |
set -euo pipefail
mkdir -p ~/.m2
cat > ~/.m2/settings.xml << EOF
<settings>
<mirrors>
<mirror>
<id>jfrog-central</id>
<mirrorOf>*</mirrorOf>
<url>https://databricks.jfrog.io/artifactory/db-maven/</url>
</mirror>
</mirrors>
<servers>
<server>
<id>jfrog-central</id>
<username>gha-service-account</username>
<password>${JFROG_ACCESS_TOKEN}</password>
</server>
</servers>
</settings>
EOF
echo "Maven configured to use JFrog registry"
- name: Set up PAT
env:
DATABRICKS_COMPARATOR_TOKEN: ${{ secrets.DATABRICKS_COMPARATOR_TOKEN }}
run: |
echo "DATABRICKS_COMPARATOR_TOKEN=${DATABRICKS_COMPARATOR_TOKEN}" >> $GITHUB_ENV
- name: Run Tests
run: mvn -pl jdbc-core test -Dtest=JDBCDriverComparisonTest
- name: Format Email Content
run: |
chmod +x bin/format-comparator-email.sh
./bin/format-comparator-email.sh
- name: Check for Report and Differences
id: check_differences
run: |
if [ -f "jdbc-comparison-report.txt" ]; then
if grep -q "No differences found" "jdbc-comparison-report.txt"; then
echo "has_differences=false" >> $GITHUB_OUTPUT
else
echo "has_differences=true" >> $GITHUB_OUTPUT
fi
else
echo "Report file not found"
exit 1
fi
- name: Send Email
if: steps.check_differences.outputs.has_differences == 'true'
uses: dawidd6/action-send-mail@4226df7daafa6fc901a43789c49bf7ab309066e7 # v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.SMTP_USERNAME }}
password: ${{ secrets.SMTP_PASSWORD }}
subject: JDBC Driver Comparison Results - 🚨Differences Found
html_body: file://jdbc-comparison-report.html
to: ${{ secrets.EMAIL_RECIPIENTS }}
from: JDBC Comparator Runner
content_type: text/html
- name: Upload Report as Artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: jdbc-comparison-report
path: |
jdbc-comparison-report.txt
jdbc-comparison-report.html