Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] Unexpected working directory since recent update #1767

Closed
Flamefire opened this issue Feb 14, 2025 · 3 comments · Fixed by #1768
Closed

[BUG] Unexpected working directory since recent update #1767

Flamefire opened this issue Feb 14, 2025 · 3 comments · Fixed by #1768
Assignees
Labels
Area: Report Upload Issues with pre-ingest report uploading bug Something isn't working Eng Area: Codecov GitHub Action Medium Medium Priority Issues (to be fixed or re-evaluated in 3 months

Comments

@Flamefire
Copy link
Contributor

Describe the bug

(I think) since one of the updates at/on v4/v5 the default working directory of the action is changed.
Previously it seemed to always run in $GITHUB_WORKSPACE but now it uses whatever folder is set by the previous step.

This is a problem because the relevant source files will not be found, especially due to a bug in the CLI tool and hence the path fixup are not done and the coverage report will be wrong, e.g. showing many new files that cannot be associated with files in the repo

To Reproduce
Steps to reproduce the behavior:

  1. Create coverage data
  2. Use the codecov-action as a step
  3. Change to a folder that doesn't have a git repo, e.g. /tmp, in the step before that
  4. In my case the coverage file on codecov.io has all absolute paths starting with /__w/

Expected behavior
Default working-directory should likely be $GITHUB_WORKSPACE such that the report is correct.

Regression
Not exactly sure which version did work or if this was a change from GitHub actions triggering this

Product Area
Coverage

Versions

  • OS: Linux
  • Git Host: GitHub
  • CI/CD: GitHub Actions
  • Uploader: codecov-action@v5.3.1

Commit and CI link
CI run

==> Running upload-coverage
      ./codecov --verboseupload-coverage -t <redacted> --fail-on-error --git-service github --sha 34098f5b52a5864e4afcdcf24ed62ad71a4e9487 --disable-search --file coverage.all.info --file coverage.iconv.info --file coverage.icu.info --gcov-executable gcov --name Github Actions
info - 2025-02-13 13:50:54,380 -- ci service found: github-actions
debug - 2025-02-13 13:50:54,382 -- versioning system found: <class 'codecov_cli.helpers.versioning_systems.NoVersioningSystem'>
debug - 2025-02-13 13:50:54,384 -- versioning system found: <class 'codecov_cli.helpers.versioning_systems.NoVersioningSystem'>
debug - 2025-02-13 13:50:54,384 -- Loading config from /__w/locale/locale/.codecov.yml
debug - 2025-02-13 13:50:54,404 -- Starting upload coverage --- {"verbose": true, "auto_load_params_from": null, "codecov_yml_path": null, "enterprise_url": null, "disable_telem": false, "version": "cli-10.0.1", "command": "upload-coverage", "fail_on_error": true, "git_service": "github", "commit_sha": "34098f5b52a5864e4afcdcf24ed62ad71a4e9487", "disable_search": true, "gcov_executable": "gcov", "name": "Github Actions", "slug": "boostorg/locale", "report_code": "default", "network_root_folder": "/__w/locale/locale", "files_search_root_folder": "/__w/locale/locale", "files_search_exclude_folders": [], "disable_file_fixes": false, "build_code": "13308852149", "build_url": "https://github.com/boostorg/locale/actions/runs/13308852149", "job_code": "CI", "branch": "ci", "pull_request_number": "260", "env_vars": {}, "flags": [], "plugin_names": ["xcode", "gcov", "pycoverage"], "dry_run": false, "use_legacy_uploader": false, "handle_no_reports_found": false, "report_type": "coverage", "network_filter": null, "network_prefix": null, "gcov_args": null, "gcov_ignore": null, "gcov_include": null, "swift_project": null, "parent_sha": null}
debug - 2025-02-13 13:50:54,404 -- Selected preparation plugins --- {"selected_plugins": ["<class 'codecov_cli.plugins.xcode.XcodePlugin'>", "<class 'codecov_cli.plugins.gcov.GcovPlugin'>", "<class 'codecov_cli.plugins.pycoverage.Pycoverage'>"], "cli_config": {}}
debug - 2025-02-13 13:50:54,404 -- Running preparation plugin: <class 'codecov_cli.plugins.xcode.XcodePlugin'>
debug - 2025-02-13 13:50:54,405 -- Running xcode plugin...
warning - 2025-02-13 13:50:54,405 -- xcrun is not installed or can't be found.
debug - 2025-02-13 13:50:54,405 -- Running preparation plugin: <class 'codecov_cli.plugins.gcov.GcovPlugin'>
debug - 2025-02-13 13:50:54,405 -- Running gcov plugin...
warning - 2025-02-13 13:50:54,410 -- No gcov data found.
debug - 2025-02-13 13:50:54,410 -- Running preparation plugin: <class 'codecov_cli.plugins.pycoverage.Pycoverage'>
warning - 2025-02-13 13:50:54,410 -- coverage.py is not installed or can't be found.
debug - 2025-02-13 13:50:54,410 -- Collecting relevant files
info - 2025-02-13 13:50:54,420 -- Found 3 coverage files to report
info - 2025-02-13 13:50:54,420 -- > /__w/locale/locale/coverage.iconv.info
info - 2025-02-13 13:50:54,420 -- > /__w/locale/locale/coverage.all.info
info - 2025-02-13 13:50:54,420 -- > /__w/locale/locale/coverage.icu.info
debug - 2025-02-13 13:50:54,420 -- Selected uploader to use: <class 'codecov_cli.services.upload.upload_sender.UploadSender'>
debug - 2025-02-13 13:50:54,458 -- Sending upload request to Codecov
info - 2025-02-13 13:50:54,941 -- Your upload is now processing. When finished, results will be available at: https://app.codecov.io/github/boostorg/locale/commit/34098f5b52a5864e4afcdcf24ed62ad71a4e9487
debug - 2025-02-13 13:50:54,941 -- Upload request to Codecov complete. --- {"response": {"raw_upload_location": "https://storage.googleapis.com/codecov-production/shelter/github/boostorg%3A%3A%3A%3Alocale/34098f5b52a5864e4afcdcf24ed62ad71a4e9487/d57853bc-c04e-440c-94bf-8fd7a7e4e58b.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EJWQHUGIBILH4J7Q6ZUSCIFNEOLYSNDS7L3B4N5SIBQ2J4YLYE5CRFCD%2F20250213%2Fus%2Fs3%2Faws4_request&X-Amz-Date=20250213T135054Z&X-Amz-Expires=30&X-Amz-SignedHeaders=host&X-Amz-Signature=2d1783818e8156496e87f40a2a1a4cef313c991856bf224ca3c2bfe7297b5a70", "url": "https://app.codecov.io/github/boostorg/locale/commit/34098f5b52a5864e4afcdcf24ed62ad71a4e9487"}}
debug - 2025-02-13 13:50:54,941 -- Sending upload to storage
info - 2025-02-13 13:50:55,191 -- Process Upload complete
debug - 2025-02-13 13:50:55,192 -- Upload result --- {"result": "RequestResult(error=None, warnings=[], status_code=200, text='')"}
@Flamefire Flamefire added the bug Something isn't working label Feb 14, 2025
@thomasrockhu-codecov thomasrockhu-codecov added Medium Medium Priority Issues (to be fixed or re-evaluated in 3 months Eng Area: Codecov GitHub Action Area: Report Upload Issues with pre-ingest report uploading labels Feb 14, 2025
@thomasrockhu-codecov thomasrockhu-codecov self-assigned this Feb 14, 2025
@Flamefire
Copy link
Contributor Author

Flamefire commented Feb 15, 2025

I suspect that this is not the actual issue but rather a symlink issue:
The action runs git config --global --add safe.directory /home/runner/work/locale/locale

The uploader later runs git rev-parse --show-toplevel which fails without the above leading to an empty network. (A patch of mine would help to detect this more easily)

I did that manually:

      - name: Debug coverage
        run: |
          echo "PWD: $PWD -- $(pwd)"
          echo "WD: ${{github.workspace}}"
          echo "Canonical: $(readlink -f ${{github.workspace}})"
          echo "Canonical: $(readlink -f $PWD)"
          git status
          git rev-parse --show-toplevel
        working-directory: ${{github.workspace}}

Output:

PWD: /__w/locale/locale -- /__w/locale/locale
WD: /home/runner/work/locale/locale
Canonical: 
Canonical: /__w/locale/locale
fatal: detected dubious ownership in repository at '/__w/locale/locale'
To add an exception for this directory, call:

	git config --global --add safe.directory /__w/locale/locale

So the git commands all fail because the safe.directory uses the "wrong" path

I found this in the output of the checkout action:

 Temporarily overriding HOME='/__w/_temp/359bd767-00ec-4698-988d-74cb927b839b' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
/usr/bin/git config --global --add safe.directory /__w/locale/locale
Deleting the contents of '/__w/locale/locale'

So that does the right thing but only in a temporary folder.

Edit: Not a necessarily a symlink issue: The job runs in a container, which is a change on our side as before we didn't use a container.

@thomasrockhu-codecov
Copy link
Contributor

@Flamefire oh this is fascinating, there is an option to turn off safe directory setting in the Action with disable_safe_directory: true. Would that solve this issue?

@Flamefire
Copy link
Contributor Author

Flamefire commented Feb 15, 2025

I'll try but I don't see how. I mean this just does not add the (wrong) directory so the "right" one will still be missing causing the error.

I think a solution is to use $GITHUB_WORKSPACE instead of ${{github.workspace}} at

git config --global --add safe.directory ${{ github.workspace }}

I did a quick check:

$ echo "${{github.workspace}} $GITHUB_WORKSPACE"
/home/runner/work/locale/locale /__w/locale/locale 

Edit: disable_safe_directory: true didn't help. I opened a PR: #1768

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area: Report Upload Issues with pre-ingest report uploading bug Something isn't working Eng Area: Codecov GitHub Action Medium Medium Priority Issues (to be fixed or re-evaluated in 3 months
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants