From d1dfb370bfc6ded139e53b37cc478e953a0e01ac Mon Sep 17 00:00:00 2001 From: proddy Date: Tue, 15 Sep 2020 21:21:27 +0200 Subject: [PATCH] move CI from travis to GitHub actions --- .github/workflows/EMS-ESP_CI.yml | 33 ++++++++++ .github/workflows/EMS-ESP_build.yml | 89 ++++++++++++++++++++++++++ .github/workflows/EMS-ESP_cpp_make.yml | 20 ++++++ .github/workflows/codeql-analysis.yml | 63 ------------------ .gitignore | 1 + .travis.yml => .travis.yml_old | 0 FIRMWARE.md | 26 ++++++++ platformio.ini | 2 + scripts/gzip_fw.py | 39 +++++++++++ scripts/rename_fw.py | 45 +++++++++++++ 10 files changed, 255 insertions(+), 63 deletions(-) create mode 100644 .github/workflows/EMS-ESP_CI.yml create mode 100644 .github/workflows/EMS-ESP_build.yml create mode 100644 .github/workflows/EMS-ESP_cpp_make.yml delete mode 100644 .github/workflows/codeql-analysis.yml rename .travis.yml => .travis.yml_old (100%) create mode 100644 FIRMWARE.md create mode 100644 scripts/gzip_fw.py create mode 100644 scripts/rename_fw.py diff --git a/.github/workflows/EMS-ESP_CI.yml b/.github/workflows/EMS-ESP_CI.yml new file mode 100644 index 000000000..a163354e2 --- /dev/null +++ b/.github/workflows/EMS-ESP_CI.yml @@ -0,0 +1,33 @@ +name: EMS-ESP CI + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +#on: +# push: +# branches: [ main ] +# pull_request: +# branches: [ main ] + +on: + pull_request: + +jobs: + emsesp: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + # platformio upgrade --dev + platformio upgrade + platformio update + - name: Run PlatformIO + run: | + platformio run + + + diff --git a/.github/workflows/EMS-ESP_build.yml b/.github/workflows/EMS-ESP_build.yml new file mode 100644 index 000000000..d0a940447 --- /dev/null +++ b/.github/workflows/EMS-ESP_build.yml @@ -0,0 +1,89 @@ +name: Build_firmware + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +#on: +# push: +# branches: [ main ] +# pull_request: +# branches: [ main ] + +on: + push: + branches: [ dev ] + +jobs: + # emsesp_pull: + # runs-on: ubuntu-latest + # continue-on-error: true + # steps: + # - uses: actions/checkout@v1 + # - name: Use latest EMS-ESP development + # run: | + # git config --local user.name "Platformio BUILD" + # git switch -c main + # git remote add -f EMS-ESP "https://github.com/proddy/EMS-ESP.git" + # git merge EMS-ESP/dev --allow-unrelated-histories + # - name: Push EMS-ESP # Push updates of latest EMS-ESP development to repo + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: 'dev' + # force: true + + emsesp: + # needs: emsesp_pull + runs-on: ubuntu-latest + # continue-on-error: true + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + # platformio upgrade --dev + platformio upgrade + platformio update + - name: Run PlatformIO + run: | + platformio run + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build/firmware + + Upload: + needs: [emsesp] + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v1 + - uses: actions/download-artifact@v2 + with: + name: firmware + path: ./mv_firmware + - name: Display structure of downloaded files + run: ls -R + working-directory: ./mv_firmware + - name: Move firmware files in sub-folders + run: | + mkdir -p ./firmware + mkdir -p ./firmware/tasmota32/ESP32_needed_files/ + [ ! -f ./mv_firmware/*.bin ] || mv ./mv_firmware/EMS-ESP*.* ./firmware/ + [ ! -f ./FIRMWARE.md ] || mv -f ./FIRMWARE.md ./README.md + - name: Commit files # transfer the new binaries back into the repository + run: | + git config --local user.name "Platformio BUILD" + git rm -r --cached . + git add ./README.md + git add -f ./firmware/*.* + git commit -m "EMS-ESP binaries" + - name: Push changes # push the firmware files to branch firmware + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: 'firmware' + force: true + diff --git a/.github/workflows/EMS-ESP_cpp_make.yml b/.github/workflows/EMS-ESP_cpp_make.yml new file mode 100644 index 000000000..2e4070688 --- /dev/null +++ b/.github/workflows/EMS-ESP_cpp_make.yml @@ -0,0 +1,20 @@ +name: EMS-ESP C/C++ make + +on: + push: + # branches: [ dev ] + pull_request: + # branches: [ dev ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: make clean + run: make clean + - name: make + run: make + \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 9c7888c97..000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [main] - pull_request: - # The branches below must be a subset of the branches above - branches: [main] - schedule: - - cron: '0 11 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - # Override automatic language detection by changing the below list - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['cpp', 'javascript', 'python'] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 - \ No newline at end of file diff --git a/.gitignore b/.gitignore index b85d4d549..1176cfd07 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ pio_local.ini # project specfic /scripts/stackdmp.txt emsesp +firmware /data/www/ /lib/framework/WWWData.h /interface/build/ diff --git a/.travis.yml b/.travis.yml_old similarity index 100% rename from .travis.yml rename to .travis.yml_old diff --git a/FIRMWARE.md b/FIRMWARE.md new file mode 100644 index 000000000..c2a260acc --- /dev/null +++ b/FIRMWARE.md @@ -0,0 +1,26 @@ +# ![logo](https://github.com/proddy/EMS-ESP/blob/main/media/EMS-ESP_logo_dark.png) + +**EMS-ESP** is an open-source firmware for the Espressif ESP8266 and ESP32 microcontroller that communicates with **EMS** (Energy Management System) based equipment from manufacturers like Bosch, Buderus, Nefit, Junkers, Worcester and Sieger. + +[![version](https://img.shields.io/github/release/proddy/EMS-ESP.svg?label=Latest%20Release)](https://github.com/proddy/EMS-ESP/blob/master/CHANGELOG.md) +[![release-date](https://img.shields.io/github/release-date/proddy/EMS-ESP.svg?label=Released)](https://github.com/proddy/EMS-ESP/commits/master) +[![license](https://img.shields.io/github/license/proddy/EMS-ESP.svg)](LICENSE) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b8880625bdf841d4adb2829732030887)](https://app.codacy.com/app/proddy/EMS-ESP?utm_source=github.com&utm_medium=referral&utm_content=proddy/EMS-ESP&utm_campaign=Badge_Grade_Settings) +[![Build Firmware](https://github.com/proddy/EMS-ESP/workflows/Build_firmware/badge.svg)](https://github.com/proddy/EMS-ESP/actions?query=workflow%3ABuild_firmware) +[![downloads](https://img.shields.io/github/downloads/proddy/EMS-ESP/total.svg)](https://github.com/proddy/EMS-ESP/releases) +[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/proddy/EMS-ESP.svg)](http://isitmaintained.com/project/proddy/EMS-ESP "Average time to resolve an issue") +[![Percentage of issues still open](http://isitmaintained.com/badge/open/proddy/EMS-ESP.svg)](http://isitmaintained.com/project/proddy/EMS-ESP "Percentage of issues still open") +
+[![gitter](https://img.shields.io/gitter/room/EMS-ESP/EMS-ESP.svg)](https://gitter.im/EMS-ESP/community) + +If you like **EMS-ESP**, please give it a star, or fork it and contribute! + +[![GitHub stars](https://img.shields.io/github/stars/proddy/EMS-ESP.svg?style=social&label=Star)](https://github.com/proddy/EMS-ESP/stargazers) +[![GitHub forks](https://img.shields.io/github/forks/proddy/EMS-ESP.svg?style=social&label=Fork)](https://github.com/proddy/EMS-ESP/network) +[![donate](https://img.shields.io/badge/donate-PayPal-blue.svg)](https://www.paypal.com/paypalme/prderbyshire/2) + +# Installation + +Development builds can be found in https://github.com/proddy/EMS-ESP/tree/firmware/firmware. Follow the instructions in the [Wiki](https://emsesp.github.io/docs) on how to install. + +See [CHANGELOG.md](https://github.com/proddy/blob/development/tasmota/CHANGELOG.md) for changes since the last release. diff --git a/platformio.ini b/platformio.ini index 10961b3d5..e51eb3502 100644 --- a/platformio.ini +++ b/platformio.ini @@ -39,6 +39,8 @@ libs_core = extra_scripts = pre:scripts/build_interface.py scripts/main_script.py + scripts/rename_fw.py + scripts/gzip_fw.py framework = arduino monitor_speed = 115200 diff --git a/scripts/gzip_fw.py b/scripts/gzip_fw.py new file mode 100644 index 000000000..8c39ede19 --- /dev/null +++ b/scripts/gzip_fw.py @@ -0,0 +1,39 @@ +Import('env') +import os +import re +import shutil +import gzip + +OUTPUT_DIR = "build{}".format(os.path.sep) + +def bin_gzip(source, target, env): + + # get the version + bag = {} + exprs = [ + (re.compile(r'^#define EMSESP_APP_VERSION\s+"(\S+)"'), 'app_version'), + ] + with open('./src/version.h', 'r') as f: + for l in f.readlines(): + for expr, var in exprs: + m = expr.match(l) + if m and len(m.groups()) > 0: + bag[var] = m.group(1) + + app_version = bag.get('app_version') + + variant = "EMS-ESP-" + app_version.replace(".", "_") + "-" + str(target[0]).split(os.path.sep)[2] + + # create string with location and file names based on variant + bin_file = "{}firmware{}{}.bin".format(OUTPUT_DIR, os.path.sep, variant) + gzip_file = "{}firmware{}{}.bin.gz".format(OUTPUT_DIR, os.path.sep, variant) + + # check if new target files exist and remove if necessary + if os.path.isfile(gzip_file): os.remove(gzip_file) + + # write gzip firmware file + with open(bin_file,"rb") as fp: + with gzip.open(gzip_file, "wb", compresslevel = 9) as f: + shutil.copyfileobj(fp, f) + +env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_gzip]) \ No newline at end of file diff --git a/scripts/rename_fw.py b/scripts/rename_fw.py new file mode 100644 index 000000000..ec80c6253 --- /dev/null +++ b/scripts/rename_fw.py @@ -0,0 +1,45 @@ +Import('env') +import os +import re +import shutil + +OUTPUT_DIR = "build{}".format(os.path.sep) + +def bin_copy(source, target, env): + + # get the version + bag = {} + exprs = [ + (re.compile(r'^#define EMSESP_APP_VERSION\s+"(\S+)"'), 'app_version'), + ] + with open('./src/version.h', 'r') as f: + for l in f.readlines(): + for expr, var in exprs: + m = expr.match(l) + if m and len(m.groups()) > 0: + bag[var] = m.group(1) + + app_version = bag.get('app_version') + + variant = "EMS-ESP-" + app_version.replace(".", "_") + "-" + str(target[0]).split(os.path.sep)[2] + + # check if output directories exist and create if necessary + if not os.path.isdir(OUTPUT_DIR): + os.mkdir(OUTPUT_DIR) + + for d in ['firmware']: + if not os.path.isdir("{}{}".format(OUTPUT_DIR, d)): + os.mkdir("{}{}".format(OUTPUT_DIR, d)) + + # create string with location and file names based on variant + bin_file = "{}firmware{}{}.bin".format(OUTPUT_DIR, os.path.sep, variant) + + # check if new target files exist and remove if necessary + for f in [bin_file]: + if os.path.isfile(f): + os.remove(f) + + # copy firmware.bin to firmware/.bin + shutil.copy(str(target[0]), bin_file) + +env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_copy])