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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbartosik
Copy link

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/[email protected] 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/[email protected]/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/[email protected] 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/[email protected]/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?

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