Github actions instead of Travis

This commit is contained in:
Maxim Prokhorov
2021-02-22 22:53:10 +03:00
parent 945d39b529
commit a4c1287dc0
11 changed files with 217 additions and 115 deletions
+113
View File
@@ -0,0 +1,113 @@
name: Build
on: [push, pull_request]
jobs:
generate-matrix:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- id: set-matrix
run: |
pip install platformio
python tools/pio/generate-ci-matrix.py
build:
needs: generate-matrix
runs-on: ubuntu-20.04
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os}}-${{ hashFiles('requirements.txt') }}
- uses: actions/cache@v2
if: ${{ contains(matrix.env, 'esp32') }}
with:
path: ~/.platformio
key: ${{ runner.os }}-esp32-${{ hashFiles('platformio*.ini') }}
- uses: actions/cache@v2
if: ${{ contains(matrix.env, 'esp8266') }}
with:
path: ~/.platformio
key: ${{ runner.os }}-esp8266-${{ hashFiles('platformio*.ini') }}
- name: Dependencies
run: |
sudo apt install binutils
pip install -r requirements.txt
- name: Build
env:
CHIP: ${{ matrix.chip }}
ENV: ${{ matrix.env }}
run: |
platformio run -e $ENV
zip -q -rr ESPEasy_$ENV.zip build_output/*
- uses: actions/upload-artifact@v2
with:
name: Binaries
path: ESPEasy_${{ matrix.env }}.zip
release-files:
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os}}-docs-${{ hashFiles('requirements.txt') }}
- name: Build documentation
run: |
cd docs
sudo apt install imagemagick zip
pip install -r requirements.txt
make html
cd ..
zip -r -qq ESPEasy_docs.zip docs/build/*
- name: Package utilities
run: |
cd dist
zip -r -qq ../ESPEasy_dist.zip *
cd ..
- name: Extract release notes
run: |
echo $GITHUB_REF
git --no-pager tag -l --format="%(contents)" ${GITHUB_REF:10}
git --no-pager tag -l --format="%(contents)" ${GITHUB_REF:10} > ReleaseNotes.txt
- uses: actions/upload-artifact@v2
with:
path: |
tools/upload-release.py
ESPEasy_docs.zip
ESPEasy_dist.zip
ReleaseNotes.txt
release:
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-20.04
needs: [release-files, build]
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- uses: actions/download-artifact@v2
with:
path: artifacts/
- name: Create release
working-directory: artifacts/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ls -R
pip install PyGithub
python3 artifact/tools/upload-release.py
-103
View File
@@ -1,103 +0,0 @@
language: python
python:
- '3.8'
dist: bionic
sudo: false
cache: false
addons:
apt:
packages:
- cppcheck
- binutils
install:
- pip install -U platformio sphinx recommonmark sphinx_bootstrap_theme
- pip install -r requirements.txt
- platformio update
- cd patches; ./check_puya_patch; cd ..
env:
- ENV=custom_ESP32_4M316k
- ENV=custom_ESP32_4M316k_ETH
#- ENV=custom_ESP8266_1M
- ENV=custom_ESP8266_4M1M
#- ENV=custom_ESP8266_4M2M
#- ENV=custom_ESP8266_4M2M_LittleFS
#- ENV=custom_alt_wifi_ESP8266_1M
- ENV=custom_alt_wifi_ESP8266_4M1M
#- ENV=custom_beta_ESP8266_1M
#- ENV=custom_beta_ESP8266_4M1M
- ENV=custom_sdk3_ESP8266_4M1M
- ENV=dev_ESP8266_4M1M
- ENV=hard_SONOFF_POW_4M1M
- ENV=hard_Shelly_1_2M256
- ENV=hard_Shelly_PLUG_S_2M256
- ENV=hard_Ventus_W266
- ENV=hard_LCtech_relay_x2_1M
- ENV=hard_other_POW_ESP8285_1M
- ENV=minimal_IRext_ESP8266_1M
- ENV=minimal_IRext_ESP8266_4M1M
- ENV=minimal_IRext_ESP8266_4M2M
#- ENV=minimal_core_242_ESP8266_1M_OTA
#- ENV=minimal_core_242_ESP8285_1M_OTA
- ENV=minimal_core_274_ESP8266_1M_OTA_Domoticz
- ENV=minimal_core_274_ESP8266_1M_OTA_FHEM_HA
- ENV=minimal_core_274_ESP8285_1M_OTA_Domoticz
- ENV=minimal_core_274_ESP8285_1M_OTA_FHEM_HA
#- ENV=minimal_core_274_sdk3_ESP8266_1M_OTA_Domoticz
#- ENV=minimal_core_274_sdk3_ESP8266_1M_OTA_FHEM_HA
#- ENV=minimal_core_274_sdk3_ESP8285_1M_OTA_Domoticz
#- ENV=minimal_core_274_sdk3_ESP8285_1M_OTA_FHEM_HA
#- ENV=normal_ESP8266_16M_LittleFS
- ENV=normal_ESP8266_1M
- ENV=normal_ESP8266_1M_VCC
- ENV=normal_ESP8266_4M1M
- ENV=normal_ESP8266_4M1M_VCC
- ENV=normal_ESP8285_1M
- ENV=normal_IRext_no_rx_ESP8266_4M2M
- ENV=normal_WROOM02_2M256
- ENV=normal_WROOM02_2M
- ENV=normal_alt_wifi_ESP8266_1M
- ENV=normal_alt_wifi_ESP8266_1M_VCC
- ENV=normal_alt_wifi_ESP8266_4M1M
#- ENV=normal_sdk3_ESP8266_1M
#- ENV=spec_debug_beta_custom_ESP8266_4M1M
#- ENV=spec_debug_custom_ESP32_4M316k
#- ENV=spec_debug_custom_ESP8266_4M1M
#- ENV=spec_memanalyze_ESP8266
- ENV=test_ESP32-wrover-kit_4M316k
- ENV=test_ESP32-wrover-kit_4M316k_ETH
- ENV=test_ESP32_4M316k
- ENV=test_ESP32_4M316k_ETH
- ENV=test_ESP32_4M316k_lolin_d32_pro
- ENV=test_ESP8266_4M1M_VCC
#- ENV=test_ESP8266_4M1M_VCC_MDNS_SD
#- ENV=test_alt_wifi_ESP8266_4M1M_VCC
#- ENV=test_beta_ESP8266_16M_LittleFS
- ENV=test_beta_ESP8266_4M1M
script:
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run -e $ENV
before_deploy:
- ./before_deploy
deploy:
provider: releases
prerelease: true
api_key:
secure: bZeuKI7evXeZYmGayfcvIC1fThBGcksAyOrCbZ8kAGeTbHGJqFLBBy8to5UpNBSZVfeDWo25Iqy8Pfbyb7p2c1hg6fG9jS0UzQkLnoUNMxpUM1dJACkZxvFdP4Br3Y3vUPWtrWUbo8rN/b3E6tjSNLE7vQiwsarj+eWTO2V6BGcsN0eHc04/UCM2+DcHvJ4y7Ec36yIUaClNAWMal1osBYaViruylOdBKT/WDs1ZMoJMceXCfxMQ/8J2moYvymKfSkXSmoMGmzlTuq8v5N4AweutjpC4Zba2BbxIJv+PwWjhfIgTviHFggSU90UPTKVWYv13vms92VVKz1CDVrUQNn+YQes9+ROPUnrMc9bJ+q7E1lWJRZeDMqGECB+8BjUtUk6H81K+XhOnW1mtZiMnvMCwkmE0OT1eBObGMcpR962/DUBoQDmulMs2IieB0dLobmUBhpc1syrKEPKxjY7yhhQMr6In82jODVLR3qDkNQ8xtIfevzCo/ocUjiOrXW4b/pDMy28Yh109DMb/KSWEsjjkkpXhsT1YVy2MwOa7FRhHFW+SNKX4Us8T75H+pO4mQ4afnPEtjYKodj7XD92zqNxKfMx3elEx5RK6HKekHjpXdYtuXzGONB9StA+2T43/2llt3n5fzv4BRfCumBEJ77/ufB0U/uhsCe6lVwJf34U=
file_glob: true
file: ESPEasy*.zip
skip_cleanup: true
on:
tags: true
# repo: psy0rz/ESPEasy-platformio
notifications:
email: false
+1 -1
View File
@@ -2,7 +2,7 @@
PATCH=puya_core2_4_x.patch
for DIR in ~/.platformio/packages/framework-arduinoespressif8266*/; do
for DIR in ~/.platformio/packages/framework-arduinoespressif8266/ ~/.platformio/packages/framework-arduinoespressif8266*/; do
#not applied yet? (in upstream or otherwise)
if ! grep "PUYA" $DIR/cores/esp8266/Esp.cpp >/dev/null; then
+2 -1
View File
@@ -73,7 +73,8 @@ extra_scripts = tools/pio/gzip-firmware.py
[extra_scripts_default]
extra_scripts = pre:tools/pio/concat_cpp_files.py
extra_scripts = pre:tools/pio/set-ci-defines.py
pre:tools/pio/concat_cpp_files.py
pre:tools/pio/generate-compiletime-defines.py
tools/pio/copy_files.py
post:tools/pio/remove_concat_cpp_files.py
+3 -6
View File
@@ -31,8 +31,7 @@
; -mtarget-align see: https://github.com/arendst/Sonoff-Tasmota/issues/3678#issuecomment-419712437
[esp82xx_defaults]
build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
-D NDEBUG
build_flags = -D NDEBUG
-lstdc++ -lsupc++
-mtarget-align
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
@@ -41,8 +40,7 @@ build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
lib_ignore = ESP32_ping, ESP32WebServer, ESP32HTTPUpdateServer, ServoESP32, IRremoteESP8266, HeatpumpIR
[esp82xx_2_5_x]
build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
-DNDEBUG
build_flags = -DNDEBUG
-mtarget-align
-DVTABLES_IN_FLASH
-fno-exceptions
@@ -62,8 +60,7 @@ lib_ignore = ${esp82xx_defaults.lib_ignore}
;[core_2_3_0]
;platform = https://github.com/TD-er/platform-espressif8266.git#patch/v1.5.0_Puya
;build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
; -DNDEBUG
;build_flags = -DNDEBUG
; -DVTABLES_IN_FLASH
; -fno-exceptions
; -DPUYA_SUPPORT=1
-1
View File
@@ -18,7 +18,6 @@ extra_scripts = post:tools/pio/post_esp32.py
${extra_scripts_default.extra_scripts}
build_unflags = -Wall
build_flags = ${mqtt_flags.build_flags}
-D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
-DCONFIG_FREERTOS_ASSERT_DISABLE
-DCONFIG_LWIP_ESP_GRATUITOUS_ARP
-DCONFIG_LWIP_GARP_TMR_INTERVAL=30
+43
View File
@@ -0,0 +1,43 @@
import json
from platformio.project.config import ProjectConfig
def get_jobs(cfg):
for env in cfg.envs():
platform = cfg.get("env:{}".format(env), "platform")
if "espressif8266" in platform:
yield {"chip": "esp8266", "env": env}
elif "espressif32" in platform:
yield {"chip": "esp32", "env": env}
else:
raise ValueError("Unknown `platform = {}` for `[env:{}]`".format(platform, env))
def filter_jobs(jobs, ignore=("spec_",)):
for job in jobs:
if job["env"].startswith(ignore):
continue
yield job
jobs = filter_jobs(get_jobs(ProjectConfig.get_instance()))
# XXX for testing
def get_one_of_each(jobs):
seen = set()
for job in jobs:
if not job["chip"] in seen:
seen.add(job["chip"])
yield job
# ref. https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/
# we need to echo something like this:
# ::set-output name=matrix::{"include": [{"chip": "esp8266", "env": "custom_ESP8266_4M1M"}, {"chip": "esp32", "env": "custom_ESP32_4M316k"}]}
fmt = "::set-output name=matrix::{}"
out = fmt.format(json.dumps({"include": list(get_one_of_each(jobs))}))
print(out)
# XXX for testing
# ... Normal run will dump the whole jobs list as-is ...
+1 -1
View File
@@ -80,4 +80,4 @@ print("\u001b[33m GIT_HEAD: \u001b[0m {}".format(get_git_description()))
print("\u001b[32m ------------------------------- \u001b[0m")
env.AddBuildMiddleware(gen_compiletime_defines)
env.AddBuildMiddleware(gen_compiletime_defines)
-2
View File
@@ -60,8 +60,6 @@ else:
"-DUSE_SETTINGS_ARCHIVE"
]
my_flags = env.ParseFlags(env['BUILD_FLAGS'])
my_defines = my_flags.get("CPPDEFINES")
env.Append(BUILD_FLAGS=custom_defines)
+22
View File
@@ -0,0 +1,22 @@
Import("env")
import os
def get_github_actions_git_tag():
ref = os.environ.get("GITHUB_REF", "")
if ref and ref.startswith("refs/tags/"):
return ref[len("refs/tags/") :]
return ""
if "true" == os.environ.get("CI", "false"):
defines = [
"CONTINUOUS_INTEGRATION",
("BUILD_GIT", '\\\"{}\\\"'.format(get_github_actions_git_tag())),
]
else:
defines = [("BUILD_GIT", '\\\"\\\"')]
env.Append(CPPDEFINES=defines)
+32
View File
@@ -0,0 +1,32 @@
import os
import pathlib
from itertools import chain
from github import Github
def find_zip(directory):
return pathlib.Path(directory).glob("**/*.zip")
if __name__ == "__main__":
tag = os.environ["GITHUB_REF"][len("refs/tags/") :]
# TODO: does not really work :(
# see the workflow generating this artifact
with open("artifact/ReleaseNotes.txt", "r") as f:
message = f.read()
# Binaries/ - .elf + .bin
# artifact/ - docs, upload tools, etc.
archives = [
str(zip_file) for zip_file in chain(find_zip("Binaries"), find_zip("artifact"))
]
print("Prepared for tag={} and archives={}".format(tag, archives))
gh = Github(os.environ["GITHUB_TOKEN"])
repo = gh.get_repo(os.environ["GITHUB_REPOSITORY"])
release = repo.create_git_release(tag=tag, name=tag, message=message)
for path in archives:
release.upload_asset(path)