Fix running git commands in CI tests under GitHub Actions #1397
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reasons for creating this PR
GitHub Actions CI builds are currently failing because some tests are executing git commands, but git refuses to run because of a "dubious ownership" error. The error happens because the PHPUnit tests are run within a container as the root user, but the /app directory is owned by another user (uid 1001).
Here is
whoami
under the container:Here is
ls -l /app
:Link to relevant issue(s), if any
Description of the changes in this PR
The PR fixes the problem by first creating the directory
/home/runner
which doesn't exist within the container, even though it is the value of theHOME
environment variable. Then it executes the commandgit config --global --add safe.directory /app
, which will preventgit
from complaining about dubious ownership; this will be stored in the configuration file/home/runner/.gitconfig
where subsequent git commands (run from PHPUnit tests) will see it.Known problems or uncertainties in this PR
n/a
Checklist
.sr-only
class, color contrast)