Arduino/compile-sketches action can’t report size

Hello everyone!

I wrote a GitHub actions workflow here to check every commit and report sketches size. This is my workflow:


name: Compile Sketch

on:
  - push
  - pull_request
  - workflow_dispatch

env:
  SKETCHES_REPORTS_PATH: sketches-reports
  SKETCHES_REPORTS_ARTIFACT_NAME: Cookie-Cats

jobs:
  compile-sketch:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        fqbn:
          - "esp8266:esp8266:nodemcu"
          - "esp8266:esp8266:d1_mini"

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Compile sketch
        uses: arduino/compile-sketches@v1
        with:
          fqbn: ${{ matrix.fqbn }}
          platforms: |
            - name: esp8266:esp8266
              source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
              version: 3.1.2
          sketch-paths: |
            - ./Cookie-Cats/
          libraries: |
            - name: ArduinoJson
              version: 6.21.4
            - name: TickTwo
              version: 4.4.0
            - name: PracticalCrypto
              version: 0.1.0
              source-url: https://github.com/gutierrezps/PracticalCrypto.git
          enable-deltas-report: true
          sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}

      - name: Upload sketches report to workflow artifact
        uses: actions/upload-artifact@v3
        with:
          name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
          path: ${{ env.SKETCHES_REPORTS_PATH }}

  report:
    needs: compile-sketch  # Wait for the compile job to finish to get the data for the report
    if: github.event_name == 'pull_request' # Only run the job when the workflow is triggered by a pull request
    runs-on: ubuntu-latest
    permissions:
        pull-requests: write
    steps:
      # This step is needed to get the size data produced by the compile jobs
      - name: Download sketches reports artifact
        uses: actions/download-artifact@v3
        with:
          name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
          path: ${{ env.SKETCHES_REPORTS_PATH }}

      - uses: arduino/report-size-deltas@v1
        with:
          sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}

But I only get N/A in report like this:

{
  "commit_hash": "4392bd2796014ca9ea2afc8faee316c8a6a35cd7",
  "commit_url": "https://github.com/Cookie-Cats/Cookie-Cats/commit/4392bd2796014ca9ea2afc8faee316c8a6a35cd7",
  "boards": [
    {
      "board": "esp8266:esp8266:nodemcu",
      "sketches": [
        {
          "name": "Cookie-Cats",
          "compilation_success": true,
          "sizes": [
            {
              "name": "flash",
              "maximum": "N/A",
              "current": {
                "absolute": "N/A",
                "relative": "N/A"
              }
            },
            {
              "name": "RAM for global variables",
              "maximum": "N/A",
              "current": {
                "absolute": "N/A",
                "relative": "N/A"
              }
            }
          ]
        }
      ],
      "sizes": [
        {
          "name": "flash",
          "maximum": "N/A"
        },
        {
          "name": "RAM for global variables",
          "maximum": "N/A"
        }
      ]
    }
  ]
}

I’m new to Arduino and I’m sorry that I don’t know how to fix it. I will so appreciate if you could help me to fix this problem. Thanks!

Hi @diazepam. Very cool that you are using the arduino/compile-sketches GitHub Actions action in your project!

Unfortunately the ESP8266 boards platform is not compatible with the size report feature of the action. The reason is because the action requires that the platform report the sketch memory usage data from the compilation in a standardized format. You can see that compiling for an ESP8266 board does produce a memory usage report:

https://github.com/Cookie-Cats/Cookie-Cats/actions/runs/7248783964/job/19745384313#step:3:184

  . Variables and constants in RAM (global, static), used 35160 / 80192 bytes (43%)
  ║   SEGMENT  BYTES    DESCRIPTION
  ╠══ DATA     1496     initialized variables
  ╠══ RODATA   6896     constants       
  ╚══ BSS      26768    zeroed variables
  . Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 60943 / 65536 bytes (92%)
  ║   SEGMENT  BYTES    DESCRIPTION
  ╠══ ICACHE   32768    reserved space for flash instruction cache
  ╚══ IRAM     28175    code in IRAM    
  . Code in flash (default, ICACHE_FLASH_ATTR), used 463280 / 1048576 bytes (44%)
  ║   SEGMENT  BYTES    DESCRIPTION
  ╚══ IROM     463280   code in flash   

However, the report is not produced directly by the Arduino build system, but instead by a custom Python script created by the ESP8266 platform developers:

https://github.com/esp8266/Arduino/blob/3.1.2/tools/sizes.py

That approach works fine when it is a human reading the report, but the report doesn't have a standardized format so the arduino/compile-sketches action is not able to parse it.

I believe the reason why the ESP8266 platform developers resorted to this approach of creating a custom size reporting mechanism is because traditionally the Arduino platform system had a very short-sighted design that assumed a microcontroller could only ever have two types of memory ("program memory" and "dynamic memory"):

https://arduino.github.io/arduino-cli/latest/platform-specification/#recipes-to-compute-binary-sketch-size

Since then, a flexible system for memory reported has been introduced into the Arduino platform framework:

https://arduino.github.io/arduino-cli/latest/platform-specification/#recipes-to-compute-binary-sketch-size-for-more-complex-systems-since-arduino-cli-0210

It is likely that system would meet the needs of the ESP8266 platform well. If they migrated the platform to it then it would make the memory usage data available in a machine readable format suitable for use by the arduino/compile-sketches action.

But for now you will not be able to use the feature when compiling for these boards. Even without the size report, I still think it is well worth using the action to get some automated validation of the code via a "smoke test".

1 Like

Thank you for your warm, professional and detailed explanation! I appreciate that you explained the reason why the ESP8266 board was not able to provide a detailed report.

I believe that in the future the ESP8266 will migrate to a new reporting platform that provides a mechanically readable form.

Many thanks to the developers of Arduino and ESP8266 core for Arduino! Your efforts are making a better world!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.