|
| 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 |
0 commit comments