Files
lvgl/.github/workflows/code_generation.yml
T

132 lines
5.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Code Generation
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency
# Ensure that only one commit will be running tests at a time on each PR
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
code-generation:
name: Code Generation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: 3.12
- name: Install dependencies
# sbom/requirements.txt pins the SBOM validator so an unreviewed
# upstream release cannot silently change or break the compliance gate.
run: python3 -m pip install kconfiglib pytest -r sbom/requirements.txt
# ------------------------------------------------------------------
# Unit tests for the config-headers generator itself.
# ------------------------------------------------------------------
- name: "Test: config headers generator"
id: config-headers-tests
continue-on-error: true
working-directory: scripts/generators
run: python3 -m pytest config_headers/test/ -q
# ------------------------------------------------------------------
# Config headers: lv_conf_template.h, lv_conf_internal.h and
# lv_conf_kconfig.h are generated from the Kconfig tree. Regenerate
# them and fail if the committed files differ.
# ------------------------------------------------------------------
- name: "Generate: config headers (Kconfig)"
id: config-headers
continue-on-error: true
run: |
python3 scripts/generators/config_files.py
git diff --exit-code -- \
Kconfig \
lv_conf_template.h \
include/lvgl/config/lv_conf_internal.h \
include/lvgl/config/lv_conf_kconfig.h \
|| (echo "::error::Generated config headers are out of date. Run scripts/generators/config_headers.py and commit the result."; exit 1)
git restore .
# ------------------------------------------------------------------
# Style API: style_gen.c/h and documentation
# ------------------------------------------------------------------
- name: "Generate: style api"
id: style-api
continue-on-error: true
run: |
python3 scripts/generators/style_api.py
git diff --exit-code || (echo "::error::Generated styles are out of date. Run scripts/generators/style_api.py and commit the result."; exit 1)
git restore .
# ------------------------------------------------------------------
# COPYRIGHTS.md and the SPDX SBOM (sbom/) are generated from
# sbom/third_party.json. These fail if a committed output is stale.
# ------------------------------------------------------------------
- name: "Check: COPYRIGHTS.md is up to date"
id: copyrights
continue-on-error: true
run: python3 scripts/generate_copyrights.py --check
- name: "Check: SPDX SBOM is up to date"
id: sbom
continue-on-error: true
run: python3 scripts/generate_sbom.py --check
# ------------------------------------------------------------------
# The SBOM validates against the official SPDX 3.0.1 JSON Schema.
# ------------------------------------------------------------------
- name: "Check: SPDX SBOM is schema-valid"
id: sbom_schema
continue-on-error: true
run: python3 scripts/validate_sbom.py
# ------------------------------------------------------------------
# Final gate fail the job if any generator above is out of date.
# This gives us full output from every generator before failing.
# New generators: add a step above and a line here.
# ------------------------------------------------------------------
- name: "Gate: fail if any generator check failed"
if: |
steps.config-headers-tests.outcome == 'failure' ||
steps.config-headers.outcome == 'failure' ||
steps.style-api.outcome == 'failure' ||
steps.copyrights.outcome == 'failure' ||
steps.sbom.outcome == 'failure' ||
steps.sbom_schema.outcome == 'failure'
run: |
echo "Code generation results:"
echo "------------------------"
print_result() {
local name="$1"
local outcome="$2"
if [ "$outcome" = "success" ]; then
echo " ✅ $name"
else
echo " ❌ $name"
fi
}
print_result "config-headers-tests" "${{ steps.config-headers-tests.outcome }}"
print_result "config-headers" "${{ steps.config-headers.outcome }}"
print_result "style-api" "${{ steps.style-api.outcome }}"
print_result "copyrights" "${{ steps.copyrights.outcome }}"
print_result "sbom" "${{ steps.sbom.outcome }}"
print_result "sbom_schema" "${{ steps.sbom_schema.outcome }}"
echo "------------------------"
echo "A generator test failed, or a generated file is out of date. See above for details."
exit 1