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

Fix running git commands in CI tests under GitHub Actions #1397

Merged
merged 1 commit into from
Dec 15, 2022

Conversation

osma
Copy link
Member

@osma osma commented Dec 15, 2022

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:

uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)

Here is ls -l /app:

drwxr-xr-x   15 1001     ntp           4096 Dec 15 13:57 /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 the HOME environment variable. Then it executes the command git config --global --add safe.directory /app, which will prevent git 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

  • phpUnit tests pass locally with my changes
  • I have added tests that show that the new code works, or tests are not relevant for this PR (e.g. only HTML/CSS changes)
  • The PR doesn't reduce accessibility of the front-end code (e.g. tab focus, scaling to different resolutions, use of .sr-only class, color contrast)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@osma osma added this to the 2.17 milestone Dec 15, 2022
@osma osma self-assigned this Dec 15, 2022
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Dec 15, 2022

Codecov Report

Base: 71.17% // Head: 71.35% // Increases project coverage by +0.18% 🎉

Coverage data is based on head (ba237a1) compared to base (0a51dd5).
Patch has no changes to coverable lines.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1397      +/-   ##
============================================
+ Coverage     71.17%   71.35%   +0.18%     
  Complexity     1650     1650              
============================================
  Files            32       32              
  Lines          3788     3774      -14     
============================================
- Hits           2696     2693       -3     
+ Misses         1092     1081      -11     
Impacted Files Coverage Δ
controller/RestController.php 22.26% <0.00%> (-0.12%) ⬇️
controller/Honeypot.php 40.90% <0.00%> (ø)
controller/WebController.php 17.32% <0.00%> (+0.12%) ⬆️
model/ConceptMappingPropertyValue.php 83.67% <0.00%> (+0.84%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@osma osma added maintenance Dependency changes, security updates, infrastructure tweaks & general mainenance and removed bug labels Dec 15, 2022
@osma osma merged commit b13b2c4 into master Dec 15, 2022
@osma osma deleted the issue1394-ci-builds-fail branch December 15, 2022 14:44
@osma osma mentioned this pull request Dec 15, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Dependency changes, security updates, infrastructure tweaks & general mainenance tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI builds are failing due to dubious ownership in repository at '/app'
2 participants