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

Allow rake to remove toolchaing, clean before testing #350

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

jbartosik
Copy link
Contributor

I've hit two problems:

  1. Running rake then rake test would fail[1]. To address this I run codegen:clean before test
  2. Runig rake codegen:clean would fail[2]. To address this I add write permission to the toolchain dir before attemmpting to remove it.

[1]

$ rake test
  2 go list ./... | grep -v vendor | xargs go test -v
  3 pattern ./...: directory toolchains/pkg/mod/github.com/fatih/camelcase@v1.0.0 outside main module or its selected dependencies

[2]

$ rake codegen:clean
rm -rf /Users/joachim.bartosik/go/src/github.com/DataDog/agent-payload/toolchains/gogo
rm -rf /Users/joachim.bartosik/go/src/github.com/DataDog/agent-payload/toolchains
rm: cannot remove '/Users/joachim.bartosik/go/src/github.com/DataDog/agent-payload/toolchains/pkg/mod/github.com/envoyproxy/protoc-gen-validate@v0.10.1/main.go': Permission denied
rake aborted!
Command failed with status (1): [rm -rf /Users/joachim.bartosik/go/src/gith...]
/Users/joachim.bartosik/go/src/github.com/DataDog/agent-payload/Rakefile:36:in `block (2 levels) in <top (required)>'
Tasks: TOP => codegen:clean
(See full trace by running task with --trace)

Motivation

I want to run rake test and have it work.

Reviewers: please see the review guidelines.

I've hit two problems:
1. Running `rake` then `rake test` would fail[1]. To address this I run
   `codegen:clean` before test
2. Runig `rake codegen:clean` would fail[2]. To address this I add write
   permission to the toolchain dir before attemmpting to remove it.

[1]
```bash
$ rake test
  2 go list ./... | grep -v vendor | xargs go test -v
  3 pattern ./...: directory toolchains/pkg/mod/github.com/fatih/camelcase@v1.0.0 outside main module or its selected dependencies
```
[2]
```bash
$ rake codegen:clean
rm -rf /Users/joachim.bartosik/go/src/github.com/DataDog/agent-payload/toolchains/gogo
rm -rf /Users/joachim.bartosik/go/src/github.com/DataDog/agent-payload/toolchains
rm: cannot remove '/Users/joachim.bartosik/go/src/github.com/DataDog/agent-payload/toolchains/pkg/mod/github.com/envoyproxy/protoc-gen-validate@v0.10.1/main.go': Permission denied
rake aborted!
Command failed with status (1): [rm -rf /Users/joachim.bartosik/go/src/gith...]
/Users/joachim.bartosik/go/src/github.com/DataDog/agent-payload/Rakefile:36:in `block (2 levels) in <top (required)>'
Tasks: TOP => codegen:clean
(See full trace by running task with --trace)
```
@@ -33,6 +33,9 @@ protoc_jsonschema_version="73d5723"
namespace :codegen do
task :clean do
sh "rm -rf #{gogo_dir}"
if Dir.exist?(toolchain_dir)
sh "chmod u+w -R #{toolchain_dir}"
Copy link
Member

Choose a reason for hiding this comment

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

Quetsion: Would it make more sense to add the permissions in the task that generates the proto files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm new here but I think that this is a good way to go around this - in most cases we don't want to overwrite anything in the directory so it's readonly

@jbartosik
Copy link
Contributor Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Oct 29, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in master is 2m.

Use /merge -c to cancel this operation!

@dd-mergequeue dd-mergequeue bot merged commit 008503f into master Oct 29, 2024
8 checks passed
@jbartosik jbartosik deleted the joachim-bartosik-rake-fix branch October 29, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants