Skip to content

Commit

Permalink
Added CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
danimtb committed Jan 8, 2019
1 parent 573b5ad commit c891f78
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

language: python
python:
- "2.7"

sudo: false

cache:
directories:
- "~/.platformio"

env:
- PLATFORMIO_CI_SRC=src/main.cpp

install:
- pip install -U platformio

script:
- python deploy.py

deploy:
provider: releases
api_key:
secure: $GITHUB_OAUTH_TOKEN
file_glob: true
file: pipersense_*.zip
skip_cleanup: true
on:
tags: true
42 changes: 42 additions & 0 deletions deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import shutil
from glob import glob

# Set platfomio envirnoments to build
envs = ["nodemcuv2"]

# Get version of firmware from travis tag, otherwise set test-build
version = os.getenv("TRAVIS_TAG", "test-build")

# Iterate to generate firmware files and remove not needed ones
for env in envs:
# Iterate to generate firmware files
os.system("platformio run -e %s -t buildfs" % env)
os.system("platformio run -e %s" % env)

# Remove not needed files
shutil.rmtree(os.path.abspath(os.path.join(".pioenvs", env, "FrameworkArduino")))
shutil.rmtree(os.path.abspath(os.path.join(".pioenvs", env, "src")))
os.remove(os.path.abspath(os.path.join(".pioenvs", env, "libFrameworkArduino.a")))
os.remove(os.path.abspath(os.path.join(".pioenvs", env, "libFrameworkArduinoVariant.a")))

for lib in glob(os.path.abspath(os.path.join(".pioenvs", env, "lib*"))):
shutil.rmtree(os.path.abspath(os.path.join(".pioenvs", env, lib)))

# Check built files exist, otherwise raise
if (os.path.exists(os.path.abspath(os.path.join(".pioenvs", env, "firmware.bin"))) and
os.path.exists(os.path.abspath(os.path.join(".pioenvs", env, "firmware.elf"))) and
os.path.exists(os.path.abspath(os.path.join(".pioenvs", env, "spiffs.bin")))):
print ("OK [%s]: All files created" % env)
else:
raise Exception("ERROR [%s]: Missing files" % env)

# Remove not needed external files
for element in glob(os.path.abspath(os.path.join(".pioenvs", "*"))):
if os.path.isfile(element):
os.remove(element)

# Create zip with firmware files for each platformio environment
shutil.make_archive(os.path.abspath("pipersense_%s" % version),
'zip',
os.path.abspath(os.path.join(".", ".pioenvs")))

0 comments on commit c891f78

Please sign in to comment.