move CI from travis to GitHub actions

This commit is contained in:
proddy
2020-09-15 21:21:27 +02:00
parent d2b4fd59ff
commit d1dfb370bf
10 changed files with 255 additions and 63 deletions

33
.github/workflows/EMS-ESP_CI.yml vendored Normal file
View File

@@ -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

89
.github/workflows/EMS-ESP_build.yml vendored Normal file
View File

@@ -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

20
.github/workflows/EMS-ESP_cpp_make.yml vendored Normal file
View File

@@ -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

View File

@@ -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

1
.gitignore vendored
View File

@@ -17,6 +17,7 @@ pio_local.ini
# project specfic
/scripts/stackdmp.txt
emsesp
firmware
/data/www/
/lib/framework/WWWData.h
/interface/build/

26
FIRMWARE.md Normal file
View File

@@ -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")
<br/>
[![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.

View File

@@ -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

39
scripts/gzip_fw.py Normal file
View File

@@ -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])

45
scripts/rename_fw.py Normal file
View File

@@ -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/<variant>.bin
shutil.copy(str(target[0]), bin_file)
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_copy])