ssh-agent icon indicating copy to clipboard operation
ssh-agent copied to clipboard

Cargo Dependencies on Linux Runner

Open Abhay2412 opened this issue 1 year ago • 2 comments

Hello, I am trying to run a workflow to make a deb file for a Flutter project that communicates with Rust. We have some private repos that are being called in our project as dependencies.

According to the documentation this works for Windows I tried adding it to my workflow as well https://github.com/marketplace/actions/webfactory-ssh-agent#cargos-rust-private-dependencies-on-windows but I am still get an error for some reason:

name: Building App on Linux
on:
  push:
    branches:
      - workflows
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Configure git to use SSH
        run: |
          git config --global url."ssh://[email protected]/".insteadOf "https://github.com/"
      - name: Give GitHub Actions access to Crate 1 Repo
        uses: webfactory/[email protected]
        with:
          ssh-private-key: ${{ secrets.CRATE1DEPLOYKEY }}
      - name: Give GitHub Actions access to Crate 2 Repo
        uses: webfactory/[email protected]
        with:
          ssh-private-key: ${{ secrets.CRATE2DEPLOYKEY }}
      - name: Give GitHub Actions access to Crate 3 Repo
        uses: webfactory/[email protected]
        with:
          ssh-private-key: ${{ secrets.CRATE3DEPLOYKEY }}
      - name: Give GitHub Actions access to Crate 4 Repo
        uses: webfactory/[email protected]
        with:
          ssh-private-key: ${{ secrets.CRATE4DEPLOYKEY }}
      - name: Add GitHub to known hosts
        run: |
          mkdir -p ~/.ssh
          ssh-keyscan github.com >> ~/.ssh/known_hosts
      - name: Update cargo config to use Git CLI
        run: echo -e "[net]\ngit-fetch-with-cli = true" > ~/.cargo/config.toml  
      - uses: subosito/flutter-action@v2
        with:
          flutter-version: "3.x"
          cache: true
          channel: stable
      - name: Install dependencies
        run: |
          flutter pub get
          sudo apt-get install clang cmake git ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev
      - name: Build Linux Distribution
        run: |
          dart pub global activate flutter_distributor
          flutter_distributor release --name=dev --jobs=release-dev-linux-deb
      - name: Upload Distribution
        uses: actions/upload-artifact@v2
        with:
          name: linux-deb
          path: dist/

The Cargo.toml file:

[package]
name = "app"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "staticlib"]

[dependencies]
flutter_rust_bridge = "=2.1.0"
anyhow = "1.0.86"
lazy_static = "1.5.0"
plotters = "0.3.6"
rustfft = "6.2.0"

CRATE1= { git = "ssh://[email protected]/{Crate1Repo}.git" }
CRATE2= { git = "ssh://[email protected]/{Crate2Repo}.git" }
CRATE3= { git = "ssh://[email protected]/{Crate3Repo}.git" }
CRATE4= { git = "ssh://[email protected]/{Crate4Repo}.git" }

The error I get when the workflow gets to the step of Building the Linux distribution: SEVERE: error: failed to get `CRATE1` as a dependency of package `app v0.1.0 I'm hoping to get some insight on what I'm doing wrong and guidance.

Abhay2412 avatar Aug 01 '24 15:08 Abhay2412

Hi, i've just faced a similar issue and this article helped me about the setup: https://adventures.michaelfbryan.com/posts/configuring-cargo-auth-in-github-actions/

other than that since all your git strings are already starting with "ssh://..."

  • name: Configure git to use SSH run: | git config --global url."ssh://[email protected]/".insteadOf "https://github.com/"

seems redundant

boroskoyo avatar Aug 02 '24 11:08 boroskoyo

Hi, i've just faced a similar issue and this article helped me about the setup: https://adventures.michaelfbryan.com/posts/configuring-cargo-auth-in-github-actions/

other than that since all your git strings are already starting with "ssh://..."

  • name: Configure git to use SSH run: | git config --global url."ssh://[email protected]/".insteadOf "https://github.com/"

seems redundant

Appreciate the feedback and your reply I think the ssh agent step works it's just for some reason Cargo.toml is not able to recognize the repos maybe some configuration settings I am missing and thanks for the article was following it.

Abhay2412 avatar Aug 02 '24 14:08 Abhay2412