Skip to content

Commit f1eea85

Browse files
committed
test
1 parent 3a90731 commit f1eea85

File tree

1 file changed

+98
-85
lines changed

1 file changed

+98
-85
lines changed

.github/workflows/cleanup_pypi.yml

Lines changed: 98 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,125 @@
1-
name: Cleanup PyPI
1+
name: Submodule Auto PR
22
on:
33
workflow_call:
44
inputs:
5-
environment:
6-
description: CI environment to run in (pypi-test or pypi-prod-nightly)
5+
duckdb-python-sha:
76
type: string
8-
required: true
9-
subcommand:
10-
description: List or Delete
11-
type: string
12-
default: delete
13-
verbosity:
14-
description: Tool verbosity ("verbose" or "debug")
7+
description: The commit to build against (defaults to latest commit of current ref)
8+
required: false
9+
duckdb-sha:
1510
type: string
16-
default: verbose
17-
secrets:
18-
PYPI_CLEANUP_OTP:
19-
description: PyPI OTP
11+
description: The DuckDB submodule commit or ref to build against
2012
required: true
21-
PYPI_CLEANUP_PASSWORD:
22-
description: PyPI password
13+
auto-land:
14+
type: boolean
15+
description: Immediately merge the PR
16+
default: false
17+
secrets:
18+
DUCKDBLABS_BOT_TOKEN:
19+
description: Github token of the DuckDBLabs bot
2320
required: true
2421
workflow_dispatch:
2522
inputs:
26-
subcommand:
27-
description: List or Delete
28-
type: choice
29-
required: true
30-
options:
31-
- list
32-
- delete
33-
default: list
34-
environment:
35-
description: CI environment to run in
36-
type: choice
37-
required: true
38-
options:
39-
- pypi-prod-nightly
40-
- pypi-test
41-
verbosity:
42-
description: Tool verbosity
43-
type: choice
23+
duckdb-python-sha:
24+
type: string
25+
description: The commit to build against (defaults to latest commit of current ref)
26+
required: false
27+
duckdb-sha:
28+
type: string
29+
description: The DuckDB submodule commit or ref to build against
4430
required: true
45-
options:
46-
- verbose
47-
- debug
48-
default: verbose
31+
auto-land:
32+
type: boolean
33+
description: Immediately merge the PR
34+
default: false
35+
36+
defaults:
37+
run:
38+
shell: bash
4939

