canonical / grafana-agent-snap

Snap of Grafana Agent, a telemetry collector for sending metrics, logs and traces to the Grafana's LGTM stack.
https://snapcraft.io/grafana-agent
Apache License 2.0
1 stars 5 forks source link

update snap release workflow to work with `snapcraft>=8.2.0` #62

Closed ca-scribner closed 3 months ago

ca-scribner commented 3 months ago

snapcraft 8.2.0 introduced breaking changes to snapcraft remote-build:

  1. launchpad credentials have moved from $XDG_DATA_DIR/snapcraft/provider/launchpad/credentials to $XDG_DATA_DIR/snapcraft/launchpad-credentials
  2. release notes also mention "Instead of falling back to the legacy remote-builder, snapcraft will fail if a project is not in the top level of a git repository or is shallowly clone" -- grafana-agent-snap has the snap nested in the repo, so this might cause issues as well. not sure

(1) I think blocks this repo from releasing, as seen in the most recent failure for the release snap workflow run

ca-scribner commented 3 months ago

I think both (1) and (2) affect this repo.

To debug the release snap action run failure I've moved the credentials to ~/.local/share/snapcraft/launchpad-credentials. That resolves the issue where that action run hangs while asking the user to do 2FA, but it immediately hits a new error:

snapcraft remote-build --launchpad-accept-public-upload                                                                                                                                    
# remote-build is experimental and is subject to change. Use with caution.                                                                                                                                                                                     
# snapcraft internal error: RemoteBuildInvalidGitRepoError(brief='The Git repository is invalid for remote build.', details='Remote build for shallow cloned git repos are no longer supported')   
full log ``` 2024-05-28 17:39:33.955 Starting snapcraft, version 8.2.8.post35+gita00f1c43 2024-05-28 17:39:33.955 Log verbosity level set to BRIEF 2024-05-28 17:39:33.960 Configuring application... 2024-05-28 17:39:33.960 Preparing application... 2024-05-28 17:39:33.961 Build plan: platform=None, build_for=None 2024-05-28 17:39:33.961 Loading project file '/home/runner/work/grafana-agent-snap/grafana-agent-snap/snap/snapcraft.yaml' 2024-05-28 17:39:33.971 Processing grammar (on amd64 for amd64) 2024-05-28 17:39:33.971 Processing grammar for plugin: dump 2024-05-28 17:39:33.971 Processing grammar for source: ./snap/local 2024-05-28 17:39:33.971 Processing grammar for source-type: local 2024-05-28 17:39:33.971 Processing grammar for override-build: cp agent-wrapper $CRAFT_PART_INSTALL/ 2024-05-28 17:39:33.971 Processing grammar for plugin: go 2024-05-28 17:39:33.971 Processing grammar for source: https://github.com/grafana/agent 2024-05-28 17:39:33.971 Processing grammar for source-type: git 2024-05-28 17:39:33.971 Processing grammar for source-tag: v0.40.4 2024-05-28 17:39:33.971 Processing grammar for build-snaps: ['go'] 2024-05-28 17:39:33.971 Processing grammar for build-packages: ['build-essential', 'libsystemd-dev', 'libbpfcc-dev', 'bpfcc-tools'] 2024-05-28 17:39:33.971 Processing grammar for stage-packages: ['libsystemd0', 'libbpfcc', 'bpfcc-tools'] 2024-05-28 17:39:33.971 Processing grammar for override-build: export USE_CONTAINER=0 export GOFLAGS="-mod=readonly -tags=promtail_journal_enabled" make agent agentctl cp build/grafana-agent $CRAFT_PART_INSTALL/agent cp build/grafana-agentctl $CRAFT_PART_INSTALL/agentctl 2024-05-28 17:39:33.972 Running snapcraft remote-build on host 2024-05-28 17:39:33.972 remote-build is experimental and is subject to change. Use with caution. 2024-05-28 17:39:33.973 Setting up RequestService 2024-05-28 17:39:33.973 Emitter: Pausing control of the terminal 2024-05-28 17:39:35.822 Emitter: Resuming control of the terminal 2024-05-28 17:39:35.826 Architectures to build: [, ] 2024-05-28 17:39:35.830 Starting new build. It may take a while to upload large projects. 2024-05-28 17:39:35.830 snapcraft internal error: RemoteBuildInvalidGitRepoError(brief='The Git repository is invalid for remote build.', details='Remote build for shallow cloned git repos are no longer supported') 2024-05-28 17:39:35.832 Traceback (most recent call last): 2024-05-28 17:39:35.832 File "/snap/snapcraft/11801/lib/python3.10/site-packages/craft_application/application.py", line 517, in run 2024-05-28 17:39:35.832 return_code = dispatcher.run() or 0 2024-05-28 17:39:35.832 File "/snap/snapcraft/11801/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 487, in run 2024-05-28 17:39:35.832 return self._loaded_command.run(self._parsed_command_args) 2024-05-28 17:39:35.832 File "/snap/snapcraft/11801/lib/python3.10/site-packages/craft_application/commands/base.py", line 196, in run 2024-05-28 17:39:35.832 result = self._run(parsed_args, **kwargs) or result 2024-05-28 17:39:35.832 File "/snap/snapcraft/11801/lib/python3.10/site-packages/snapcraft/commands/remote.py", line 235, in _run 2024-05-28 17:39:35.832 builds = builder.start_builds( 2024-05-28 17:39:35.832 File "/snap/snapcraft/11801/lib/python3.10/site-packages/craft_application/services/remotebuild.py", line 125, in start_builds 2024-05-28 17:39:35.832 check_git_repo_for_remote_build(project_dir) 2024-05-28 17:39:35.832 File "/snap/snapcraft/11801/lib/python3.10/site-packages/craft_application/remote/git.py", line 112, in check_git_repo_for_remote_build 2024-05-28 17:39:35.832 raise RemoteBuildInvalidGitRepoError( 2024-05-28 17:39:35.832 craft_application.remote.errors.RemoteBuildInvalidGitRepoError: The Git repository is invalid for remote build. 2024-05-28 17:39:35.832 Remote build for shallow cloned git repos are no longer supported 2024-05-28 17:39:35.832 Full execution log: '/home/runner/.local/state/snapcraft/log/snapcraft-20240528-173933.954788.log' ```

which I think is issue (2) mentioned above. But, good news is that converting the shallow git clone to a full clone (git fetch --unshallow during debugging) unblocked snapcraft remote-build. So if we change the workflow's actions/checkout fetch-depth to 0 I think it'll work how we want.