mirror of
https://github.com/1technophile/OpenMQTTGateway.git
synced 2026-02-25 19:21:42 +01:00
* Refactor GitHub Actions workflows for build, documentation, and linting - Consolidated build logic into reusable workflows (`task-build.yml` and `task-docs.yml`) to reduce duplication across multiple workflows. - Introduced `environments.json` to centralize the list of PlatformIO build environments, improving maintainability and clarity. - Updated `build.yml` and `build_and_docs_to_dev.yml` to utilize the new reusable workflows and environment definitions. - Enhanced `release.yml` to streamline the release process and integrate documentation generation. - Created reusable linting workflow (`task-lint.yml`) to standardize code formatting checks across the repository. - Simplified manual documentation workflow by leveraging the new reusable documentation workflow. - Improved artifact management and retention policies across workflows. - Updated dependencies and versions in workflows to ensure compatibility and performance. * CI/CD pipeline agnostic of Workflow Engine and integrated on github actions - Implemented ci.sh for orchestrating the complete build pipeline. - Created ci_00_config.sh for centralized configuration of build scripts. - Created ci_build_firmware.sh for building firmware for specified PlatformIO environments. - Created ci_prepare_artifacts.sh for preparing firmware artifacts for upload or deployment. - Created ci_set_version.sh for updating version tags in firmware configuration files. - Created ci_build.sh to orchestrate the complete build pipeline. - Created ci_qa.sh for code linting and formatting checks using clang-format. - Created ci_site.sh for building and deploying VuePress documentation with version management. - Implemented checks for required tools and dependencies in the new scripts. - Updated common_wu.py, compressFirmware.py, gen_wu.py, generate_board_docs.py, and prepare_deploy.sh with descriptive comments. Refactor CI/CD scripts for improved modularity and clarity - Consolidated build steps in task-build.yml to utilize ci.sh for version tagging, building, and artifact preparation. - Updated task-lint.yml to use ci.sh for code formatting checks instead of ci_qa.sh. - Enhanced CI_SCRIPTS.md documentation to reflect changes in script usage, command structure, and output organization. - Improved internal scripts for better error handling and logging. - Streamlined the output structure for build artifacts and documentation.
35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
# Compresses firmware binaries with gzip for OTA updates during build
|
|
# Used by: PlatformIO environments (optional, commented in environments.ini)
|
|
import gzip
|
|
import shutil
|
|
import os
|
|
Import("env")
|
|
|
|
|
|
def compressFirmware(source, target, env):
|
|
""" Compress firmware using gzip for 'compressed OTA upload' """
|
|
SOURCE_FILE = env.subst("$BUILD_DIR") + os.sep + env.subst("$PROGNAME") + ".bin"
|
|
SOURCE_BAK = SOURCE_FILE + '.bak'
|
|
do_compress = True
|
|
if os.path.exists(SOURCE_FILE) and os.path.exists(SOURCE_BAK):
|
|
src_mtime = os.stat(SOURCE_FILE).st_mtime
|
|
bak_mtime = os.stat(SOURCE_BAK).st_mtime
|
|
""" Recompress if .bin file is newer than .bak file """
|
|
do_compress = (src_mtime > bak_mtime)
|
|
|
|
if do_compress:
|
|
print("Compressing firmware for upload...")
|
|
shutil.move(SOURCE_FILE, SOURCE_BAK)
|
|
with open(SOURCE_BAK, 'rb') as f_in:
|
|
with gzip.open(SOURCE_FILE, 'wb', compresslevel = 9) as f_out:
|
|
shutil.copyfileobj(f_in, f_out)
|
|
""" Set modification time on compressed file so incremental build works """
|
|
shutil.copystat(SOURCE_BAK, SOURCE_FILE)
|
|
|
|
if os.path.exists(SOURCE_BAK):
|
|
ORG_FIRMWARE_SIZE = os.stat(SOURCE_BAK).st_size
|
|
GZ_FIRMWARE_SIZE = os.stat(SOURCE_FILE).st_size
|
|
|
|
print("Compression reduced firmware size to {:.0f}% (was {} bytes, now {} bytes)".format((GZ_FIRMWARE_SIZE / ORG_FIRMWARE_SIZE) * 100, ORG_FIRMWARE_SIZE, GZ_FIRMWARE_SIZE))
|
|
|
|
env.AddPostAction("$BUILD_DIR/firmware.bin", [compressFirmware]) |