canonical / action-publish

A Github action for publishing snaps
MIT License
35 stars 12 forks source link

action-publish fails to upload my snap to snapstore #10

Closed MehdiChinoune closed 3 years ago

MehdiChinoune commented 3 years ago

It was working, but recently it brokes.

I get this:

Sorry, an error occurred in Snapcraft:
[Errno 13] Permission denied: '/home/runner/.config/snapcraft/candid.cfg'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/cli/_errors.py", line 298, in _is_send_to_sentry
    with _CLIConfig(read_only=True) as cli_config:
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/config.py", line 57, in __enter__
    self.load()
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/config.py", line 73, in load
    with open(self.config_path) as f:
PermissionError: [Errno 13] Permission denied: '/home/runner/.config/snapcraft/cli.cfg'

Original exception was:
Traceback (most recent call last):
  File "/snap/snapcraft/6466/bin/snapcraft", line 33, in <module>
    sys.exit(load_entry_point('snapcraft==4.7.1', 'console_scripts', 'snapcraft')())
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/cli/store.py", line 810, in login
    store_client = storeapi.StoreClient(use_candid=experimental_login)
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/storeapi/_store_client.py", line 48, in __init__
    candid_has_credentials = http_clients.CandidClient.has_credentials()
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/storeapi/http_clients/_candid_client.py", line 37, in has_credentials
    return not CandidConfig().is_section_empty()
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/storeapi/http_clients/_config.py", line 32, in __init__
    self.load()
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/storeapi/http_clients/_config.py", line 92, in load
    elif self._get_config_path().exists():
  File "/snap/snapcraft/6466/usr/lib/python3.6/pathlib.py", line 1336, in exists
    self.stat()
  File "/snap/snapcraft/6466/usr/lib/python3.6/pathlib.py", line 1158, in stat
    return self._accessor.stat(self)
  File "/snap/snapcraft/6466/usr/lib/python3.6/pathlib.py", line 387, in wrapped
    return strfunc(str(pathobj), *args)
PermissionError: [Errno 13] Permission denied: '/home/runner/.config/snapcraft/candid.cfg'
Traceback (most recent call last):
  File "/snap/snapcraft/6466/bin/snapcraft", line 33, in <module>
    sys.exit(load_entry_point('snapcraft==4.7.1', 'console_scripts', 'snapcraft')())
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/cli/store.py", line 810, in login
    store_client = storeapi.StoreClient(use_candid=experimental_login)
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/storeapi/_store_client.py", line 48, in __init__
    candid_has_credentials = http_clients.CandidClient.has_credentials()
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/storeapi/http_clients/_candid_client.py", line 37, in has_credentials
    return not CandidConfig().is_section_empty()
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/storeapi/http_clients/_config.py", line 32, in __init__
    self.load()
  File "/snap/snapcraft/6466/lib/python3.6/site-packages/snapcraft/storeapi/http_clients/_config.py", line 92, in load
    elif self._get_config_path().exists():
  File "/snap/snapcraft/6466/usr/lib/python3.6/pathlib.py", line 1336, in exists
    self.stat()
  File "/snap/snapcraft/6466/usr/lib/python3.6/pathlib.py", line 1158, in stat
    return self._accessor.stat(self)
  File "/snap/snapcraft/6466/usr/lib/python3.6/pathlib.py", line 387, in wrapped
    return strfunc(str(pathobj), *args)
PermissionError: [Errno 13] Permission denied: '/home/runner/.config/snapcraft/candid.cfg'
Error: The process '/snap/bin/snapcraft' failed with exit code 1

The snap was built using destructive-mode

jhenstridge commented 3 years ago

I just kicked off a run of the action's own CI by upgrading its dependencies (which doesn't otherwise change its behaviour), and the integration test that uploads to the store passed without issue:

https://github.com/snapcore/action-publish/runs/2655591634?check_suite_focus=true

This is using the same revision of Snapcraft as shown in your errors, so it should be hitting the same code paths. Is the project you're working with public? At a minimum, it'd be useful to see the workflow yaml to try and determine what's going on.

MehdiChinoune commented 3 years ago

Yes, It's public https://github.com/Makhber/makhber/blob/master/snap/snapcraft.yaml Just to mention that after I have reverted to build snap using snapcore/action-build everything work as expected. the failure occurs when I build the snap using the destructive mode --destructive-mode (because it's 60-80% faster than snapcore/action-build)

jhenstridge commented 3 years ago

This is probably the bit causing problems:

https://github.com/Makhber/makhber/blob/12b4ac299eee2a5e9ff374e09281df13c8b7affd/.github/workflows/packaging.yml#L169-L173

My guess is that by running Snapcraft under sudo, it's probably left some files in $HOME that can't be read by the regular user account.

You could probably work around this by running sudo rm -rf $HOME/.config/snapcraft before calling action-publish. But I'd strongly suggest using snapcore/action-build@v1 to build your snap. The Github Actions runner VM image is not a clean build environment, having a lot of extra software installed. It avoids these kind of permission problems by running snapcraft as regular CI user account.

MehdiChinoune commented 3 years ago

This is probably the bit causing problems:

https://github.com/Makhber/makhber/blob/12b4ac299eee2a5e9ff374e09281df13c8b7affd/.github/workflows/packaging.yml#L169-L173

My guess is that by running Snapcraft under sudo, it's probably left some files in $HOME that can't be read by the regular user account.

You could probably work around this by running sudo rm -rf $HOME/.config/snapcraft before calling action-publish. But I'd strongly suggest using snapcore/action-build@v1 to build your snap. The Github Actions runner VM image is not a clean build environment, having a lot of extra software installed. It avoids these kind of permission problems by running snapcraft as regular CI user account.

It works.

Build time:

You can see clearly that action-build is very slow.