Skip to content

Sketches with #include Math.h do not compile via GH Action (but do locally) #270

@aliphys

Description

@aliphys

Describe the problem

If a sketch has #include "Math.h", the arduino/compile-sketches GitHub Action will return fatal error: Math.h: No such file or directory. However, the same sketch compiles and executes locally as expected.

  /home/runner/work/nicla-sense-me-fw/nicla-sense-me-fw/Arduino_BHY2/examples/Magnetometer/Magnetometer.ino:17:10: fatal error: Math.h: No such file or directory
   #include "Math.h"
            ^~~~~~~~
  compilation terminated.
  
  Used library Version Path
  Arduino_BHY2 1.0.6   /home/runner/work/nicla-sense-me-fw/nicla-sense-me-fw/Arduino_BHY2
  ArduinoBLE   1.3.6   /home/runner/Arduino/libraries/ArduinoBLE
  
  Used platform      Version Path
  arduino:mbed_nicla 4.1.3   /home/runner/.arduino15/packages/arduino/hardware/mbed_nicla/4.1.3
  Error during build: exit status 1

To reproduce

  1. Compile the sketch below for the Nicla Sense ME locally. It should compile, and magnetometer data is received over the Serial connection
/*
 * This example shows how to use the access the magnetometer data and send it over serial.
 * 
 * Every 1 second, this sketch will send the heading of the magnetometer over serial.
 * by calculating the arctangent between the x and y axis and multiplied in a conversion
 * factor to convert the headings from radians to degrees.
 * 
 * Instructions:
 * 1. Upload this sketch to your Nicla Sense ME board.
 * 2. Open the Serial Monitor at a baud rate of 115200.
 * 3. The heading of the magnetometer will be printed to the serial monitor.
 * 
 * Initial author: @mcmchris
 */

#include "Arduino_BHY2.h"
#include "Math.h"

SensorXYZ magnetometer(SENSOR_ID_MAG);

float heading = 0;
unsigned long previousMillis = 0;  // will store last time the sensor was updated
const long interval = 1000;

void setup() {
  Serial.begin(115200);
  BHY2.begin();
  magnetometer.begin();
}

void loop() {
  BHY2.update();
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    heading = round(atan2(magnetometer.x(), magnetometer.y()) * 180.0 / PI);
    Serial.println(String(heading) + "º");
  }
}
  1. Run this GitHub Workflow, which includes this section
      - name: Compile examples
        uses: arduino/compile-sketches@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          fqbn: ${{ matrix.board.fqbn }}
          platforms: ${{ matrix.board.platforms }}
          libraries: |
            # Board-specific libraries
            ${{ matrix.bhy2-libraries }}
            ${{ matrix.bhy2host-libraries }}
            ${{ matrix.board.libraries }}
            ${{ matrix.arduinoiotcloud-libraries }}
            ${{ matrix.blebridge-libraries }}
          sketch-paths: |
            ${{ matrix.bhy2-sketch-paths }}
            ${{ matrix.bhy2host-sketch-paths }}
            ${{ matrix.arduinoiotcloud-sketch-paths }}
            ${{ matrix.blebridge-sketch-paths }}
          enable-deltas-report: true
          sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
  1. The error regarding Math.h is displayed here

Expected behavior

If a sketch is able to compile locally and Math.h is found, then I also expect the CLI to do the same and not give an error.

'arduino/compile-sketches' version

    uses: arduino/compile-sketches@v1

Additional context

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest version
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions