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

fix: respect .gitignore in grafbase deploy #1394

Merged
merged 1 commit into from Mar 1, 2024
Merged

Conversation

obmarg
Copy link
Member

@obmarg obmarg commented Feb 29, 2024

A user was running into issues with grafbase deploy yesterday, where deployments failed with a bizzare error very similar to this one.

We eventually tracked this down to files in the users .direnv or .devenv folders - based on the tar-rs issue probably hard links of some description. While it would be good to not choke on hardlinks, I'd argue we shouldn't have been archiving these files in the first place: they're clearly meant to stay local to the users machine.

So this PR switches walkdir for ignore, which will respect .gitignore files etc, providing users with a sensible (and in most cases zero effort) way to exclude files from the archive we build on grafbase deploy. I think this is a sensible default.

This could have ramifications for anyone doing a grafbase deploy after some kind of local build step, though I don't know how likely that is really. I suggest we try it and see - if anyone complains we can revisit, maybe adding a CLI flag to change the behaviour.

Fixes GB-6107

A user was running into issues with `grafbase deploy` yesterday, where
deployments failed with a bizzare error very similar to [this one][1].

We eventually tracked this down to files in the users `.direnv` or `.devenv`
folders - based on the tar-rs issue _probably_ hard links of some description.
While it would be good to not choke on hardlinks, I'd argue we shouldn't have
been archiving these files in the first place: they're clearly meant to stay
local to the users machine.

So this PR switches `walkdir` for `ignore`, which will respect `.gitignore`
files etc, providing users with a sensible (and in most cases zero effort) way
to exclude files from the archive we build on `grafbase deploy`.  I think this
is a sensible default.

This _could_ have ramifications for anyone doing a `grafbase deploy` after some
kind of local build step, though I don't know how likely that is really.  I
suggest we try it and see - if anyone complains we can revisit, maybe adding a
CLI flag to change the behaviour.

[1]: alexcrichton/tar-rs#313
@obmarg obmarg requested a review from a team as a code owner February 29, 2024 10:50
Copy link

linear bot commented Feb 29, 2024

@yoav-lavi
Copy link
Collaborator

I think the original reasoning was build steps, but we could try this. Nice!

@yoav-lavi
Copy link
Collaborator

@obmarg although we could also explicitly ignore those dirs

@obmarg
Copy link
Member Author

obmarg commented Feb 29, 2024

@obmarg although we could also explicitly ignore those dirs

We could, but the set of files/directories we probably shouldn't be uploading is large. I don't think a blacklist approach is reasonable, without some way for users to add to that blacklist.

I think having miscellaneous files/folders that shouldn't be uploaded is a far more common case than having an additional build step, so prioritising that makes sense to me. Though happy to discuss if anyone agrees.

Copy link

Built binaries:

@obmarg obmarg merged commit eae2fee into main Mar 1, 2024
17 checks passed
@obmarg obmarg deleted the obmarg/push-lktxyzwvtpmn branch March 1, 2024 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants