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

[v4] Randomly fails with yaml.constructor.ConstructorError #1297

Closed
Tracked by #386
susnux opened this issue Feb 18, 2024 · 1 comment
Closed
Tracked by #386

[v4] Randomly fails with yaml.constructor.ConstructorError #1297

susnux opened this issue Feb 18, 2024 · 1 comment
Assignees

Comments

@susnux
Copy link

susnux commented Feb 18, 2024

Using v4 the upload sometimes fails with:
yaml.constructor.ConstructorError: could not determine a constructor for the tag '!scrutinizer-ci.com'

This string is not part of our config:

comment:
  require_changes: true
  layout: "diff"

full log:

==> Running version v0.4.7
==> Running command '/home/runner/actions-runner/_work/_actions/codecov/codecov-action/v4/dist/codecov create-commit'
/home/runner/actions-runner/_work/_actions/codecov/codecov-action/v4/dist/codecov create-commit -C 7bc953dbf6d850bf43d5201ae36b0ac59fc0038d -Z
info - 2024-02-17 12:42:41,652 -- ci service found: github-actions
Traceback (most recent call last):
  File "codecov_cli/main.py", line 81, in <module>
  File "codecov_cli/main.py", line 77, in run
  File "click/core.py", line 1157, in __call__
  File "click/core.py", line 1078, in main
  File "click/core.py", line 1685, in invoke
  File "click/core.py", line 1434, in invoke
  File "click/core.py", line 783, in invoke
  File "click/decorators.py", line 33, in new_func
  File "codecov_cli/main.py", line 57, in cli
  File "codecov_cli/helpers/config.py", line 65, in load_cli_config
  File "yaml/__init__.py", line 125, in safe_load
  File "yaml/__init__.py", line 81, in load
  File "yaml/constructor.py", line 51, in get_single_data
  File "yaml/constructor.py", line 60, in construct_document
  File "yaml/constructor.py", line 408, in construct_yaml_seq
  File "yaml/constructor.py", line 129, in construct_sequence
  File "yaml/constructor.py", line 129, in <listcomp>
  File "yaml/constructor.py", line 100, in construct_object
  File "yaml/constructor.py", line 427, in construct_undefined
yaml.constructor.ConstructorError: could not determine a constructor for the tag '!scrutinizer-ci.com'
  in "<unicode string>", line 5, column 7:
        - !scrutinizer-ci.com
          ^

But I found from another project (maybe that config is also loaded (a parent directory)?), were we have this config:

codecov:
  branch: master
  ci:
  - drone.nextcloud.com
  - '!scrutinizer-ci.com'

comment: false

# Ignore project status check as our CI only runs PHP tests for PHP PRs and JS tests for JS PRs
# Otherwise it will warn about project coverage drops
coverage:
  status:
    project: off
    patch: off

But this config is valid from your validation:

cat codecov.yml | curl --data-binary @- https://codecov.io/validate
Valid!

{
  "codecov": {
    "branch": "master",
    "ci": [
      "drone.nextcloud.com",
      "!scrutinizer-ci.com"
    ]
  },
  "comment": false,
  "coverage": {
    "status": {
      "project": false,
      "patch": false
    }
  }
}
@joseph-sentry
Copy link

Hi @susnux,

The workflow checks out nextcloud/server at this commit: de0c7e10086c9504d4bcc8db82c086215ff3de6f and the codecov.yml for that commit is here. If you try to upload this file, it will be invalid. On the main branch of nextcloud/server this has been fixed by wrapping quotes around the !scrutinizer-ci.com.

However, this is not the main problem here as this is not the codecov.yml you intend to use for this upload.

The real issue though is that the Codecov CLI is not using the correct codecov.yml.

I believe that manually setting the --codecov-yml-path to the location of the codecov.yml you want to use should fix this.

I also believe that setting the working-directory of the codecov-action step in your CI to the directory that matches the git repo you are running the CI on, as you have done in previous steps in the workflow, should fix this issue as well.

Either way should work, and it's up to your preference.

Feel free to reply with any more questions you may have!

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

No branches or pull requests

3 participants