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

Build multi OS for Docker #452

Merged
merged 22 commits into from
Jul 14, 2024
Merged

Build multi OS for Docker #452

merged 22 commits into from
Jul 14, 2024

Conversation

williamdes
Copy link
Contributor

@williamdes williamdes commented Jul 14, 2024

Fixes #451
Fixes #450

Copy link

codecov bot commented Jul 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.60%. Comparing base (bf2c594) to head (ebd2ee0).
Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #452      +/-   ##
==========================================
- Coverage   69.85%   69.60%   -0.26%     
==========================================
  Files          55       55              
  Lines        4249     4250       +1     
  Branches     3906     3909       +3     
==========================================
- Hits         2968     2958      -10     
- Misses       1281     1292      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@williamdes

This comment was marked as resolved.

Dockerfile Show resolved Hide resolved
@SimonKagstrom
Copy link
Owner

Man, you work so quickly! :-)

For now build tests do not pass on Alpine, I added a new workflow Can you help ? It looks like some cmake guru is needed:

/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../libssp_nonshared.a when searching for -lssp_nonshared
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/libssp_nonshared.a when searching for -lssp_nonshared

OK, so the fork-32 test fail to build (it appears, from the logs). The test was not really working anyway, so I removed it in master. Perhaps you could try to merge/rebase onto that?

By the way, did you forget this ?:

commit b31bdf569202087aa34681136ef0fee71e021cbc (HEAD -> multi-dist)
Author: William Desportes <[email protected]>
Date:   Sun Jul 14 12:19:47 2024 +0200

    chore: bump to v43

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 98608be..950cfd2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required (VERSION 3.12)
 project (kcov)
 
-set (PROJECT_VERSION_MAJOR 39)
+set (PROJECT_VERSION_MAJOR 43)

Yeah, I did! The git tag is what mostly determines the version. This is for some cmakery that another guy contributed, so I'm not completely sure why it's needed. But feel free to update it!

@williamdes
Copy link
Contributor Author

Man, you work so quickly! :-)

Haha, 10 years of work ;p

OK, so the fork-32 test fail to build (it appears, from the logs). The test was not really working anyway, so I removed it in master. Perhaps you could try to merge/rebase onto that?

Done

Yeah, I did! The git tag is what mostly determines the version. This is for some cmakery that another guy contributed, so I'm not completely sure why it's needed. But feel free to update it!

Maybe we should remove the Cmakelist stuff and determine the version from that constant(s) ?

@williamdes
Copy link
Contributor Author

It looks like I have the same result as when I tried to make tests work into the Docker image
See: https://github.com/williamdes/kcov/actions/runs/9927752250/job/27423092490#step:5:285

No tests seem to pass, not sure why

@SimonKagstrom
Copy link
Owner

It looks like I have the same result as when I tried to make tests work into the Docker image See: https://github.com/williamdes/kcov/actions/runs/9927752250/job/27423092490#step:5:285

No tests seem to pass, not sure why

Might be several reasons, I think. For one, it seems like maybe /sbin is not part of the PATH:

runTest (test_compiled.debuglink.runTest) ... sh: rm: not found
sh: cp: not found
objcopy: 'build-tests/main-tests-debug-file': No such file
sh: cp: not found
sh: cp: not found

but my guess is that this is caused by the alpine image not being run with --security-opt seccomp=unconfined, or alternatively that the builder runs qemu, in which case it's the same error as with the non-x86 linuxes.

Anyway, I'm OK with just building it under alpine, so if there's no easy fix, then I think we should just disable the tests there (like non-x86:es).

@SimonKagstrom
Copy link
Owner

Yeah, I did! The git tag is what mostly determines the version. This is for some cmakery that another guy contributed, so I'm not completely sure why it's needed. But feel free to update it!

Maybe we should remove the Cmakelist stuff and determine the version from that constant(s) ?

I can take a look at that. I guess the version should be settable from the git tag for starters at least.

@williamdes
Copy link
Contributor Author

Thank you for the last commit, is there a way that I can call the function and get the output ?
Like I would have done with a Makefile
So I can use the output in the build docker shell script

@SimonKagstrom
Copy link
Owner

Thank you for the last commit, is there a way that I can call the function and get the output ? Like I would have done with a Makefile So I can use the output in the build docker shell script

