Skip to content

Commit b494d1c

Browse files
CI: Add jobs to mirror issues (#88)
cc @Tishj
2 parents a0f7660 + 2eb83ca commit b494d1c

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Create or Label Mirror Issue
2+
on:
3+
discussion:
4+
types:
5+
- labeled
6+
issues:
7+
types:
8+
- labeled
9+
10+
env:
11+
GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }}
12+
TITLE_PREFIX: "[duckdb-python/#${{ github.event.issue.number || github.event.discussion.number }}]"
13+
PUBLIC_ISSUE_TITLE: ${{ github.event.issue.title }}
14+
15+
jobs:
16+
add_needs_reproducible_example_comment:
17+
if: github.event.label.name == 'needs reproducible example'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Add comment
21+
run: |
22+
cat > needs-reproducible-example-comment.md << EOF
23+
Thanks for opening this issue in the DuckDB-Python project's issue tracker! To resolve this issue, our team needs a reproducible example. This includes:
24+
25+
* A source code snippet which reproduces the issue.
26+
* The snippet should be self-contained, i.e., it should contain all imports and should use relative paths instead of hard coded paths (please avoid \`/Users/JohnDoe/...\`).
27+
* A lot of issues can be reproduced with plain SQL code executed in the [DuckDB command line client](https://duckdb.org/docs/api/cli/overview). For such issues, please open an issue in the [main DuckDB repository](https://github.com/duckdb/duckdb/).
28+
* If the script needs additional data, please share the data as a CSV, JSON, or Parquet file. Unfortunately, we cannot fix issues that can only be reproduced with a confidential data set. [Support contracts](https://duckdblabs.com/#support) allow sharing confidential data with the core DuckDB team under NDA.
29+
30+
For more detailed guidelines on how to create reproducible examples, please visit Stack Overflow's [“Minimal, Reproducible Example”](https://stackoverflow.com/help/minimal-reproducible-example) page.
31+
EOF
32+
gh issue comment --repo duckdb/duckdb-python ${{ github.event.issue.number || github.event.discussion.number }} --body-file needs-reproducible-example-comment.md
33+
34+
create_or_label_mirror_issue:
35+
if: github.event.label.name == 'reproduced' || github.event.label.name == 'under review'
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Remove 'needs triage' / 'under review' if 'reproduced'
39+
if: github.event.label.name == 'reproduced'
40+
run: |
41+
gh issue edit --repo duckdb/duckdb-python ${{ github.event.issue.number || github.event.discussion.number }} --remove-label "needs triage" --remove-label "under review" --remove-label "needs reproducible example"
42+
43+
- name: Remove 'needs triage' / 'reproduced' if 'under review'
44+
if: github.event.label.name == 'under review'
45+
run: |
46+
gh issue edit --repo duckdb/duckdb-python ${{ github.event.issue.number || github.event.discussion.number }} --remove-label "needs triage" --remove-label "reproduced"
47+
48+
- name: Remove 'needs triage' if 'expected behavior'
49+
if: github.event.label.name == 'expected behavior'
50+
run: |
51+
gh issue edit --repo duckdb/duckdb-python ${{ github.event.issue.number || github.event.discussion.number }} --remove-label "needs triage"
52+
53+
- name: Get mirror issue number
54+
run: |
55+
gh issue list --repo duckdblabs/duckdb-internal --search "${TITLE_PREFIX}" --json title,number --state all --jq ".[] | select(.title | startswith(\"$TITLE_PREFIX\")).number" > mirror_issue_number.txt
56+
echo "MIRROR_ISSUE_NUMBER=$(cat mirror_issue_number.txt)" >> $GITHUB_ENV
57+
58+
- name: Print whether mirror issue exists
59+
run: |
60+
if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then
61+
echo "Mirror issue with title prefix '$TITLE_PREFIX' does not exist yet"
62+
else
63+
echo "Mirror issue with title prefix '$TITLE_PREFIX' exists with number $MIRROR_ISSUE_NUMBER"
64+
fi
65+
66+
- name: Set label environment variable
67+
run: |
68+
if ${{ github.event.label.name == 'reproduced' }}; then
69+
echo "LABEL=reproduced" >> $GITHUB_ENV
70+
echo "UNLABEL=under review" >> $GITHUB_ENV
71+
else
72+
echo "LABEL=under review" >> $GITHUB_ENV
73+
echo "UNLABEL=reproduced" >> $GITHUB_ENV
74+
fi
75+
76+
- name: Create or label issue
77+
run: |
78+
if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then
79+
gh issue create --repo duckdblabs/duckdb-internal --label "$LABEL" --label "Python" --title "$TITLE_PREFIX - $PUBLIC_ISSUE_TITLE" --body "See https://github.com/duckdb/duckdb-python/issues/${{ github.event.issue.number || github.event.discussion.number }}"
80+
else
81+
gh issue edit --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --remove-label "$UNLABEL" --add-label "$LABEL"
82+
fi
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Update Mirror Issue
2+
on:
3+
discussion:
4+
types:
5+
- labeled
6+
issues:
7+
types:
8+
- closed
9+
- reopened
10+
11+
env:
12+
GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }}
13+
TITLE_PREFIX: "[duckdb-python/#${{ github.event.issue.number || github.event.discussion.number }}]"
14+
15+
jobs:
16+
update_mirror_issue:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Get mirror issue number
20+
run: |
21+
gh issue list --repo duckdblabs/duckdb-internal --search "${TITLE_PREFIX}" --json title,number --state all --jq ".[] | select(.title | startswith(\"$TITLE_PREFIX\")).number" > mirror_issue_number.txt
22+
echo "MIRROR_ISSUE_NUMBER=$(cat mirror_issue_number.txt)" >> $GITHUB_ENV
23+
24+
- name: Print whether mirror issue exists
25+
run: |
26+
if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then
27+
echo "Mirror issue with title prefix '$TITLE_PREFIX' does not exist yet"
28+
else
29+
echo "Mirror issue with title prefix '$TITLE_PREFIX' exists with number $MIRROR_ISSUE_NUMBER"
30+
fi
31+
32+
- name: Add comment with status to mirror issue
33+
run: |
34+
if [ "$MIRROR_ISSUE_NUMBER" != "" ]; then
35+
gh issue comment --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --body "The issue has been ${{ github.event.action }} (https://github.com/duckdb/duckdb-python/issues/${{ github.event.issue.number || github.event.discussion.number }})."
36+
fi
37+
38+
- name: Add closed label to mirror issue
39+
if: github.event.action == 'closed'
40+
run: |
41+
if [ "$MIRROR_ISSUE_NUMBER" != "" ]; then
42+
gh issue edit --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --add-label "public closed" --remove-label "public reopened"
43+
fi
44+
45+
- name: Reopen mirror issue and add reopened label
46+
if: github.event.action == 'reopened'
47+
run: |
48+
if [ "$MIRROR_ISSUE_NUMBER" != "" ]; then
49+
gh issue reopen --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER
50+
gh issue edit --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --add-label "public reopened" --remove-label "public closed"
51+
fi

0 commit comments

Comments
 (0)