forked from duckdb/duckdb-java
-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (149 loc) · 6.25 KB
/
Vendor.yml
File metadata and controls
161 lines (149 loc) · 6.25 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Vendor
on:
workflow_call:
inputs:
duckdb-sha:
description: 'Vendor Specific DuckDB SHA'
required: false
default: ''
type: 'string'
workflow_dispatch:
inputs:
duckdb-sha:
description: 'Vendor Specific DuckDB SHA'
required: false
default: ''
type: 'string'
jobs:
vendor:
name: "Update Vendored Sources"
if: ${{ github.repository == 'duckdb/duckdb-java' }}
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
id: setup_python
with:
python-version: '3.12'
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout engine
uses: actions/checkout@v4
id: checkout_engine
with:
repository: duckdb/duckdb
path: .git/duckdb
fetch-depth: 0
- name: Checkout engine rev
id: checkout_engine_rev
if: ${{ inputs.duckdb-sha != '' }}
working-directory: .git/duckdb
run: |
echo "Checking out engine ref: ${{ inputs.duckdb-sha }} on branch: ${{ github.ref_name }}"
git checkout ${{ inputs.duckdb-sha }}
- name: Vendor sources
if: ${{ steps.checkout_engine_rev.outcome == 'success' }}
id: vendor
run: |
REV=$(cd .git/duckdb && git rev-parse --short HEAD && cd ../..)
echo "Updating vendored DuckDB sources to ${REV}"
git config --global user.email "github_bot@duckdblabs.com"
git config --global user.name "DuckDB Labs GitHub Bot"
# Vendoring branch must exist, it may or may not already have
# a pending PR on it, we are rebasing it anyway
git checkout vendoring-${{ github.ref_name }}
git rebase ${{ github.ref_name }}
# Call the vendoring script in the engine
rm -rf src/duckdb
python vendor.py --duckdb .git/duckdb
# Clean up
rm -rf .git/duckdb
# Export vendor revision for use in later steps
echo "vendor_rev=${REV}" >> "${GITHUB_OUTPUT}"
- name: Check for incoming changes
if: ${{ steps.vendor.outcome == 'success' }}
id: check_for_changes
run: |
if git diff --exit-code; then
echo "No vendoring changes detected, skipping the remaining of the job."
else
echo "Changes detected, proceeding with commit and push."
echo "has_changes=true" >> "${GITHUB_OUTPUT}"
fi
- name: Commit and push the changes
id: commit_and_push
if: ${{ steps.check_for_changes.outcome == 'success' && steps.check_for_changes.outputs.has_changes == 'true' }}
run: |
MSG="Update vendored DuckDB sources to ${{ steps.vendor.outputs.vendor_rev }}"
git add src/duckdb CMakeLists.txt
git commit -m "${MSG}"
git push -f origin vendoring-${{ github.ref_name }}
echo "commit_msg=${MSG}" >> "${GITHUB_OUTPUT}"
- name: Check PR exists
id: check_pr_exists
if: ${{ steps.commit_and_push.outcome == 'success' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUM=$(gh pr list --head vendoring-${{ github.ref_name }} --json number --jq '.[].number')
if [ -z "${PR_NUM}" ]; then
echo "No PR exists for branch vendoring-${{ github.ref_name }}"
echo "pr_exists=false" >> "${GITHUB_OUTPUT}"
else
echo "PR found for branch vendoring-${{ github.ref_name }}, number: ${PR_NUM}"
echo "pr_exists=true" >> "${GITHUB_OUTPUT}"
echo "pr_num=${PR_NUM}" >> "${GITHUB_OUTPUT}"
fi
- name: Prepare PR message
id: prepare_pr_message
if: ${{ steps.check_pr_exists.outcome == 'success' }}
run: |
DATE="$(date +"%Y-%m-%d %H:%M:%S")"
CHANGE_LABEL="duckdb/duckdb#${{ steps.vendor.outputs.vendor_rev }}"
CHANGE_URL="https://github.com/duckdb/duckdb/commit/${{ steps.vendor.outputs.vendor_rev }}"
MSG=" - [${CHANGE_LABEL}](${CHANGE_URL}) imported at ${DATE}"
echo "PR message: ${MSG}"
echo "pr_msg=${MSG}" >> "${GITHUB_OUTPUT}"
- name: Create PR
id: create_pr
if: ${{ steps.prepare_pr_message.outcome == 'success' && steps.check_pr_exists.outputs.pr_exists == 'false' }}
env:
# We cannot use default workflow's GITHUB_TOKEN here, because
# it is restricted to not trigger 'pull_request' event that
# we need to dispatch the testing workflow.
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
# Write multiline PR msg to a body.txt file
echo "Changes:" > body.txt
echo "${{ steps.prepare_pr_message.outputs.pr_msg }}" >> body.txt
# Remove empty lines
sed -i '/^$/d' body.txt
gh pr create \
--head "vendoring-${{ github.ref_name }}" \
--base "${{ github.ref_name }}" \
--title "${{ steps.commit_and_push.outputs.commit_msg }}" \
--body-file body.txt
- name: Update PR
id: update_pr
if: ${{ steps.prepare_pr_message.outcome == 'success' && steps.check_pr_exists.outputs.pr_exists == 'true' }}
env:
# We cannot use default workflow's GITHUB_TOKEN here, because
# it is restricted to not trigger 'pull_request' event that
# we need to dispatch the testing workflow.
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
# Write existing PR body text to a file
gh pr view vendoring-${{ github.ref_name }} --json body --jq '.body' > body.txt
# Append change description
echo "${{ steps.prepare_pr_message.outputs.pr_msg }}" >> body.txt
# Remove empty lines
sed -i '/^$/d' body.txt
gh pr edit ${{ steps.check_pr_exists.outputs.pr_num }} \
--title "${{ steps.commit_and_push.outputs.commit_msg }}" \
--body-file body.txt
# Close and re-open the PR to trigger the tests
gh pr close ${{ steps.check_pr_exists.outputs.pr_num }}
gh pr reopen ${{ steps.check_pr_exists.outputs.pr_num }}