From a78fbb0e5925caa0addd201a2ad9fe2b6ddb5343 Mon Sep 17 00:00:00 2001 From: Pavel Slama Date: Mon, 21 Dec 2020 21:01:20 +0100 Subject: [PATCH] GithubCI --- .github/workflows/build.yml | 143 ++++++++++++++++++ .github/workflows/release.yml | 37 +++++ README.md | 3 +- .../WeatherMeters_STM32.ino | 53 ------- library.json | 21 ++- library.properties | 1 + 6 files changed, 192 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml delete mode 100644 examples/timers/WeatherMeters_STM32/WeatherMeters_STM32.ino diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f2b9431 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,143 @@ +name: build + +on: + push: + branches: + - master + pull_request: + branches: + - "*" + +jobs: + platformio-build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.8" + + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install --upgrade platformio + pio lib -g install "pilotak/MovingAverage" + pio lib -g install "pilotak/MovingAverageAngle" + + - name: Compile UNO + run: | + pio ci --lib="." --board=uno + env: + PLATFORMIO_CI_SRC: ./examples/timers/WeatherMeters_AVR + + - name: Compile ESP8266 + run: | + pio ci --lib="." --board=esp8285 + env: + PLATFORMIO_CI_SRC: ./examples/timers/WeatherMeters_ESP8266 + + - name: Compile ESP32 + run: | + pio ci --lib="." --board=esp32dev + env: + PLATFORMIO_CI_SRC: ./examples/timers/WeatherMeters_ESP32 + + - name: Compile adhoc + run: | + pio ci --lib="." --board=uno --board=esp8285 --board=esp32dev + env: + PLATFORMIO_CI_SRC: ./examples/WeatherMeters_adhoc + + - name: Compile external ADC + run: | + pio lib -g install "pilotak/MCP3X21" + pio ci --lib="." --board=uno --board=esp8285 --board=esp32dev + env: + PLATFORMIO_CI_SRC: ./examples/WeatherMeters_external_ADC + + arduino-build: + strategy: + matrix: + board: ["UNO", "ESP8266", "ESP32"] + include: + - board: "UNO" + platform: "arduino:avr" + fqbn: "arduino:avr:uno" + url: "" + + - board: "ESP8266" + platform: "esp8266:esp8266" + fqbn: "esp8266:esp8266:esp8285" + url: https://arduino.esp8266.com/stable/package_esp8266com_index.json + + - board: "ESP32" + platform: "esp32:esp32" + fqbn: "esp32:esp32:esp32" + url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json + + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare + run: | + cp ./WeatherMeters.h ./examples/WeatherMeters_external_ADC + cp ./WeatherMeters.h ./examples/WeatherMeters_adhoc + + - name: Set up Python + if: ${{ matrix.board == 'ESP32' }} + uses: actions/setup-python@v2 + with: + python-version: "3.8" + + - name: Install pyserial + if: ${{ matrix.board == 'ESP32' }} + run: | + python -m pip install --upgrade pip + pip install --upgrade pyserial + + - name: Setup Arduino CLI + uses: arduino/setup-arduino-cli@v1.1.1 + + - name: "Install platform for ${{ matrix.board }}" + run: | + arduino-cli core update-index + arduino-cli core install ${{ matrix.platform }} + arduino-cli lib install --git-url https://github.com/pilotak/MovingAverage + arduino-cli lib install --git-url https://github.com/pilotak/MovingAverageAngle + env: + ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS: ${{ matrix.url }} + ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL: true + + - name: Compile timer UNO + if: ${{ matrix.board == 'UNO' }} + run: | + cp ./WeatherMeters.h ./examples/timers/WeatherMeters_AVR + arduino-cli compile --fqbn ${{ matrix.fqbn }} ./examples/timers/WeatherMeters_AVR + + - name: Compile timer ESP8266 + if: ${{ matrix.board == 'ESP8266' }} + run: | + cp ./WeatherMeters.h ./examples/timers/WeatherMeters_ESP8266 + arduino-cli compile --fqbn ${{ matrix.fqbn }} ./examples/timers/WeatherMeters_ESP8266 + + - name: Compile timer ESP32 + if: ${{ matrix.board == 'ESP32' }} + run: | + cp ./WeatherMeters.h ./examples/timers/WeatherMeters_ESP32 + arduino-cli compile --fqbn ${{ matrix.fqbn }} ./examples/timers/WeatherMeters_ESP32 + + - name: Compile adhoc + run: | + arduino-cli compile --fqbn ${{ matrix.fqbn }} ./examples/WeatherMeters_adhoc + + - name: Compile external ADC + run: | + arduino-cli lib install --git-url https://github.com/pilotak/MCP3X21 + arduino-cli compile --fqbn ${{ matrix.fqbn }} ./examples/WeatherMeters_external_ADC + env: + ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL: true \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..37ff23c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: release + +on: + push: + tags: + - "v*" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare + id: prepare + run: | + git fetch --prune --unshallow --tags -f + + VERSION=$(git tag --points-at HEAD) + VERSION=${VERSION//v} + + echo "## :bookmark_tabs: Changes" >>"CHANGELOG.md" + git log --pretty=format:"- %s %H%n" $(git describe --abbrev=0 --tags $(git describe --tags --abbrev=0)^)...$(git describe --tags --abbrev=0) >>"CHANGELOG.md" + + echo ::set-output name=version::${VERSION} + + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ steps.prepare.outputs.version }} + body_path: CHANGELOG.md + draft: false + prerelease: false \ No newline at end of file diff --git a/README.md b/README.md index bad3261..753db40 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Weather Meters -[![Build Status](https://travis-ci.org/pilotak/WeatherMeters.svg?branch=master)](https://travis-ci.org/pilotak/WeatherMeters) [![Framework Badge Arduino](https://img.shields.io/badge/framework-arduino-00979C.svg)](https://arduino.cc) +[![build](https://github.com/pilotak/WeatherMeters/workflows/build/badge.svg)](https://github.com/pilotak/WeatherMeters/actions) +[![Framework Badge Arduino](https://img.shields.io/badge/framework-arduino-00979C.svg)](https://arduino.cc) Arduino library for processing wind speed, wind wane and rain gauge sensors (WH1080, WH1090, Sparkfun) diff --git a/examples/timers/WeatherMeters_STM32/WeatherMeters_STM32.ino b/examples/timers/WeatherMeters_STM32/WeatherMeters_STM32.ino deleted file mode 100644 index db4aaf5..0000000 --- a/examples/timers/WeatherMeters_STM32/WeatherMeters_STM32.ino +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include "WeatherMeters.h" - -const int windvane_pin = PB1; -const int anemometer_pin = PB12; -const int raingauge_pin = PB14; - -volatile bool got_data = false; - -RTClock rtclock(RTCSEL_LSE); -WeatherMeters <4> meters(windvane_pin, 8); // filter last 4 directions, refresh data every 8 sec - -void intAnemometer() { - meters.intAnemometer(); -} - -void intRaingauge() { - meters.intRaingauge(); -} - -void secondCount() { - meters.timer(); -} - -void readDone(void) { - got_data = true; -} - -void setup() { - Serial.begin(115200); - - attachInterrupt(digitalPinToInterrupt(anemometer_pin), intAnemometer, FALLING); - attachInterrupt(digitalPinToInterrupt(raingauge_pin), intRaingauge, FALLING); - - meters.attach(readDone); - rtclock.attachSecondsInterrupt(secondCount); - meters.reset(); // in case we got already some interrupts -} - -void loop() { - if (got_data) { - got_data = false; - Serial.print("Wind degrees: "); - Serial.print(meters.getDir(), 1); - Serial.print(" Wind speed: "); - Serial.print(meters.getSpeed(), 1); - Serial.print("km/h, Rain: "); - Serial.print(meters.getRain(), 4); - Serial.println("mm"); - } - - delay(1); // or do something else -} diff --git a/library.json b/library.json index 386050f..9e25b0a 100644 --- a/library.json +++ b/library.json @@ -2,23 +2,20 @@ "name": "WeatherMeters", "keywords": "weather, meters, processing, wind, speed, direction, rain", "description": "Weather meters processing library", - "repository": - { + "repository": { "type": "git", "url": "https://github.com/pilotak/WeatherMeters.git" }, - "authors": - { - "name": "Pavel Slama", - "email": "info@pavelslama.cz", - "url": "https://github.com/pilotak" + "authors": { + "name": "Pavel Slama", + "email": "info@pavelslama.cz", + "url": "https://github.com/pilotak" }, - "dependencies": - { - "name": "MovingAverageAngle", - "version": "^1.0.3" + "dependencies": { + "name": "pilotak/MovingAverageAngle", + "version": "^1.0.4" }, "version": "2.0.0", "frameworks": "arduino", "platforms": "*" -} \ No newline at end of file +} diff --git a/library.properties b/library.properties index 5e1e0e0..6bf48c2 100644 --- a/library.properties +++ b/library.properties @@ -8,3 +8,4 @@ includes=WeatherMeters.h category=Signal Input/Output version=2.0.0 architectures=* +depends=MovingAverageAngle