jimporter / mike

Manage multiple versions of your MkDocs-powered documentation via Git
BSD 3-Clause "New" or "Revised" License
528 stars 47 forks source link

Unsupported Command in Github Actions #133

Closed anatoly-scherbakov closed 1 year ago

anatoly-scherbakov commented 1 year ago

I am seeing an error similar to #90 when running mike on GitHub Actions.

Traceback (most recent call last):
  File "/opt/actions-runner/_work/_tool/Python/3.10.9/x64/lib/python3.10/site-packages/mike/git_utils.py", line 196, in _write
    return self._pipe.stdin.write(data)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/actions-runner/_work/_tool/Python/3.10.9/x64/bin/mike", line 33, in <module>
    sys.exit(load_entry_point('mike==1.2.0.dev0', 'console_scripts', 'mike')())
  File "/opt/actions-runner/_work/_tool/Python/3.10.9/x64/lib/python3.10/site-packages/mike/driver.py", line 365, in main
    return args.func(parser, args)
  File "/opt/actions-runner/_work/_tool/Python/3.10.9/x64/lib/python3.10/site-packages/mike/driver.py", line 141, in deploy
    with commands.deploy(cfg, args.version, args.title, args.alias,
  File "/opt/actions-runner/_work/_tool/Python/3.10.9/x64/lib/python3.10/contextlib.py", line 142, in __exit__
    next(self.gen)
  File "/opt/actions-runner/_work/_tool/Python/3.10.9/x64/lib/python3.10/site-packages/mike/commands.py", line 93, in deploy
    commit.add_file(canonical_file)
  File "/opt/actions-runner/_work/_tool/Python/3.10.9/x64/lib/python3.10/site-packages/mike/git_utils.py", line 242, in add_file
    self._write_data(file_info.data)
  File "/opt/actions-runner/_work/_tool/Python/3.10.9/x64/lib/python3.10/site-packages/mike/git_utils.py", line 204, in _write_data
    self._write(data)
  File "/opt/actions-runner/_work/_tool/Python/3.10.9/x64/lib/python3.10/site-packages/mike/git_utils.py", line 198, in _write
    raise GitCommitError(self._stderr.decode('utf-8'))
mike.git_utils.GitCommitError: error writing commit:
  fatal: Unsupported command: nothing to commit, working tree clean
  fast-import: dumping crash report to .git/fast_import_crash_8385

Commands:

         pip install -U https://github.com/jimporter/mike/archive/master.zip
         export DOCS_VERSION="PR$(git status | cut --delimiter '/' --fields 2)"
         git config user.name github-actions
         git config user.email github-actions@github.com
         poetry run mike --debug deploy --update-aliases -t "$DOCS_VERSION" -m "$DOCS_VERSION" "$DOCS_VERSION"

I believe reason is different to #90 because git fast-import is available. When I add git fast-import --help to the pipeline I get this in CI output:

GIT-FAST-IMPORT(1)                Git Manual                GIT-FAST-IMPORT(1)

NAME
       git-fast-import - Backend for fast Git data importers
…

You can see that fast-import is printing a crash report file. Here is what that contains.

fast-import crash report:
    fast-import process: 10571
    parent process     : 10488
    at 2023-01-30 10:56:34 +0000

fatal: Unsupported command: nothing to commit, working tree clean

Most Recent Commands Before Crash
---------------------------------
  commit refs/heads/gh-pages
  committer github-actions <github-actions@github.com> 1675076[194](https://github.com/datafold/datafold/actions/runs/4043137530/jobs/6951703990#step:5:195) +0000
  data 44
  from 0452afcc3f9390f73c364b572998ea6d252c8d64
  D PR2710
* nothing to commit, working tree clean

Active Branch LRU
-----------------
    active_branches = 1 cur, 5 max

  pos  clock name
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1)      1 refs/heads/gh-pages

Inactive Branches
-----------------
refs/heads/gh-pages:
  status      : active loaded
  tip commit  : 373b796cfa2d844c06d604a0a8f96fb74567bc9b
  old tree    : 1f17611fddbb3bc47f71a9ac1230c43dd3e0308d
  cur tree    : 1f17611fddbb3bc47f71a9ac1230c43dd3e0308d
  commit clock: 1
  last pack   : 0

Marks
-----

-------------------
END OF CRASH REPORT
fast-import crash report:
    fast-import process: 11737
    parent process     : 11656
    at [202](https://github.com/datafold/datafold/actions/runs/4043137530/jobs/6951703990#step:5:203)3-01-30 11:01:05 +0000

In order to ensure full clone of the repo I use

     - uses: actions/checkout@v3
       with:
         fetch-depth: 0
jimporter commented 1 year ago

Your DOCS_VERSION is probably not what you intended. Its value is:

PR2710
nothing to commit, working tree clean

But this is also a bug in how mike escapes filenames, so I have a fix for that too. Thanks for the report.