pguyot / arm-runner-action

Run tests natively and build images directly from GitHub Actions using a chroot-based virtualized Raspberry Pi (raspios/raspbian) environment
BSD 3-Clause "New" or "Revised" License
153 stars 31 forks source link

Rust build possibly running out of RAM #77

Closed Benji377 closed 1 year ago

Benji377 commented 1 year ago

Intro

I am creating a Tauri app. It has a frontend in Next.js and the backend in Rust. Using the Tauri command with cargo, I can build the project for different platforms like Ubuntu, Windows and Mac. Unfortunately, I am not able to compile the project for the Raspberry Pi because it has a different chip architecture. Therefore, I wanted to use your runner to try and build it using GitHub actions.

Problem

When I execute the GitHub action, everything seems to work fine, up until it tries to install tauri with the cargo command: cargo install tauri-cli. Then it starts compiling the needed dependencies and eventually fails because it doesn't have enough RAM to continue. It doesn't say that it doesn't have enough RAM, but when I tried to install tauri on my Raspberry Pi 3B+ with 1 GB of RAM, I encountered the same error. I solved it by increasing swap to 4 GB.

GitHub action

name: Raspberry Pi aarch64 cpu
on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: pguyot/arm-runner-action@v2.5.2
        with:
          image_additional_mb: 10240
          base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv8-Bullseye.7z
          cpu: cortex-a53
          commands: |
            apt-get update -y --allow-releaseinfo-change
            apt-get upgrade -y
            apt-get autoremove -y
            apt-get install curl
            curl https://sh.rustup.rs -sSf | sh -s -- -y
            . "$HOME/.cargo/env"
            curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash
            apt-get install -y nodejs
            npm install next@latest react@latest react-dom@latest eslint-config-next@latest
            apt-get install -y libwebkit2gtk-4.0-dev build-essential wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
            cargo install tauri-cli
            npm install
            cargo tauri build

Action error

Benji377 commented 1 year ago

Well, never mind, I just run the free -m command in the Runner, and it does have about 7 GB of RAM. That's more than the Raspberry I used with SWAP.

               total        used        free      shared  buff/cache   available
Mem:            6943         617         205          22        6121        6010
Swap:           4095           0        4095

I really don't know what the issue could be now

razr commented 1 year ago

@Benji377 It might be due to the disk space. By default, it is about 24GB available, see #75

Benji377 commented 1 year ago

I executed df -h just before the runner exits to check the size and here is the output:

 + df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop3p2     11G  4.1G  6.0G  41% /
/dev/loop3p1    127M   32M   96M  26% /boot
devtmpfs        3.4G     0  3.4G   0% /dev
+ cargo install tauri-cli

After I execute the cargo install tauri-cli command, the Runner exits. @razr Maybe it has to do with disk space, but how do I increase it?

razr commented 1 year ago

I'm doing it like this for the GH runner:

    - name: Increase free space
      # Remove Android and dotnet
      run: |
        df -h
        sudo rm -rf /usr/local/lib/android
        sudo rm -rf /usr/share/dotnet
        df -h

I see that you set image_additional_mb: 10240. Maybe it should be more?

Benji377 commented 1 year ago

Unfortunately, even when doubling the size, I get the same error

pguyot commented 1 year ago

This seems to be related: https://github.com/rust-lang/rust/issues/64248#issuecomment-839392042

But the workaround (cleaning up registry), didn't work unfortunately. https://github.com/pguyot/Raspirus/actions/runs/5039405198/jobs/9037523222#step:3:765

Benji377 commented 1 year ago

What you are saying is that this issue is more likely related to Rust not being able to download some crates, right?

pguyot commented 1 year ago

The issue is Rust related. It's not that it cannot download crates but rather that it cannot download the index. I did find a workaround and created a PR on your repo. It's still running but past the installation of taurus-cli.

See https://github.com/pguyot/Raspirus/actions/runs/5039610464/jobs/9037866452

Source for the workaround: https://github.com/libp2p/rust-libp2p/pull/3782#issuecomment-1525449521