Skip to content

Commit

Permalink
Merge pull request #226 from RuffaloLavoisier/AMAL
Browse files Browse the repository at this point in the history
CI : reduce time and analyze detailed results
  • Loading branch information
simonmicro authored May 17, 2022
2 parents 7ce0972 + a6b7474 commit 5bf9b17
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 58 deletions.
105 changes: 55 additions & 50 deletions .github/buildEverything.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@
editions.append(line.strip()[5:-1])
fh.close()

# Find all languages
languages = []
langIncludePath = os.path.join('include', 'locales')
for fName in os.listdir(langIncludePath):
if os.path.join(os.path.join(langIncludePath, fName)):
languages.append(fName[:-2]) # This drops off the .h

# And compile!
def compile_model(lang):
def compile_model(lang, edition):
# Configs
includeConfig = os.path.join('include', 'config.h')

Expand All @@ -38,66 +45,64 @@ def compile_model(lang):
# Always clean after changing the language (just-in-case)
logging.info('Cleanup...')
subprocess.run(['pio', 'run', '-t', 'clean'], capture_output=True)
for edition in editions:
filename = edition + '-' + lang + '.bin'
try:
os.remove(os.path.join('.', filename))
logging.info('Deleted ' + filename)
except OSError:
pass

# Compile editions
for edition in editions:
def doBuild(makeDebug):
# Setup variables
filename = edition + '-' + lang + ('-debug' if makeDebug else '') + '.bin'

# Setup build type (using the config file via replacing, as platformio does not allow setting the property using Python)
configIn = open(pioConfig, 'r')
configStr = configIn.read()
configIn.close()
configStr, hitCount = re.subn('(build_type\s?=\s?)(\w+)', r'\1' + ('debug' if makeDebug else 'release'), configStr)
if hitCount == 0:
logging.error('Error on setting build type!')
exit(4)
configOut = open(pioConfig, 'w')
configOut.write(configStr)
configOut.close()
filename = edition + '-' + lang + '.bin'
try:
os.remove(os.path.join('.', filename))
logging.info('Deleted ' + filename)
except OSError:
pass

# Compile firmware
logging.info('Compiling ' + filename + '...')
try:
res = subprocess.run(['pio', 'run', '-e', edition], capture_output=True)
except KeyboardInterrupt:
exit(3)
if res.returncode != 0:
logging.error('COMPILATION FAILED')
logging.error(res.stderr.decode())
exit(2)
# "Export" firmware.bin
shutil.copy(os.path.join('.pio', 'build', edition, 'firmware.bin'), os.path.join('.', filename))
doBuild(True)
doBuild(False)
# Compile editions
def doBuild(makeDebug):
# Setup variables
filename = edition + '-' + lang + ('-debug' if makeDebug else '') + '.bin'

# Setup build type (using the config file via replacing, as platformio does not allow setting the property using Python)
configIn = open(pioConfig, 'r')
configStr = configIn.read()
configIn.close()
configStr, hitCount = re.subn('(build_type\s?=\s?)(\w+)', r'\1' + ('debug' if makeDebug else 'release'), configStr)
if hitCount == 0:
logging.error('Error on setting build type!')
exit(4)
configOut = open(pioConfig, 'w')
configOut.write(configStr)
configOut.close()

# Compile firmware
logging.info('Compiling ' + filename + '...')
try:
res = subprocess.run(['pio', 'run', '-e', edition], capture_output=True)
except KeyboardInterrupt:
exit(3)
if res.returncode != 0:
logging.error('COMPILATION FAILED')
logging.error(res.stderr.decode())
exit(2)
# "Export" firmware.bin
shutil.copy(os.path.join('.pio', 'build', edition, 'firmware.bin'), os.path.join('.', filename))
doBuild(True)
doBuild(False)

if __name__ == "__main__":

ap = argparse.ArgumentParser()

ap.add_argument("-l", "--support-language", type=str, required=True, help="# model language to compile. (Enter 'all' to compile all language packs.)")
ap.add_argument("-m", "--support-model", type=str, required=True, help="# model type to compile. (Enter 'all' to compile all model packs.)")
args = vars(ap.parse_args())

#if you want all-language packs
if args["support_language"] == "all":

# Find all languages
languages = []
langIncludePath = os.path.join('include', 'locales')
for fName in os.listdir(langIncludePath):
if os.path.join(os.path.join(langIncludePath, fName)):
languages.append(fName[:-2]) # This drops off the .h

if args["support_language"] == "all" and args["support_model"] == "all":
for lang in languages:
for edition in editions:
compile_model(lang,edition)
elif args["support_language"] == "all" and args["support_model"] != "all":
for lang in languages:
compile_model(lang)
compile_model(lang, args["support_model"])
elif args["support_language"] != "all" and args["support_model"] == "all":
for edition in editions:
compile_model(args["support_language"], edition)
else :
compile_model(args["support_language"])
compile_model(args["support_language"], args["support_model"])
20 changes: 12 additions & 8 deletions .github/workflows/test-OSW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@ on:
branches: [ master, develop ]

jobs:
find-languages:
Find-packages:
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: recursive
- id: set-matrix
- id: get-languages
run: echo "::set-output name=languages_matrix::$(cd include/locales/; X=$(ls *.h -1 | sed -e 's/\.h$//' | tr '\n' ' '); X=($X); jq --compact-output --null-input '$ARGS.positional' --args -- "${X[@]}")"
- id: get-models
run: echo "::set-output name=models_matrix::$(F=$(cat platformio.ini | grep "\[\env:" | sed -e 's/\[\env://' | tr ']\n' ' ');F=($F);jq --compact-output --null-input '$ARGS.positional' --args -- "${F[@]}")"
outputs:
languages_matrix: ${{ steps.set-matrix.outputs.languages_matrix }}
build_linux:
needs: find-languages
languages_matrix: ${{ steps.get-languages.outputs.languages_matrix }}
models_matrix: ${{ steps.get-models.outputs.models_matrix }}
build-OSW:
needs: Find-packages
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: ${{ fromJson(needs.find-languages.outputs.languages_matrix) }}
language: ${{ fromJson(needs.Find-packages.outputs.languages_matrix) }}
model: ${{ fromJson(needs.Find-packages.outputs.models_matrix) }}
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
Expand All @@ -50,8 +54,8 @@ jobs:
run: python -m pip install --upgrade pip && pip install --upgrade platformio
- name: Rename config
run: mv include/config.h.example include/config.h
- name: Compile language ${{ matrix.language }} model
run: python3 .github/buildEverything.py -l ${{ matrix.language }}
- name: Compile language ${{ matrix.language }} model ${{ matrix.model }}
run: python3 .github/buildEverything.py -l ${{ matrix.language }} -m ${{ matrix.model }}
- name: Upload firmware artifacts
uses: actions/upload-artifact@v2
with:
Expand Down

0 comments on commit 5bf9b17

Please sign in to comment.