summarise-errors #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main, master, develop ] | |
| pull_request: | |
| branches: [ main, master, develop ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential g++ | |
| - name: Build library | |
| run: | | |
| g++ -c -std=c++11 -Iinclude src/csv_parser.cpp -o csv_parser.o | |
| g++ -c -std=c++11 -Iinclude src/json_parser.cpp -o json_parser.o | |
| g++ -c -std=c++11 -Iinclude src/error_detector.cpp -o error_detector.o | |
| g++ -c -std=c++11 -Iinclude src/file_utils.cpp -o file_utils.o | |
| - name: Run CSV Parser Tests | |
| run: | | |
| g++ -std=c++11 -Iinclude tests/test_csv_parser.cpp csv_parser.o -o test_csv_parser | |
| ./test_csv_parser | |
| - name: Run JSON Parser Tests | |
| run: | | |
| g++ -std=c++11 -Iinclude tests/test_json_parser.cpp json_parser.o -o test_json_parser | |
| ./test_json_parser | |
| - name: Run Error Detector Tests | |
| run: | | |
| g++ -std=c++11 -Iinclude tests/test_error_detector.cpp error_detector.o -o test_error_detector | |
| ./test_error_detector | |
| - name: Run File Utils Tests | |
| run: | | |
| g++ -std=c++11 -Iinclude tests/test_file_utils.cpp file_utils.o -o test_file_utils | |
| ./test_file_utils | |
| - name: Build main application | |
| run: | | |
| g++ -std=c++11 -pthread -Iinclude src/sensor-data.cpp csv_parser.o json_parser.o error_detector.o file_utils.o -o sensor-data | |
| - name: Integration Test - List Errors | |
| run: | | |
| echo '{"timestamp": "2026-01-17T10:00:00", "sensor_id": "sensor001", "sensor": "ds18b20", "value": "85"}' > test.out | |
| echo '{"timestamp": "2026-01-17T10:01:00", "sensor_id": "sensor002", "sensor": "ds18b20", "value": "22.5"}' >> test.out | |
| ./sensor-data list-errors test.out | grep -q "sensor001" | |
| rm test.out | |
| - name: Integration Test - Convert | |
| run: | | |
| echo '{"timestamp": "2026-01-17T10:00:00", "sensor_id": "sensor001", "sensor": "ds18b20", "value": "22.5"}' > test.out | |
| ./sensor-data convert -o output.csv test.out | |
| grep -q "sensor001" output.csv | |
| rm test.out output.csv | |
| - name: Integration Test - Remove Errors | |
| run: | | |
| echo '{"timestamp": "2026-01-17T10:00:00", "sensor_id": "sensor001", "sensor": "ds18b20", "value": "85"}' > test.out | |
| echo '{"timestamp": "2026-01-17T10:01:00", "sensor_id": "sensor002", "sensor": "ds18b20", "value": "22.5"}' >> test.out | |
| ./sensor-data convert --remove-errors -o output.csv test.out | |
| grep -q "sensor002" output.csv | |
| ! grep -q ",85" output.csv | |
| rm test.out output.csv | |
| - name: Integration Test - stdin to stdout (JSON) | |
| run: | | |
| echo '{"sensor":"ds18b20","value":"22.5","unit":"C"}' | ./sensor-data convert | grep -q "sensor" | |
| - name: Integration Test - stdin to file (JSON) | |
| run: | | |
| echo '{"sensor":"ds18b20","value":"22.5","unit":"C"}' | ./sensor-data convert -o output.csv | |
| grep -q "ds18b20" output.csv | |
| rm output.csv | |
| - name: Integration Test - stdin with CSV format | |
| run: | | |
| echo -e "sensor,value,unit\nds18b20,22.5,C" | ./sensor-data convert -f csv | grep -q "ds18b20" | |
| - name: Integration Test - stdin with --remove-errors | |
| run: | | |
| echo '{"sensor":"ds18b20","value":"85","unit":"C"}' | ./sensor-data convert --remove-errors | wc -l | grep -q "1" | |
| - name: Integration Test - stdin redirect | |
| run: | | |
| echo '{"sensor":"bme280","value":"1013","unit":"hPa"}' > test_stdin.out | |
| ./sensor-data convert < test_stdin.out | grep -q "bme280" | |
| rm test_stdin.out |