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

Airbyte-ci: Allow airbyte-ci to run from anywhere in project #31412

Merged
merged 9 commits into from
Oct 19, 2023

Conversation

bnchrch
Copy link
Contributor

@bnchrch bnchrch commented Oct 13, 2023

Problem

You must run airbyte-ci from root

closes #31250

Solution

Just change the working directory when you run airbyte-ci to be root

Note for reviewer

Why changing the working directory instead of refactoring for absolute paths

Using absolute paths seemed more prone to error and a larger refactor

Example here: https://github.com/airbytehq/airbyte/pull/31409/files

Why do you set the working directory in two places

Because dagger run requires it set before invoked

and airbyte-ci-internal when run on its own also needs it set

@bnchrch bnchrch requested review from alafanechere and a team October 13, 2023 23:58
@vercel
Copy link

vercel bot commented Oct 13, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Oct 19, 2023 1:04am

@erohmensing
Copy link
Contributor

Hm, I'm afraid that being booted out of your working directory might not really solve the problem here - it still slows down the interaction cycle pretty significantly. That's an assumption, but something that might be worth asking our most receptive connector devs about.

If we could get around the setting it teice, is there a way we could change directory back to where we were at the end? Maybe some sort of with that keeps the context of where we were to get us back there?

Copy link
Contributor

@evantahler evantahler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent DX improvement. My comments are all nits.

Comment on lines 69 to 71
def get_airbyte_repo() -> git.Repo:
"""Get the airbyte repo."""
return git.Repo(search_parent_directories=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we throw if we aren't in a git repo at all?
That's done by the caller below 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate that the git repo we are in is, in fact, airbytehq/airbyte?

@@ -180,6 +203,7 @@ def airbyte_ci(
airbyte_ci.add_command(connectors)
airbyte_ci.add_command(metadata)
airbyte_ci.add_command(test)
set_working_directory_to_root()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fine, but do any child-commands or forks need to be in a certain directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Currently every airbyte-ci command is imported here and every airbyte-ci logic assumes airbyte/ as the working directory.


def set_working_directory_to_root() -> None:
"""Set the working directory to the root of the airbyte repo."""
os.chdir(get_airbyte_repo_path_with_fallback())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if we are changing the CWD, we should probably log something, like "Using /path/to/root as working directory"

@bnchrch
Copy link
Contributor Author

bnchrch commented Oct 16, 2023

@erohmensing I think theres a small misunderstanding about what os.chdir does.

Essentially each process has its own "working directory" meaning that the python program we run, wont change the directory that the terminal is targeting.

Its both why we dont have to reset the working directory back to the orginal and why I have to call set_working_directory_to_root() in two places, as

  1. The terminal has its own working directory
  2. and Dagger run (e.g. airbyte-ci) has its own working directory
  3. and airbyte-ci-internal does too.
image

@erohmensing
Copy link
Contributor

@bnchrch thanks for the explanation, that makes sense! I'll admit I was only going off of the PR description, I hadnt checked it out and tried it.

Copy link
Contributor

@erohmensing erohmensing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


If this command is run from outside the airbyte repo, it will not work properly.

Please run this command your local airbyte project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Please run this command your local airbyte project.
Please run this command in your local airbyte project.


logging.warning(warning_message)

return False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Looks like the return value is not used

@bnchrch bnchrch merged commit 95afbb2 into master Oct 19, 2023
20 checks passed
@bnchrch bnchrch deleted the bnchrch/airbyte-ci-anywhere branch October 19, 2023 01:26
ariesgun pushed a commit to ariesgun/airbyte that referenced this pull request Oct 23, 2023
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.

Update airbyte-ci to allow running from anywhere in airbyte repo
3 participants