[CI] Refactor GitHub Actions workflows for build, documentation, and linting (#2260)
* 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.
This commit is contained in:
1 parent
fd433c220e
commit
134c03362c
27 files changed
+4151
-346
No files matched your search
@@ -0,0 +1,127 @@
|
||||
name: Reusable Documentation Workflow
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
python-version:
|
||||
description: 'Python version to use'
|
||||
required: false
|
||||
type: string
|
||||
default: '3.11'
|
||||
node-version:
|
||||
description: 'Node.js version to use'
|
||||
required: false
|
||||
type: string
|
||||
default: '14.x'
|
||||
version-source:
|
||||
description: 'Source of version: "release" (from GitHub release) or "custom" (provided)'
|
||||
required: false
|
||||
type: string
|
||||
default: 'release'
|
||||
custom-version:
|
||||
description: 'Custom version string when version-source is "custom"'
|
||||
required: false
|
||||
type: string
|
||||
default: ''
|
||||
base-path:
|
||||
description: 'Base path for documentation (e.g., "/" for prod, "/dev/" for dev)'
|
||||
required: false
|
||||
type: string
|
||||
default: '/'
|
||||
destination-dir:
|
||||
description: 'Destination directory for GitHub Pages deployment'
|
||||
required: false
|
||||
type: string
|
||||
default: '.'
|
||||
generate-webuploader:
|
||||
description: 'Generate WebUploader manifest'
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
webuploader-args:
|
||||
description: 'Additional arguments for gen_wu.py script'
|
||||
required: false
|
||||
type: string
|
||||
default: ''
|
||||
run-pagespeed:
|
||||
description: 'Run PageSpeed Insights after deployment'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
pagespeed-url:
|
||||
description: 'URL to test with PageSpeed Insights'
|
||||
required: false
|
||||
type: string
|
||||
default: 'https://docs.openmqttgateway.com/'
|
||||
secrets:
|
||||
GITHUB_TOKEN:
|
||||
required: true
|
||||
APIKEY:
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
documentation:
|
||||
runs-on: ubuntu-latest
|
||||
name: Create and deploy documentation
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ inputs.node-version }}
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ inputs.python-version }}
|
||||
|
||||
- name: Build documentation site
|
||||
run: |
|
||||
# Build script arguments based on inputs
|
||||
ARGS=""
|
||||
|
||||
# Set version source and custom version
|
||||
if [ "${{ inputs.version-source }}" = "custom" ] && [ -n "${{ inputs.custom-version }}" ]; then
|
||||
ARGS="$ARGS --custom-version '${{ inputs.custom-version }}' --version-source custom"
|
||||
elif [ "${{ inputs.version-source }}" = "release" ]; then
|
||||
# Get latest release tag
|
||||
if command -v git >/dev/null 2>&1; then
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "development")
|
||||
ARGS="$ARGS --custom-version '${LATEST_TAG}' --version-source release"
|
||||
else
|
||||
ARGS="$ARGS --version-source release"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Set base path/URL prefix
|
||||
if [ "${{ inputs.base-path }}" != "/" ]; then
|
||||
ARGS="$ARGS --url-prefix '${{ inputs.base-path }}'"
|
||||
fi
|
||||
|
||||
# WebUploader generation
|
||||
if [ "${{ inputs.generate-webuploader }}" != "true" ]; then
|
||||
ARGS="$ARGS --no-webuploader"
|
||||
elif [ -n "${{ inputs.webuploader-args }}" ]; then
|
||||
ARGS="$ARGS --webuploader-args '${{ inputs.webuploader-args }}'"
|
||||
fi
|
||||
|
||||
# Run the build script
|
||||
eval "./scripts/ci_site.sh ${ARGS}"
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./generated/site
|
||||
destination_dir: ${{ inputs.destination-dir }}
|
||||
cname: docs.openmqttgateway.com
|
||||
|
||||
- name: Run PageSpeed Insights
|
||||
if: inputs.run-pagespeed
|
||||
uses: jakepartusch/psi-action@v1.3
|
||||
id: psi
|
||||
with:
|
||||
url: ${{ inputs.pagespeed-url }}
|
||||
threshold: 60
|
||||
key: ${{ secrets.APIKEY }}
|
||||
Reference in new issue
Block a user