Skip to content

Commit

Permalink
test(test): ✅ add build tests on github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreHiroyuki committed Aug 20, 2024
1 parent 5ca50c8 commit 636ecc8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install PlatformIO Core
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
Expand All @@ -26,3 +26,9 @@ jobs:
pip install platformio
- name: Run Tests on the Desktop Environment
run: platformio test -e desktop
- name: Run Build Test for Arduino Uno
run: platformio run -e arduino_uno -t build_test.cpp
- name: Run Build Test for ESP32 Dev Module
run: platformio run -e esp32dev -t build_test.cpp


42 changes: 42 additions & 0 deletions build_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Include lib:
#include <Arduino.h>
#include <DataTome.h>

// Create an Arithmetic Moving Average object of unsigned int type,
// 10 in size
DataTomeMvAvg<unsigned, unsigned long> test(10);
DataTomeAnalysis<unsigned, unsigned long> test2(10);
// DataTomeExpAvg<unsigned, unsigned long> test3(10);

// This variable just generates input for average test
unsigned delta_x = 0;

void setup() {
// Initialize serial interface
Serial.begin(9600);
}

void loop() {
// Pushes the input in the moving average object
test.push(delta_x);

// Generates the next input
delta_x += 5;
if (delta_x > 1000) delta_x = 0;

// Prints each value stored in the moving average
for (uint8_t i = 0; i < test.size(); i++) {
Serial.print(test[i]);
Serial.print(" ");
}
// Prints the result of the average
Serial.print("= ");
Serial.print(test.get());
// Prints the value stored in the first and last indexes
Serial.print(" | f: ");
Serial.print(test.front());
Serial.print(" b: ");
Serial.println(test.back());

delay(1000);
}

0 comments on commit 636ecc8

Please sign in to comment.