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

Add GOCACHE in build.sh #116

Merged
merged 14 commits into from
Jan 16, 2023
Merged

Conversation

leventov
Copy link
Contributor

Fixes #108

xgo.go Outdated Show resolved Hide resolved
@techknowlogick
Copy link
Owner

🤔 hmmm... CI fail is kinda related, I wonder if it is due to base not being rebuilt.

@leventov
Copy link
Contributor Author

@techknowlogick what do you mean by "base not being rebuilt"?

@techknowlogick
Copy link
Owner

@leventov the base docker image, however I've toggled it on to build fresh for this PR and it still fails in same way, so that sadly wasn't the issue. Now I am rather confused as in theory that directory should be writeable, I wonder if it fails because it is created inside the docker container with root permissions and perhaps outside the docker container the CI runs with non-root user

@bearsh
Copy link
Contributor

bearsh commented May 25, 2021

the problems seems to be that the .xgo-cache folder in the home directory is created from inside the container as root.

$ ls -la . | grep .xgo
drwxr-xr-x   2 root   root        4096 Jun 15  2020 .xgo-cache

so it's not writable by this code:

if err := os.MkdirAll(gocache, 0641); err != nil {
	log.Fatalf("Failed to create gocache dir: %v.", err)
}

I think .xgo-cache should be owned by the user and ideally also I files inside it. so xgo should create that folder initially (and error if it's already present with wrong ownership with a message how to fix it). hopefully it's working when the
build script calls chown -R --reference /gochache /gocache/* at the end like it does already on the /build folder.

xgo.go Outdated
@@ -315,11 +315,17 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string
re := regexp.MustCompile("([A-Z]):")
folder_w := filepath.ToSlash(re.ReplaceAllString(folder, "/$1"))
depsCache_w := filepath.ToSlash(re.ReplaceAllString(depsCache, "/$1"))
gocache := filepath.Join(depsCache, "gocache")
if err := os.MkdirAll(gocache, 0641); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this 0641 intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was an attempt to shrink down from 644 suggested above: #116 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is supposed to be a directory 0644 = rw-r--r-- which means you can't actually traverse the directory

This should be 0755 or 0750

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm gonna push up an update

@leventov
Copy link
Contributor Author

@bearsh please feel free to recreate or fix this PR if you understand how to fix it.

@aadog aadog mentioned this pull request Nov 4, 2022
@zeripath
Copy link
Collaborator

I think I've fixed this now.

@zeripath
Copy link
Collaborator

Refixed conflicts

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Collaborator

I'll rebase this once #194 is in.

@zeripath
Copy link
Collaborator

Conflicts re-resolved

@techknowlogick techknowlogick merged commit 22d7aee into techknowlogick:main Jan 16, 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.

Cache build results across xgo runs
5 participants