Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📊 improve etl pr command #3634

Merged
merged 9 commits into from
Nov 27, 2024
Merged

📊 improve etl pr command #3634

merged 9 commits into from
Nov 27, 2024

Conversation

lucasrodes
Copy link
Member

@lucasrodes lucasrodes commented Nov 27, 2024

In the past, the only field that was mandatory when calling the etl pr command was the name of the branch. The name of the branch is not that important, given that it will not live for long. Instead, what we should be forcing users to care about is the PR title and category, which should help us organize PRs better.

From now on, the title and category are mandatory, but if the user doesn't type them in, the command will prompt them with available options.

Key points

  • The temporary branch's name is auto-generated to ensure no collisions. Its structure is {username}-{category}-{summary_of_the_title}-{hash}. E.g., lucasrodes-data-ucdp-update-sdf09. While long, this is still readable and doesn't force users to type in a name for a branch that will not long live. Optionally, the user can still use --work-branch` to define a custom name.
  • If you've created your branch already and want to merge to master without creating a new branch, just type etl pr "title of pr" --direct. Since this is an important change in how the command works, it makes sense that this is visible with a flag. Also, this is not the primary use case; therefore, the flag should be used.
  • Also, if you don't specify a category of your PR, the command will prompt you with the available options.
  • New option --private to have your staging server be private!

More details in --help:

Usage: etl pr [OPTIONS] TITLE [[data|bug|refactor|enhance|feature|docs|chore|style|wip|tests]]

This script creates a new draft pull request in GitHub, which starts a new staging server.

Arguments:

  • TITLE: The title of the PR. This must be given.
  • CATEGORY: The category of the PR. This is optional. If not given, the user will be prompted to choose one.

Main use case: Branch out from master to a temporary work_branch, and create a PR to merge work_branch -> master. You will be asked to choose a category. The value of work_branch will be auto-generated based on the title and the category.

# Without specifying a category (you will be prompted for a category)                                                                                                                   
etl pr "some title for the PR"                                                                                                                                                                                                                                                                                                                                         
# With a category                                                                                                                                                                       
etl pr "some title for the PR" data                                                                                                                                                                                                                                                             

Custom use case (1): Same as main use case, but with a specific branch name for the work_branch.

# Without specifying a category (you will be prompted for a category)
etl pr "some title for the PR"

# With a category
etl pr "some title for the PR" data

# With private stating server
etl pr "some title for the PR" --private

Custom use case (2): Create a pull request from current_branch to master.

etl pr "some title for the PR" --direct                                                                                                                                                  

Custom use case (3): Create a pull request from branch this-temporary-branch -> develop.

etl pr "some title for the PR" --direct --base-branch "develop" --work-branch "this-temporary-branch"                                                                                    
# Shorter                                                                                                                                                                               
etl pr "some title for the PR" --direct -b "develop" -w "this-temporary-branch"                                                                                                          
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --scope        -s  TEXT  Scope of the PR (only relevant if --title is given). This text will be preprended to the PR title. Examples: 'demography' for data work on this field,        │
│                          'etl.db' if working on specific modules, 'wizard', etc.                                                                                                       │
│ --work-branch  -w  TEXT  The name of the work branch to create. It is auto-generated based on the title and the category. If --direct is used, this is the PR source branch and        │
│                          defaults to the current branch.                                                                                                                               │
│ --base-branch  -b  TEXT  Name of the base branch. This is the branch to branch out from and merge back into. If --direct is used, this is the PR target branch.                        │
│                          [default: master]                                                                                                                                             │
│ --direct       -d        Directly create a PR from the current branch to the target branch (default: master).                                                                          │
│ --help                   Show this message and exit.                                                                                                                                   │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

@owidbot
Copy link
Contributor

owidbot commented Nov 27, 2024

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-pr-command

chart-diff: ✅ No charts for review.
data-diff: ✅ No differences found
Legend: +New  ~Modified  -Removed  =Identical  Details
Hint: Run this locally with etl diff REMOTE data/ --include yourdataset --verbose --snippet

Automatically updated datasets matching weekly_wildfires|excess_mortality|covid|fluid|flunet|country_profile|garden/ihme_gbd/2019/gbd_risk are not included

Edited: 2024-11-27 10:58:31 UTC
Execution time: 14.71 seconds

@lucasrodes lucasrodes marked this pull request as ready for review November 27, 2024 17:31
@lucasrodes lucasrodes merged commit 8ed55bc into master Nov 27, 2024
9 checks passed
@lucasrodes lucasrodes deleted the pr-command branch November 27, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants