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

ci(github): Run Docker as the GitHub user to simplify code #8536

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

sschuberth
Copy link
Member

No description provided.

Copy link

codecov bot commented Apr 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.68%. Comparing base (bee7613) to head (5888ba5).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8536   +/-   ##
=========================================
  Coverage     67.68%   67.68%           
  Complexity     1006     1006           
=========================================
  Files           246      246           
  Lines          7924     7924           
  Branches        883      883           
=========================================
  Hits           5363     5363           
  Misses         2181     2181           
  Partials        380      380           
Flag Coverage Δ
funTest-docker 65.35% <ø> (ø)
funTest-non-docker 34.71% <ø> (ø)
test 37.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@sschuberth sschuberth force-pushed the gh-docker-run-user branch 12 times, most recently from 19acfef to 58522f7 Compare April 23, 2024 14:02
Group workspace-related `docker run` arguments for a better overview.

Signed-off-by: Sebastian Schuberth <[email protected]>
The `all-tools` target indirectly inherits from the `base` image which
has `ENTRYPOINT [ "/bin/bash" ]`.

Signed-off-by: Sebastian Schuberth <[email protected]>
Simplify the command string by setting the environment variable via the
dedicated `-e` option for Docker.

Signed-off-by: Sebastian Schuberth <[email protected]>
The `all-tools` target of the Docker image contains a `/home/ort`
directory that belongs to the Docker image's "ort" user (UID 1000), but
it does not contain a `/home/ort/.gradle` directory yet. Ideally, one
would like to simply mount `/home/runner/.gradle:/home/ort/.gradle`
without any `chown` magic, but that does not work as the Docker image's
user does not exist on the host and thus the directory is not
accessible. Also just running the Docker image as the host user does not
work, as the mount point's parent directory (`/home/ort`) belongs to
the Docker image's "ort" user, so Gradle cannot create any sub-directories
below `.gradle` as the host user.

As a solution, simply mount to a non-existing home directory in the
Docker image, and just choose that to be the same directory as on the
host (`/home/runner`). As now `HOME` needs to be set, let Gradle deduce
`GRADLE_USER_HOME` from it automatically.

Signed-off-by: Sebastian Schuberth <[email protected]>
@sschuberth sschuberth marked this pull request as ready for review April 23, 2024 15:07
@sschuberth sschuberth requested a review from a team as a code owner April 23, 2024 15:07
@mnonnenmacher
Copy link
Member

Did you already verify on a fork that the Gradle caching works? In this functional test job it doesn't (it starts with downloading Gradle) but that's expected as the GitHub actions cache is only populated from the main branch and I guess the changes invalidate the old cache.

@sschuberth
Copy link
Member Author

Did you already verify on a fork that the Gradle caching works?

No, I didn't explicitly test that. How would I do that, create a PR to my branch from a fork? Or can we merge first to main to ease testing, and revert the last commit of this PR if it unexpectedly doesn't work?

@mnonnenmacher
Copy link
Member

Did you already verify on a fork that the Gradle caching works?

No, I didn't explicitly test that. How would I do that, create a PR to my branch from a fork? Or can we merge first to main to ease testing, and revert the last commit of this PR if it unexpectedly doesn't work?

I tested everything within my fork, e.g. making a PR to the main branch within the fork. This was especially useful to test that the published Docker images were correct without messing with those in the main repository.

However, we can also merge as is and if caching doesn't work either fix or revert it.

@sschuberth sschuberth merged commit 69bdfd9 into main Apr 25, 2024
22 checks passed
@sschuberth sschuberth deleted the gh-docker-run-user branch April 25, 2024 09:59
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