|
| 1 | +name: Distro Layer Validation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + schedule: |
| 9 | + # Run weekly on Sundays at 4 AM UTC |
| 10 | + - cron: '0 4 * * 0' |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + yocto_branch: |
| 14 | + description: 'Yocto branch to test against' |
| 15 | + required: false |
| 16 | + default: 'scarthgap' |
| 17 | + type: choice |
| 18 | + options: |
| 19 | + - scarthgap |
| 20 | + - kirkstone |
| 21 | + - nanbield |
| 22 | + |
| 23 | +env: |
| 24 | + DEBIAN_FRONTEND: noninteractive |
| 25 | + |
| 26 | +jobs: |
| 27 | + validate-distro-layer: |
| 28 | + name: Validate Distro Layer |
| 29 | + runs-on: ubuntu-22.04 |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + yocto_branch: [scarthgap, kirkstone] |
| 34 | + include: |
| 35 | + - yocto_branch: scarthgap |
| 36 | + oe_core_branch: scarthgap |
| 37 | + bitbake_branch: 2.8 |
| 38 | + - yocto_branch: kirkstone |
| 39 | + oe_core_branch: kirkstone |
| 40 | + bitbake_branch: 2.0 |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout Distro Layer |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + |
| 48 | + - name: Install System Dependencies |
| 49 | + run: | |
| 50 | + sudo apt-get update |
| 51 | + sudo apt-get install -y \ |
| 52 | + build-essential \ |
| 53 | + chrpath \ |
| 54 | + cpio \ |
| 55 | + diffstat \ |
| 56 | + gawk \ |
| 57 | + git \ |
| 58 | + python3 \ |
| 59 | + python3-pip \ |
| 60 | + python3-pexpect \ |
| 61 | + python3-git \ |
| 62 | + python3-jinja2 \ |
| 63 | + python3-subunit \ |
| 64 | + socat \ |
| 65 | + texinfo \ |
| 66 | + unzip \ |
| 67 | + wget \ |
| 68 | + xz-utils \ |
| 69 | + debianutils \ |
| 70 | + iputils-ping \ |
| 71 | + libegl1-mesa \ |
| 72 | + libsdl1.2-dev \ |
| 73 | + mesa-common-dev \ |
| 74 | + pylint \ |
| 75 | + xterm \ |
| 76 | + curl \ |
| 77 | + locales |
| 78 | +
|
| 79 | + - name: Configure Locale |
| 80 | + run: | |
| 81 | + sudo locale-gen en_US.UTF-8 |
| 82 | + sudo update-locale LANG=en_US.UTF-8 |
| 83 | +
|
| 84 | + - name: Cache Yocto Downloads |
| 85 | + uses: actions/cache@v3 |
| 86 | + with: |
| 87 | + path: | |
| 88 | + build/downloads |
| 89 | + build/sstate-cache |
| 90 | + key: distro-yocto-${{ matrix.yocto_branch }}-${{ github.sha }} |
| 91 | + restore-keys: | |
| 92 | + distro-yocto-${{ matrix.yocto_branch }}- |
| 93 | +
|
| 94 | + - name: Setup Yocto Environment |
| 95 | + run: | |
| 96 | + # Create build directory structure |
| 97 | + mkdir -p build/layers |
| 98 | + |
| 99 | + # Clone OpenEmbedded-Core for the specific branch |
| 100 | + git clone -b ${{ matrix.oe_core_branch }} \ |
| 101 | + https://github.com/openembedded/openembedded-core.git \ |
| 102 | + build/layers/openembedded-core |
| 103 | + |
| 104 | + # Clone BitBake for the specific branch |
| 105 | + git clone -b ${{ matrix.bitbake_branch }} \ |
| 106 | + https://github.com/openembedded/bitbake.git \ |
| 107 | + build/layers/bitbake |
| 108 | + |
| 109 | + # Clone meta-openembedded for additional dependencies |
| 110 | + git clone -b ${{ matrix.oe_core_branch }} \ |
| 111 | + https://github.com/openembedded/meta-openembedded.git \ |
| 112 | + build/layers/meta-openembedded |
| 113 | +
|
| 114 | + - name: Validate Distro Layer Structure |
| 115 | + run: | |
| 116 | + echo "=== Validating Distro Layer Structure ===" |
| 117 | + |
| 118 | + # Check required files exist |
| 119 | + echo "📁 Checking required files..." |
| 120 | + for file in README.md SECURITY.md LICENSE conf/layer.conf; do |
| 121 | + if [ -f "$file" ]; then |
| 122 | + echo "✅ $file: Present" |
| 123 | + else |
| 124 | + echo "❌ $file: Missing" |
| 125 | + exit 1 |
| 126 | + fi |
| 127 | + done |
| 128 | + |
| 129 | + # Check distro-specific structure |
| 130 | + echo "📋 Checking distro-specific structure..." |
| 131 | + if [ -d "conf/distro" ]; then |
| 132 | + echo "✅ Distro configurations: $(ls conf/distro/*.conf | wc -l) found" |
| 133 | + else |
| 134 | + echo "❌ No distro configurations found" |
| 135 | + exit 1 |
| 136 | + fi |
| 137 | + |
| 138 | + # Ensure no machine configurations (distro layer separation) |
| 139 | + if [ -d "conf/machine" ]; then |
| 140 | + echo "❌ Distro layer should not contain machine configurations" |
| 141 | + exit 1 |
| 142 | + else |
| 143 | + echo "✅ No machine configurations (correct for distro layer)" |
| 144 | + fi |
| 145 | + |
| 146 | + # Ensure no BSP recipes (distro layer separation) |
| 147 | + if [ -d "recipes-bsp" ]; then |
| 148 | + echo "❌ Distro layer should not contain BSP recipes" |
| 149 | + exit 1 |
| 150 | + else |
| 151 | + echo "✅ No BSP recipes (correct for distro layer)" |
| 152 | + fi |
| 153 | + |
| 154 | + # Validate layer.conf syntax |
| 155 | + echo "📋 Validating layer.conf syntax..." |
| 156 | + python3 -c " |
| 157 | + import sys |
| 158 | + try: |
| 159 | + with open('conf/layer.conf', 'r') as f: |
| 160 | + content = f.read() |
| 161 | + required_vars = ['BBFILE_COLLECTIONS', 'BBFILE_PATTERN', 'BBFILE_PRIORITY', 'LAYERVERSION'] |
| 162 | + for var in required_vars: |
| 163 | + if var not in content: |
| 164 | + print(f'❌ Missing required variable: {var}') |
| 165 | + sys.exit(1) |
| 166 | + # Check for distro-specific patterns |
| 167 | + if 'meta-dynamicdevices-distro' not in content: |
| 168 | + print('❌ Layer collection name should be meta-dynamicdevices-distro') |
| 169 | + sys.exit(1) |
| 170 | + print('✅ layer.conf syntax valid for distro layer') |
| 171 | + except Exception as e: |
| 172 | + print(f'❌ layer.conf validation failed: {e}') |
| 173 | + sys.exit(1) |
| 174 | + " |
| 175 | +
|
| 176 | + - name: Run yocto-check-layer on Distro Layer |
| 177 | + run: | |
| 178 | + echo "=== Running yocto-check-layer on Distro Layer ===" |
| 179 | + |
| 180 | + # Set up BitBake environment |
| 181 | + export PYTHONPATH="build/layers/bitbake/lib:$PYTHONPATH" |
| 182 | + export PATH="build/layers/bitbake/bin:build/layers/openembedded-core/scripts:$PATH" |
| 183 | + |
| 184 | + # Create minimal build configuration |
| 185 | + mkdir -p build/conf |
| 186 | + |
| 187 | + # Create bblayers.conf |
| 188 | + cat > build/conf/bblayers.conf << EOF |
| 189 | + LCONF_VERSION = "7" |
| 190 | + BBPATH = "\${TOPDIR}" |
| 191 | + BBFILES ?= "" |
| 192 | + BBLAYERS ?= " \\ |
| 193 | + \${TOPDIR}/../build/layers/openembedded-core/meta \\ |
| 194 | + \${TOPDIR}/../build/layers/meta-openembedded/meta-oe \\ |
| 195 | + \${TOPDIR}/.. \\ |
| 196 | + " |
| 197 | + EOF |
| 198 | + |
| 199 | + # Create local.conf with distro-specific configuration |
| 200 | + cat > build/conf/local.conf << EOF |
| 201 | + MACHINE ??= "qemux86-64" |
| 202 | + DISTRO ?= "lmp-dynamicdevices" |
| 203 | + PACKAGE_CLASSES ?= "package_rpm" |
| 204 | + EXTRA_IMAGE_FEATURES ?= "debug-tweaks" |
| 205 | + USER_CLASSES ?= "buildstats" |
| 206 | + PATCHRESOLVE = "noop" |
| 207 | + BB_DISKMON_DIRS ??= "\\ |
| 208 | + STOPTASKS,\${TMPDIR},1G,100K \\ |
| 209 | + STOPTASKS,\${DL_DIR},1G,100K \\ |
| 210 | + STOPTASKS,\${SSTATE_DIR},1G,100K \\ |
| 211 | + STOPTASKS,/tmp,100M,100K \\ |
| 212 | + HALT,\${TMPDIR},100M,1K \\ |
| 213 | + HALT,\${DL_DIR},100M,1K \\ |
| 214 | + HALT,\${SSTATE_DIR},100M,1K \\ |
| 215 | + HALT,/tmp,10M,1K" |
| 216 | + CONF_VERSION = "2" |
| 217 | + DL_DIR ?= "\${TOPDIR}/downloads" |
| 218 | + SSTATE_DIR ?= "\${TOPDIR}/sstate-cache" |
| 219 | + EOF |
| 220 | + |
| 221 | + # Run the layer check |
| 222 | + cd build |
| 223 | + python3 ../build/layers/openembedded-core/scripts/yocto-check-layer \ |
| 224 | + --layer .. \ |
| 225 | + --output-log ../distro-layer-check-${{ matrix.yocto_branch }}.log \ |
| 226 | + || true # Don't fail immediately, let us analyze the results |
| 227 | +
|
| 228 | + - name: Analyze Distro Layer Check Results |
| 229 | + run: | |
| 230 | + echo "=== Analyzing Distro Layer Check Results ===" |
| 231 | + |
| 232 | + if [ -f "distro-layer-check-${{ matrix.yocto_branch }}.log" ]; then |
| 233 | + echo "📊 Distro layer check log found, analyzing results..." |
| 234 | + cat "distro-layer-check-${{ matrix.yocto_branch }}.log" |
| 235 | + |
| 236 | + # Check for critical errors |
| 237 | + if grep -q "ERROR" "distro-layer-check-${{ matrix.yocto_branch }}.log"; then |
| 238 | + echo "❌ Critical errors found in distro layer validation" |
| 239 | + grep "ERROR" "distro-layer-check-${{ matrix.yocto_branch }}.log" |
| 240 | + exit 1 |
| 241 | + fi |
| 242 | + |
| 243 | + # Check for warnings |
| 244 | + if grep -q "WARNING" "distro-layer-check-${{ matrix.yocto_branch }}.log"; then |
| 245 | + echo "⚠️ Warnings found in distro layer validation" |
| 246 | + grep "WARNING" "distro-layer-check-${{ matrix.yocto_branch }}.log" |
| 247 | + fi |
| 248 | + |
| 249 | + echo "✅ Distro layer validation completed successfully" |
| 250 | + else |
| 251 | + echo "❌ Distro layer check log not found" |
| 252 | + exit 1 |
| 253 | + fi |
| 254 | +
|
| 255 | + - name: Upload Distro Layer Check Results |
| 256 | + uses: actions/upload-artifact@v3 |
| 257 | + if: always() |
| 258 | + with: |
| 259 | + name: distro-layer-check-results-${{ matrix.yocto_branch }} |
| 260 | + path: | |
| 261 | + distro-layer-check-*.log |
| 262 | + build/conf/ |
| 263 | + retention-days: 30 |
| 264 | + |
| 265 | + - name: Distro Layer Compliance Summary |
| 266 | + run: | |
| 267 | + echo "=== Distro Layer Compliance Summary ===" |
| 268 | + echo "🎛️ Layer Type: Distro (Distribution Policy)" |
| 269 | + echo "📦 Yocto Branch: ${{ matrix.yocto_branch }}" |
| 270 | + echo "✅ Structure Validation: Passed" |
| 271 | + echo "✅ Required Files: Present" |
| 272 | + echo "✅ Distro Configurations: $(ls conf/distro/*.conf 2>/dev/null | wc -l)" |
| 273 | + echo "✅ Image Recipes: $(find recipes-* -name "*.bb" 2>/dev/null | wc -l)" |
| 274 | + echo "✅ Layer Separation: No BSP/machine mixing detected" |
| 275 | + echo "✅ yocto-check-layer: Completed" |
| 276 | + echo "" |
| 277 | + echo "🎯 Distro Layer Status: Ready for Yocto Project Compatible certification" |
| 278 | +
|
| 279 | + compliance-report: |
| 280 | + name: Generate Distro Compliance Report |
| 281 | + runs-on: ubuntu-22.04 |
| 282 | + needs: validate-distro-layer |
| 283 | + if: always() |
| 284 | + |
| 285 | + steps: |
| 286 | + - name: Checkout Distro Layer |
| 287 | + uses: actions/checkout@v4 |
| 288 | + |
| 289 | + - name: Download All Artifacts |
| 290 | + uses: actions/download-artifact@v3 |
| 291 | + with: |
| 292 | + path: artifacts/ |
| 293 | + |
| 294 | + - name: Generate Distro Compliance Report |
| 295 | + run: | |
| 296 | + echo "# Distro Layer Yocto Project Compatible Validation Report" > distro-compliance-report.md |
| 297 | + echo "" >> distro-compliance-report.md |
| 298 | + echo "**Generated**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> distro-compliance-report.md |
| 299 | + echo "**Commit**: ${{ github.sha }}" >> distro-compliance-report.md |
| 300 | + echo "**Branch**: ${{ github.ref_name }}" >> distro-compliance-report.md |
| 301 | + echo "**Layer Type**: Distro (Distribution Policy)" >> distro-compliance-report.md |
| 302 | + echo "" >> distro-compliance-report.md |
| 303 | + |
| 304 | + echo "## Distro Layer Validation Results" >> distro-compliance-report.md |
| 305 | + echo "" >> distro-compliance-report.md |
| 306 | + |
| 307 | + # Analyze artifacts and generate report |
| 308 | + for artifact_dir in artifacts/*/; do |
| 309 | + if [ -d "$artifact_dir" ]; then |
| 310 | + artifact_name=$(basename "$artifact_dir") |
| 311 | + echo "### $artifact_name" >> distro-compliance-report.md |
| 312 | + |
| 313 | + # Look for log files |
| 314 | + if ls "$artifact_dir"/*.log >/dev/null 2>&1; then |
| 315 | + for log_file in "$artifact_dir"/*.log; do |
| 316 | + echo "#### $(basename "$log_file")" >> distro-compliance-report.md |
| 317 | + echo '```' >> distro-compliance-report.md |
| 318 | + tail -20 "$log_file" >> distro-compliance-report.md |
| 319 | + echo '```' >> distro-compliance-report.md |
| 320 | + echo "" >> distro-compliance-report.md |
| 321 | + done |
| 322 | + fi |
| 323 | + fi |
| 324 | + done |
| 325 | + |
| 326 | + echo "## Distro Layer Summary" >> distro-compliance-report.md |
| 327 | + echo "" >> distro-compliance-report.md |
| 328 | + echo "- **Layer Type**: Distro (Distribution Policy)" >> distro-compliance-report.md |
| 329 | + echo "- **Distribution Variants**: Multiple LmP-based configurations" >> distro-compliance-report.md |
| 330 | + echo "- **Security Features**: Disabled zeroconf, enhanced policies" >> distro-compliance-report.md |
| 331 | + echo "- **Compliance Status**: Ready for Yocto Project Compatible certification" >> distro-compliance-report.md |
| 332 | + echo "" >> distro-compliance-report.md |
| 333 | + echo "For detailed requirements, see the main repository [docs/YOCTO_PROJECT_COMPATIBLE.md](https://github.com/DynamicDevices/meta-dynamicdevices/blob/main/docs/YOCTO_PROJECT_COMPATIBLE.md)" >> distro-compliance-report.md |
| 334 | +
|
| 335 | + - name: Upload Distro Compliance Report |
| 336 | + uses: actions/upload-artifact@v3 |
| 337 | + with: |
| 338 | + name: distro-yocto-compliance-report |
| 339 | + path: distro-compliance-report.md |
| 340 | + retention-days: 90 |
| 341 | + |
| 342 | + - name: Comment PR with Distro Results |
| 343 | + if: github.event_name == 'pull_request' |
| 344 | + uses: actions/github-script@v6 |
| 345 | + with: |
| 346 | + script: | |
| 347 | + const fs = require('fs'); |
| 348 | + const report = fs.readFileSync('distro-compliance-report.md', 'utf8'); |
| 349 | + |
| 350 | + github.rest.issues.createComment({ |
| 351 | + issue_number: context.issue.number, |
| 352 | + owner: context.repo.owner, |
| 353 | + repo: context.repo.repo, |
| 354 | + body: `## 🎛️ Distro Layer Validation Results\n\n${report}` |
| 355 | + }) |
0 commit comments