5040
jobs:
51-
cleanup_pypi:
52-
name: Remove Nightlies from PyPI
41+
create_pr:
42+
name: Create PR to bump duckdb submodule to given SHA
5343
runs-on: ubuntu-latest
54-
environment:
55-
name: ${{ inputs.environment }}
56-
env:
57-
PYPI_CLEANUP_PASSWORD: ${{secrets.PYPI_CLEANUP_PASSWORD}}
58-
PYPI_CLEANUP_OTP: ${{secrets.PYPI_CLEANUP_OTP}}
5944
steps:
60-
- uses: actions/checkout@v4
45+
- name: Checkout DuckDB Python
46+
uses: actions/checkout@v4
6147
with:
48+
ref: ${{ inputs.duckdb-python-sha }}
6249
fetch-depth: 0
63-
- if: ${{ vars.PYPI_CLEANUP_USERNAME == '' }}
64-
run: |
65-
echo "Error: PYPI_CLEANUP_USERNAME is not set in CI environment '${{ inputs.environment }}'"
66-
exit 1
67-
- if: ${{ vars.PYPI_MAX_NIGHTLIES == '' }}
50+
submodules: true
51+
52+
- name: Checkout or Create Needed Branch
6853
run: |
69-
echo "Error: PYPI_MAX_NIGHTLIES is not set in CI environment '${{ inputs.environment }}'"
70-
exit 1
54+
git fetch --all
55+
head_sha=${{ inputs.duckdb-python-sha }}
56+
branch_name="vendoring-${{ github.ref_name }}"
57+
if [[ `git rev-parse --verify ${branch_name} 2>/dev/null` ]]; then
58+
# branch exists
59+
git checkout ${branch_name}
60+
else
61+
# new branch
62+
git checkout -b ${branch_name}
63+
fi
64+
[[ ${head_sha} ]] && git reset --hard ${head_sha} || true
7165
72-
- name: Install Astral UV
73-
uses: astral-sh/setup-uv@v7
74-
with:
75-
version: "0.9.0"
66+
- name: Checkout DuckDB at Given SHA
67+
run: |
68+
cd external/duckdb
69+
git fetch origin
70+
git checkout ${{ inputs.duckdb-sha }}
7671
77-
- name: Install dependencies
78-
run: uv sync --only-group pypi --no-install-project
72+
- name: Set Git User
73+
run: |
74+
git config --global user.email "[email protected]"
75+
git config --global user.name "DuckDB Labs GitHub Bot"
7976
80-
- name: List Stale Packages on PyPI
81-
if: inputs.subcommand == 'list'
77+
- name: Create PR to Bump DuckDB Submodule
8278
env:
83-
PYTHON_UNBUFFERED: 1
79+
GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }}
8480
run: |
85-
set -x
86-
uv run --no-sync python -u -m duckdb_packaging.pypi_cleanup \
87-
--${{ inputs.environment == 'pypi-prod-nightly' && 'prod' || 'test' }} \
88-
--max-nightlies ${{ vars.PYPI_MAX_NIGHTLIES }} \
89-
--${{ inputs.verbosity }} \
90-
list 2>&1 | tee cleanup_output
81+
# First commit and push
82+
git add external/duckdb
83+
git commit -m "Bump submodule"
84+
git push --force origin vendoring-${{ github.ref_name }}
85+
# create PR msg
86+
echo "Bump duckdb submodule:" > body.txt
87+
echo "- Target branch: ${{ github.ref_name }}" >> body.txt
88+
echo "- Date: $( date +"%Y-%m-%d %H:%M:%S" )" >> body.txt
89+
echo "- DuckDB SHA: ${{ inputs.duckdb-sha }}" >> body.txt
90+
echo "- Trigger: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> body.txt
91+
gh pr create \
92+
--head "vendoring-${{ github.ref_name }}" \
93+
--base ${{ github.ref_name }} \
94+
--title "[duckdb-labs bot] Bump DuckDB submodule" \
95+
--body-file body.txt > output.txt 2>&1
96+
# Show summary
97+
success=$?
98+
url=$( [[ $success ]] && gh pr view vendoring-${{ github.ref_name }} --json url --jq .url || true )
99+
echo "## Submodule PR Summary" >> $GITHUB_STEP_SUMMARY
100+
if [[ $success ]]; then
101+
echo "### PR created: [${url}](${url})" >> $GITHUB_STEP_SUMMARY
102+
else
103+
echo "### Failed to create PR" >> $GITHUB_STEP_SUMMARY
104+
fi
105+
echo '```' >> $GITHUB_STEP_SUMMARY
106+
cat output.txt >> $GITHUB_STEP_SUMMARY
107+
echo '```' >> $GITHUB_STEP_SUMMARY
108+
[[ $success ]] || exit 1
91109
92-
- name: Delete Stale Packages from PyPI
93-
if: inputs.subcommand == 'delete'
110+
- name: Automerge PR
111+
if: ${{ inputs.auto-land }}
94112
env:
95-
PYTHON_UNBUFFERED: 1
113+
GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }}
96114
run: |
97-
set -x
98-
uv run --no-sync python -u -m duckdb_packaging.pypi_cleanup \
99-
--${{ inputs.environment == 'pypi-prod-nightly' && 'prod' || 'test' }} \
100-
--max-nightlies ${{ vars.PYPI_MAX_NIGHTLIES }} \
101-
--${{ inputs.verbosity }} \
102-
delete --username "${{ vars.PYPI_CLEANUP_USERNAME }}" 2>&1 | tee cleanup_output
103-
104-
- name: PyPI Cleanup Summary
105-
run : |
106-
echo "## PyPI Cleanup Summary" >> $GITHUB_STEP_SUMMARY
107-
echo "* Subcommand: ${{ inputs.subcommand }}" >> $GITHUB_STEP_SUMMARY
108-
echo "* CI Environment: ${{ inputs.environment }}" >> $GITHUB_STEP_SUMMARY
109-
echo "* Output:" >> $GITHUB_STEP_SUMMARY
115+
gh pr merge vendoring-${{ github.ref_name }} > output.txt
116+
# Show summary
117+
success=$?
118+
if [[ $success ]]; then
119+
echo "### PR merged" >> $GITHUB_STEP_SUMMARY
120+
else
121+
echo "### Failed to auto-merge PR" >> $GITHUB_STEP_SUMMARY
122+
fi
110123
echo '```' >> $GITHUB_STEP_SUMMARY
111-
cat cleanup_output >> $GITHUB_STEP_SUMMARY
124+
cat output.txt >> $GITHUB_STEP_SUMMARY
112125
echo '```' >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)