espressif / esp-idf-ci-action

GitHub Action for ESP32 CI
MIT License
67 stars 24 forks source link

docker: command not found Error: Process completed with exit code 127. (RDT-459) #31

Closed NightSkySK closed 1 year ago

NightSkySK commented 1 year ago

I'm building my first CI for GitHub Action and I have problem with building the code.

name: Build

on: [push, pull_request, workflow_dispatch]

jobs:
  build-esp-idf-component:
    name: Build with ESP-IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        # The version names here correspond to the versions of espressif/idf Docker image.
        # See https://hub.docker.com/r/espressif/idf/tags and
        # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html
        # for details.
        idf_ver: ["v4.4.4", "release-v4.4"]
        idf_target: ["esp32"]
    container: espressif/idf:${{ matrix.idf_ver }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: 'recursive'
      - name: esp-idf build
        uses: espressif/esp-idf-ci-action@v1
        with:
            esp_idf_version: ${{ matrix.idf_ver }}
            target: ${{ matrix.idf_target }}
            path: 'main'

as an output from logs I receive:

Run espressif/esp-idf-ci-action@v1
  with:
    esp_idf_version: v4.4.4
    target: esp3[2](https://github.com/NightSkySK/mSpaceLock-device/actions/runs/5159853265/jobs/9295278237#step:4:2)
    path: main
    command: idf.py build
Run export IDF_TARGET=$(echo "esp[3](https://github.com/NightSkySK/mSpaceLock-device/actions/runs/5159853265/jobs/9295278237#step:4:3)2" | tr '[:upper:]' '[:lower:]' | tr -d '_-')
  export IDF_TARGET=$(echo "esp32" | tr '[:upper:]' '[:lower:]' | tr -d '_-')
  docker run -t -e IDF_TARGET="${IDF_TARGET}" -v "${GITHUB_WORKSPACE}:/app/NightSkySK/mSpaceLock-device" \
  -w "/app/NightSkySK/mSpaceLock-device/main" espressif/idf:v[4](https://github.com/NightSkySK/mSpaceLock-device/actions/runs/5159853265/jobs/9295278237#step:4:4).4.4 \
  /bin/bash -c 'git config --global --add safe.directory "*" && idf.py build'
  shell: bash --noprofile --norc -e -o pipefail {0}
/__w/_temp/43fd[5](https://github.com/NightSkySK/mSpaceLock-device/actions/runs/5159853265/jobs/9295278237#step:4:5)74a-8b[6](https://github.com/NightSkySK/mSpaceLock-device/actions/runs/5159853265/jobs/9295278237#step:4:6)9-4abc-8986-5b3b2e88aca5.sh: line 2: docker: command not found
Error: Process completed with exit code 12[7](https://github.com/NightSkySK/mSpaceLock-device/actions/runs/5159853265/jobs/9295278237#step:4:8).

What I did wrong? The same output I got on `release-v4.4'

NightSkySK commented 1 year ago

It took me few hours, but I finally found what was wrong with my github action yaml script, error was result of merging few different files which I wanted combine to match my needs, once I didn't fully understand how it works. So the problem was at line container: espressif/idf:${{ matrix.idf_ver }} which shouldn't be there as it caused that following steps was executed in idf container already. For long time I couldn't understand why there is docker command to be executed by espressif/esp-idf-ci-action@v1. It was intuitive for me that checkout should be executed in idf environment. Once I finally understood that checkout is going to be passed to espressif/esp-idf-ci-action@v1 and only than docker image need to be run than fixing the yaml code become easy task. I will leave my experience here, may be someone will face same issue as me.

Here is the yaml code for github action which is finally working for me:

# This is a basic workflow that is manually triggered

name:  Build and Publish Application

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
  push:
  pull_request:
    branches: [main]
  workflow_dispatch:
    # Inputs the workflow accepts.

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        # The version names here correspond to the versions of espressif/idf Docker image.
        # See https://hub.docker.com/r/espressif/idf/tags and
        # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html
        # for details.
        idf_ver: ["release-v4.3", "release-v4.4"]
        idf_target: ["esp32"]
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v3
        with:
          submodules: 'recursive'
      - name: Build Application
        uses: espressif/esp-idf-ci-action@v1
        with:
          esp_idf_version: ${{ matrix.idf_ver }}
          target: ${{ matrix.idf_target }}
      - name: Rename artifact
        run: |
          ls -lah 
          cp build/bootloader/bootloader.bin bootloader-${{ matrix.idf_ver }}.bin
          cp build/partition_table/partition-table.bin partition-table-${{ matrix.idf_ver }}.bin
          cp build/mspacelock.bin mspacelock-${{ matrix.idf_ver }}.bin
          cp build/ota_data_initial.bin ota_data_initial-${{ matrix.idf_ver }}.bin

      - name: Upload
        uses: actions/upload-artifact@v3
        with:
          name: mSpaceLock_${{ matrix.idf_target }}_${{ matrix.idf_ver }}
          path: "*-${{ matrix.idf_ver }}.bin"

  release:
    needs: build
    runs-on: ubuntu-latest
    steps:
    - name: Download Firmware Files
      uses: actions/download-artifact@v3
      with:
        path: build