mirror of
https://github.com/1technophile/OpenMQTTGateway.git
synced 2026-03-13 02:37:25 +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. - Improved internal scripts for better error handling and logging. UPDATE the web installer manifest generation and update documentation structure - Enhanced ci_list-env.sh to list environments from a JSON file. - Replaced common_wu.py and gen_wu.py scripts with new npm scripts for site generation and previewing on docsgen/gen_wu.js - Replaced generate_board_docs.py with docsgen/generated_board_docs.js - Added new npm scripts for integration of site generation on build phase. - Created preview_site.js to serve locally generated site over HTTPS with improved error handling. - Added new CI environments for CI builds in environments.json. - Deleted lint.yml as part of workflow cleanup. - Enhanced task-build.yml to include linting as a job and added support for specifying PlatformIO version. - Improved task-docs.yml to handle versioning more effectively and added clean option. Enhance documentation - ADD CLEAR Mark of development version of site - Updated README.md to include detailed workflow dependencies and relationships using mermaid diagrams. - Improved development.md with a quick checklist for contributors and clarified the code style guide. - Enhanced quick_start.md with tips for contributors and streamlined the workflow explanation. LINT FIX - Refined User_config.h for better formatting consistency. - Adjusted blufi.cpp and gatewayBT.cpp for improved code readability and consistency in formatting. - Updated gatewaySERIAL.cpp and mqttDiscovery.cpp to enhance logging error messages. - Improved sensorDS1820.cpp for better logging of device information. Add security scan workflows for vulnerability detection Add SBOM generation and upload to release workflow; update security scan summary handling Add shellcheck suppor + FIX shellcheck warning Enhance documentation for CI/CD scripts and workflows, adding details for security scanning and SBOM generation processes Fix formatting and alignment in BLE connection handling Reviewed the full web board presentation and the ESP32 web upload. The project uses a modern pattern where data is divided from the presentation layer. - Removed the `generate_board_docs` script. - Updated the `gen_wu` script in order to generate `boards-info.json`: the fail that containe all information about the configuration - Created and isolate the file `boards-info.js` to streamline the parsing of PlatformIO dependencies, modules, environments and improve the handling of library information. - Introduced vuepress component `BoardEnvironmentTable.vue` that render `boards-info.json` as UI card component - Introduced vuepress component `FlashEnvironmentSelector.vue` that render a selectred environment from `boards-info.json` and provide esp-web-upload feature on it - Introduced a new board page `board-selector.md` for improved firmware selection. - Updated `web-install.md` to enhance the firmware upload process, including a new board environment table. - Enhanced custom descriptions in `environments.ini` to include HTML links for better user guidance and board image link Add CC1101 initialization improvements and logging enhancements Add installation step for PlatformIO dependencies in documentation workflow Remove ci_set_version.sh script and associated versioning functionality * Fix comment provisined Fix PlatformIO version input reference in documentation workflow Remove outdated Squeezelite-ESP32 installer documentation
233 lines
7.4 KiB
JavaScript
233 lines
7.4 KiB
JavaScript
'use strict';
|
|
/**
|
|
* Universal parser for PlatformIO dependencies.
|
|
* Formats URLs and registry strings into a consistent "Registry Style":
|
|
* Name @ Version (provider:user)
|
|
*/
|
|
function smartFormat(dep) {
|
|
if (!dep) return "";
|
|
if (typeof dep !== 'string') return dep;
|
|
|
|
const cleanDep = dep.trim();
|
|
|
|
// Configuration for Git providers with specific regex for archives, releases, and git repos
|
|
const providers = [
|
|
{
|
|
id: 'gh',
|
|
name: 'github',
|
|
// Captures: 1. Author, 2. Repo, 3. Version from path (releases), 4. Version from filename/branch
|
|
regex: /github\.com\/([^/]+)\/([^/.]+)(?:\/(?:archive|releases\/download\/([^/]+)|tree)\/)?([^/]+)?(?:\.zip|\.git)?$/i
|
|
},
|
|
{
|
|
id: 'gl',
|
|
name: 'gitlab',
|
|
// Captures: 1. Author, 2. Repo, 3. Version from path, 4. Version from filename
|
|
regex: /gitlab\.com\/([^/]+)\/([^/.]+)(?:\/(?:-\/)?(?:archive|releases)\/([^/]+))?\/([^/]+)?(?:\.zip|\.git)?$/i
|
|
},
|
|
{
|
|
id: 'bb',
|
|
name: 'bitbucket',
|
|
// Captures: 1. Author, 2. Repo, 3. Version from path, 4. Version from filename
|
|
regex: /bitbucket\.org\/([^/]+)\/([^/.]+)(?:\/(?:get|downloads)\/([^/]+))?\/([^/]+)?(?:\.zip|\.git)?$/i
|
|
}
|
|
];
|
|
|
|
// 1. Try to match against Git providers (GitHub, GitLab, Bitbucket)
|
|
for (const p of providers) {
|
|
const match = cleanDep.match(p.regex);
|
|
if (match) {
|
|
let [_, author, repo, pathVer, fileVer] = match;
|
|
|
|
// Prioritize version from path (typical in releases) over filename
|
|
let version = pathVer || fileVer || "latest";
|
|
|
|
// Clean up version string: remove extensions and 'v' prefix
|
|
version = version
|
|
.replace(/\.(zip|git|tar\.gz)$/i, '')
|
|
.replace(/^v(\d)/i, '$1'); // Removes 'v' only if followed by a number
|
|
|
|
// Avoid redundancy if the version string is identical to the repo name
|
|
if (version.toLowerCase() === repo.toLowerCase()) {
|
|
version = "latest";
|
|
}
|
|
|
|
return `${repo} @ ${version} (${p.id}:${author})`;
|
|
}
|
|
}
|
|
|
|
// 2. Fallback for Standard PlatformIO Registry format (e.g., owner/lib @ ^1.0.0)
|
|
if (cleanDep.includes('/') || cleanDep.includes('@')) {
|
|
const parts = cleanDep.split('@');
|
|
const fullName = parts[0].trim(); // Includes owner/name
|
|
|
|
// Clean up version if present
|
|
let version = "latest";
|
|
if (parts[1]) {
|
|
version = parts[1].trim().replace(/^[\^~=]/, '');
|
|
}
|
|
|
|
// Separate owner and library name for consistent formatting
|
|
if (fullName.includes('/')) {
|
|
const [owner, libName] = fullName.split('/');
|
|
return `${libName.trim()} @ ${version} (pio:${owner.trim()})`;
|
|
}
|
|
|
|
return `${fullName} @ ${version}`;
|
|
}
|
|
|
|
// 3. Return original string if no patterns match
|
|
return cleanDep;
|
|
}
|
|
|
|
function rowConfigFromPlatformIO() {
|
|
const { execSync } = require('child_process');
|
|
|
|
try {
|
|
const jsonConfig = execSync('pio project config --json-output').toString();
|
|
const config = JSON.parse(jsonConfig);
|
|
return config;
|
|
} catch (error) {
|
|
console.error("Make sure PlatformIO Core is installed and in PATH");
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
function cleanValue(v) {
|
|
if (typeof v !== 'string') return v;
|
|
return v
|
|
.replace(/{/g, '')
|
|
.replace(/}/g, '')
|
|
.replace(/\$/g, '')
|
|
.replace(/env:/g, '')
|
|
.replace(/'/g, '')
|
|
.replace(/-D/g, '');
|
|
}
|
|
|
|
function convertJsonToSections(jsonConfig) {
|
|
const sections = {};
|
|
jsonConfig.forEach(([sectionName, configArray]) => {
|
|
sections[sectionName] = {};
|
|
configArray.forEach(([key, value]) => {
|
|
sections[sectionName][key] = value;
|
|
});
|
|
});
|
|
return sections;
|
|
}
|
|
|
|
function cleanLibraries(raw) {
|
|
if (!raw) return [];
|
|
if (typeof raw === 'string') {
|
|
raw = raw.split(',')
|
|
}
|
|
return raw.map((dep) => smartFormat(dep));
|
|
}
|
|
|
|
function extractModulesFromFlags(flags) {
|
|
if (!flags) return [];
|
|
let flagArray = [];
|
|
if (Array.isArray(flags)) {
|
|
flagArray = flags;
|
|
} else if (typeof flags === 'string') {
|
|
flagArray = flags.split(',').map(s => s.trim()).filter(s => s.length > 0);
|
|
} else {
|
|
return [];
|
|
}
|
|
const modules = [];
|
|
flagArray.forEach((flag) => {
|
|
// Match -DZmoduleName, allowing surrounding quotes
|
|
const match = flag.match(/^['" ]*-DZ([^=]+)/);
|
|
if (match) {
|
|
const moduleName = match[1];
|
|
// Additional constraint: must contain 'gateway', 'sensor', or 'actuator'
|
|
if (moduleName.includes('gateway') || moduleName.includes('sensor') || moduleName.includes('actuator')) {
|
|
modules.push(moduleName);
|
|
}
|
|
}
|
|
//if MQTT_BROKER_MODE = true then modules.push("MQTT Broker Mode");
|
|
const brokerMatch = flag.match(/^['" ]*-DMQTT_BROKER_MODE(?:=([^'"\s]+))?/);
|
|
if (brokerMatch) {
|
|
const value = brokerMatch[1];
|
|
// Add only if not explicitly set to false (case insensitive)
|
|
if (!value || value.toLowerCase() !== 'false') {
|
|
modules.push("MQTT Broker Mode");
|
|
}
|
|
}
|
|
|
|
});
|
|
return modules;
|
|
}
|
|
|
|
function collectBoardsInformations(sections, { includeTests = false } = {}) {
|
|
const rows = [];
|
|
|
|
Object.entries(sections).forEach(([section, items]) => {
|
|
if (!section.includes('env:')) return;
|
|
if (!includeTests && section.includes('-test')) return;
|
|
|
|
const env = section.replace('env:', '');
|
|
let uc = '';
|
|
let hardware = '';
|
|
let description = '';
|
|
let modules = [];
|
|
let platform = '';
|
|
let partitions = '';
|
|
let libraries = [];
|
|
let options = [];
|
|
let customImg = '';
|
|
|
|
Object.entries(items).forEach(([k, raw]) => {
|
|
const v = cleanValue(raw);
|
|
|
|
|
|
if (k === 'board') uc = v;
|
|
if (k === 'platform') platform = smartFormat(v);
|
|
if (k === 'board_build.partitions') partitions = v;
|
|
if (k === 'custom_description') description = v;
|
|
if (k === 'custom_hardware') hardware = v;
|
|
if (k === 'custom_img') customImg = v;
|
|
|
|
if (k === 'lib_deps') {
|
|
libraries = cleanLibraries(raw);
|
|
}
|
|
|
|
if (k === 'build_flags') {
|
|
options = v;
|
|
modules = extractModulesFromFlags(v);
|
|
}
|
|
});
|
|
|
|
rows.push({
|
|
Environment: env,
|
|
uC: uc,
|
|
Hardware: hardware,
|
|
Description: description,
|
|
Modules: modules,
|
|
Platform: platform,
|
|
Partitions: partitions,
|
|
Libraries: libraries,
|
|
Options: options,
|
|
CustomImg: customImg
|
|
});
|
|
});
|
|
|
|
rows.sort((a, b) => a.Environment.localeCompare(b.Environment, 'en', { sensitivity: 'base' }));
|
|
return rows;
|
|
}
|
|
|
|
function loadBoardsInfo(options = {}) {
|
|
const { includeTests = false } = options;
|
|
const config = rowConfigFromPlatformIO();
|
|
const sections = convertJsonToSections(config);
|
|
return collectBoardsInformations(sections, { includeTests });
|
|
}
|
|
|
|
function ensureDir(dir) {
|
|
const fs = require('fs');
|
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
}
|
|
|
|
module.exports = {
|
|
loadBoardsInfo,
|
|
ensureDir
|
|
};
|