codespell-project / actions-codespell

MIT License
74 stars 19 forks source link

Bug: `codespell` GH Actions throws with `UnboundLocalError: local variable 'tomllib' referenced before assignment` #59

Closed pcaversaccio closed 1 year ago

pcaversaccio commented 1 year ago

My codespell actions started to fail around 30mins ago with the following error (example run: https://github.com/pcaversaccio/snekmate/actions/runs/4367178830/jobs/7638639519).

##[debug]Evaluating condition for step: 'Run codespell'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Run codespell
##[debug]Loading inputs
##[debug]Loading env
Run codespell-project/actions-codespell@v1.0
  with:
    check_filenames: true
    skip: ./.git,yarn.lock
/usr/bin/docker run --name a5c76b7655e0d7e78b4e1499b[2](https://github.com/pcaversaccio/snekmate/actions/runs/4367178830/jobs/7638639519#step:4:2)6442c82d2c24_a02[3](https://github.com/pcaversaccio/snekmate/actions/runs/4367178830/jobs/7638639519#step:4:3)ed --label a5c76b --workdir /github/workspace --rm -e "INPUT_CHECK_FILENAMES" -e "INPUT_SKIP" -e "INPUT_CHECK_HIDDEN" -e "INPUT_EXCLUDE_FILE" -e "INPUT_BUILTIN" -e "INPUT_IGNORE_WORDS_FILE" -e "INPUT_IGNORE_WORDS_LIST" -e "INPUT_URI_IGNORE_WORDS_LIST" -e "INPUT_PATH" -e "INPUT_ONLY_WARN" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_DEBUG" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/snekmate/snekmate":"/github/workspace" a5c76b:7655e0d7e78b[4](https://github.com/pcaversaccio/snekmate/actions/runs/4367178830/jobs/7638639519#step:4:4)e1499b26442c82d2c24
::add-matcher::/home/runner/work/_temp/_github_workflow/codespell-matcher.json
##[debug]Added matchers: 'codespell-matcher-default', 'codespell-matcher-specified'. Problem matchers scan action output for known warning or error strings and report these inline.
Running codespell on '' with the following options...
Check filenames? 'true'
Checking filenames
Check hidden? ''
Exclude file ''
Skipping './.git,yarn.lock'
Builtin dictionaries ''
Ignore words file ''
Ignore words list ''
Ignore URI words list ''
Resulting CLI options  --check-filenames --skip ./.git,yarn.lock
Traceback (most recent call last):
  File "/usr/local/bin/codespell", line 8, in <module>
    sys.exit(_script_main())
  File "/usr/local/lib/python3.8/site-packages/codespell_lib/_codespell.py", line 987, in _script_main
    return main(*sys.argv[1:])
  File "/usr/local/lib/python3.8/site-packages/codespell_lib/_codespell.py", line 992, in main
    options, parser, used_cfg_files = parse_options(args)
  File "/usr/local/lib/python3.8/site-packages/codespell_lib/_codespell.py", line [5](https://github.com/pcaversaccio/snekmate/actions/runs/4367178830/jobs/7638639519#step:4:5)[6](https://github.com/pcaversaccio/snekmate/actions/runs/4367178830/jobs/7638639519#step:4:6)[8](https://github.com/pcaversaccio/snekmate/actions/runs/4367178830/jobs/7638639519#step:4:8), in parse_options
    data = tomllib.load(f).get("tool", {})
UnboundLocalError: local variable 'tomllib' referenced before assignment
Codespell found one or more problems
::remove-matcher owner=codespell-matcher-default::
##[debug]Removed matchers: 'codespell-matcher-default'
::remove-matcher owner=codespell-matcher-specified::
##[debug]Removed matchers: 'codespell-matcher-specified'
##[debug]Docker Action run completed with exit code 1
##[debug]Finishing: Run codespell

Running codespell locally with the latest version works.

larsoner commented 1 year ago

Thanks for the report, trying to fix in https://github.com/codespell-project/codespell/pull/2774, then will cut 2.2.4

larsoner commented 1 year ago

Should be all better now but reopen if not @pcaversaccio !

pcaversaccio commented 1 year ago

@larsoner nice, let me know once I can test the GH actions.

larsoner commented 1 year ago

Go ahead, should work now

pcaversaccio commented 1 year ago

Confirmed, it worked here https://github.com/pcaversaccio/snekmate/actions/runs/4367178830/jobs/7639696284. Thx for fixing it!