axodotdev / axodotdev/cargo-dist
Support injecting steps in the plan job.
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 149
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 32
Description
I recently ran into an issue in a rust project when using crates from private repos. When the CI pipeline runs the "plan" job, it doesn't have the injected steps from the `github-build-setup` file.
I'm trying to inject this in the plan job (since I'm using ssh to pull from the GitHub repo in my Cargo.toml file):
```yaml
- name: Setup SSH key for cargo dependencies
uses: webfactory/ssh-agent@v0.10.0
with:
ssh-private-key: ${{ secrets.CRATE_DEPLOY_KEY }}
```
Cargo.toml example:
```toml
[workspace.dependencies]
private-crate = { git = "ssh://git@github.com/my-org/private-crate.git", tag = "v0.5.0" }
```
Error from GitHub actions CI run:
```
Run dist plan --output-format=json > plan-dist-manifest.json
× We encountered an issue trying to read your workspace
├─▶ × `cargo metadata` execution failed
│
╰─▶ `cargo metadata` exited with an error: Updating crates.io index
Updating git repository `ssh://git@github.com/my-org/private-crate.git`
error: failed to get `private-crate` as a dependency of package `my-app v1.6.0 (/home/runner/work/my-
app/my-app-repo/apps/my-app-dir)`
Caused by:
failed to load source for dependency `private-crate`
Caused by:
unable to update ssh://git@github.com/my-org/private-crate.git?tag=v0.5.0#bcddefb1
Caused by:
failed to clone into: /home/runner/.cargo/git/db/private-crate-1bb41a8a83d12937
Caused by:
revision bcddefb159143c840ee27eddd8f6803efe6897eb not found
Caused by:
failed to authenticate when downloading repository
* attempted ssh-agent authentication, but no usernames succeeded: `git`
if the git CLI succeeds then `net.git-fetch-with-cli` may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Caused by:
no authentication methods succeeded
```
***
The current `github-build-setup` only injects this in the build-local-artifacts job. I also tested adding the step manually in the plan job to confirm this would fix the issue and it did.
I see that there was a similar issue opened already in #2065 , and a matching, but seemingly abandoned pull request #2070. Was there any plan on eventually including this change in the main branch? Or was a different approach preferred? In any case, I think having a way to inject tokens and other types of credentials could be beneficial when working on private repos.
Or is this issue already solved and there is documentation on how to address this problem? If so, I would appreciate a link if possible, as I wasn't able to find it.
Contributor guide
Research direction
Start by reading the current github-build-setup injection and the plan job, then compare the proposed approach in issues #2065 and pull request #2070. Confirm the behavior with the reported private Cargo dependency and GitHub Actions run; done means injected credential-setup steps execute in the plan job and cargo metadata succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, rust
- Domain
- ci-cd
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100