Well, my commit actually didn't build on github (yes, I should have used a branch first...). I think it's due to missing tags, so I'll attempt to repair it before reverting it.

I'm not quite sure I understand what you want? You mean the version? If you have built kcov, you can get it via

ska@Simons-MacBook-Air kcov % src/kcov --version
kcov v42-149-g4cb9

@williamdes
Copy link
Contributor Author

fatal: No names found, cannot describe anything.

Same as me today, see ad89c0f

You need to have fetch depth 0 or some other depth or maybe just try to enable fetch tags ?

I'm not quite sure I understand what you want? You mean the version? If you have built kcov, you can get it via

Indeed, but is there a way to get it before the build as I need to inject the version built into the metadata before launching docker

@SimonKagstrom
Copy link
Owner

The latest master should build again.

I guess it might be possible to replicate in ci.yml? It's really just boils down to git describe --abbrev=4 --tags HEAD (maybe with --git-dir).

@williamdes
Copy link
Contributor Author

The latest master should build again.

Yay, can you try only switching on the fetch-tags with a fetch depth of 100 maybe ?
Just trying to lower the number of commits fetched for each CI run 😄

I guess it might be possible to replicate in ci.yml? It's really just boils down to git describe --abbrev=4 --tags HEAD (maybe with --git-dir).

Not sure what you mean here

@@ -26,7 +26,7 @@ def runTest(self):
class lookup_binary_in_path(libkcov.TestCase):
@unittest.expectedFailure
def runTest(self):
os.environ["PATH"] += self.sources + "/tests/python"
os.environ["PATH"] += os.pathsep + self.sources + "/tests/python"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the patch needed to fix things up

 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:./tests/python

without the separator nothing works correctly, and rm, mv and friends can not be found

Copy link
Owner

Choose a reason for hiding this comment

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

Wow, good catch!

I wonder why it was like that? I guess maybe self.sources was an absolute path in some cases, and a relative one in another. Anyhow, good that it's fixed!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Best guess the last path in the list was not that important, but not on Alpine haha
Always add the separator 😄

@williamdes williamdes marked this pull request as ready for review July 14, 2024 17:04
Dockerfile Show resolved Hide resolved
container:
image: alpine:3.20
# Needed to attach to a binary
options: --security-opt seccomp=unconfined
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe, as you suggested, add this to the instructions somewhere? I guess the docker info can be placed in a doc/docker.md file, to reduce the clutter in README.md.

@SimonKagstrom
Copy link
Owner

--security-opt seccomp=unconfined

That was it, it should be documented somewhere in this project What is the exact kernel capability kcov needs ? https://docs.docker.com/engine/security/seccomp/#significant-syscalls-blocked-by-the-default-profile

ptrace definately, and probably process_vm_readv/process_vm_writev and personality.

@williamdes
Copy link
Contributor Author

It should be okay now, I updated the platform list for Debian. They do not have riscv64

kcov needs access the following system calls:
- [`ptrace`](https://linux.die.net/man/2/ptrace)
- [`process_vm_readv`](https://linux.die.net/man/2/process_vm_readv)/[`process_vm_writev`](https://linux.die.net/man/2/process_vm_writev)
- [`personality`](https://linux.die.net/man/2/personality)
Copy link
Owner

Choose a reason for hiding this comment

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

Well written with references!

@SimonKagstrom SimonKagstrom merged commit 1e383e5 into SimonKagstrom:master Jul 14, 2024
9 checks passed
@SimonKagstrom
Copy link
Owner

Merged, thanks a lot!

@williamdes
Copy link
Contributor Author

Currently waiting on the Docker build to fail push (workflow dispatch is very cool !) after build success: https://github.com/williamdes/kcov/actions/runs/9929723485
image

@williamdes
Copy link
Contributor Author

Merged, thanks a lot!

Thank you too for this very nice and active collaboration !
Let's monitor the build jobs 🤞🏻

@SimonKagstrom
Copy link
Owner

I'm sure it will build fie!

I saw the workflow_dispatch stuff, something to read up on in the future!

@williamdes
Copy link
Contributor Author

Something I am a bit unsure about is why it looks like the docker build also triggers for PRs, maybe a side effect of workflow dispatch

@williamdes williamdes deleted the multi-dist branch July 17, 2024 11:32
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.

ci: Build in Alpine Linux as well docker: Build for debian by default
2 participants