continuwuity/.forgejo/actions/display-log-group/action.yml
Tom Foster b481ff31c0 ci: Consolidate workflows and optimise build pipeline performance
Merge rust-checks.yml and release-image.yml into unified ci-build.yml
workflow that runs faster and more efficiently. The previous setup ran
4+ parallel jobs immediately (format, clippy, test, builds), causing
resource contention. The new pipeline runs max 2 jobs in parallel at
each stage, catching lint/format issues quickly before attempting
expensive compilation.

Extract all Rust setup logic from both workflows into reusable
rust-with-cache composite action. This replaces 6 separate actions
(rust-toolchain, sccache, timelord, plus inline APT/cache steps) with
a single action that handles:
- Rust toolchain installation with component selection
- Cross-compilation configuration (previously scattered across
  release-image.yml)
- System dependency installation with proper error handling
- Comprehensive caching (sccache, cargo registry, cargo target, uv
  tools)
- Timeline tracking and performance monitoring

The previous release-image.yml had cross-compilation support but it
was implemented inline with complex environment variables. The new
rust-with-cache action centralises this with proper parameters for
pkg-config paths, foreign architecture setup, and toolchain selection.

Performance improvements make the pipeline fast enough to consolidate:
- Warmed sccache cache shared between check and build stages
- Optimised cargo target cache to exclude incremental/ and binaries
  (was caching entire target/ directory via buildkit-cache-dance)
- Add restore-keys fallback for better cache hit rates
- Parallel background tasks for Rust setup while APT runs
- Fail-fast on format/lint errors before expensive compilation
- Enable Haswell CPU optimisations for x86_64 builds (AVX2, FMA, etc.)
- Add cross-language LTO (Link-Time Optimisation) for better performance

Fix ARM64 cross-compilation reliability issues:
- Move APT installations from background to foreground (background
  processes would hang during package downloads despite
  DEBIAN_FRONTEND=noninteractive)
- Set proper pkg-config environment for cross-compilation
- Configure APT sources to ports.ubuntu.com for foreign architectures
- Replace hardened_malloc with jemalloc (ARM64 unsupported)

Modernisation from previous commit (b0ebdb59):
- prefligit renamed to prek (avoid typosquatting)
- Direct uvx rustup replacing custom rust-toolchain action
- Workflow renames: deploy-element, deploy-docs, docker-mirror
- Renovate configuration for .forgejo/ workflows
- fix-byte-order-marker replacing check-byte-order-marker

Docker improvements:
- Remove buildkit-cache-dance injection (now handled natively)
- Align tag naming between arch-specific and multi-platform builds
- Add branch- prefix for non-default branches
- Reserve latest-{arch} tags for version releases only
- Remove dynamic library extraction logic (ldd doesn't work for
  cross-compiled binaries; Rust --release produces mostly-static binaries)

Additional improvements based on maintainer feedback:
- Generate SBOM (Software Bill of Materials) for security compliance
- Include SBOM in uploaded build artefacts alongside binary

The consolidated pipeline completes in ~10 minutes with better
resource utilisation and clearer failure diagnostics. Both x86_64 and
ARM64 builds now work reliably with the centralised cross-compilation
configuration.
2025-08-15 22:50:41 +01:00

81 lines
2.9 KiB
YAML

name: display-log-group
description: |
Display a log file in a collapsible group with timing and error handling.
Expects log files to have ELAPSED_TIME and EXIT_CODE metadata lines.
inputs:
name:
description: 'Name of the task (for display)'
required: true
log-file:
description: 'Path to the log file'
required: true
done-file:
description: 'Path to the done marker file to wait for'
required: true
group-icon:
description: 'Icon to show in group title'
required: false
default: '📦'
filter-pattern:
description: 'Optional grep pattern to filter output'
required: false
default: ''
max-lines:
description: 'Maximum lines to show (0 for unlimited)'
required: false
default: '0'
runs:
using: composite
steps:
- name: Display ${{ inputs.name }} results
shell: bash
run: |
# Wait for task completion
while [ ! -f "${{ inputs.done-file }}" ]; do
sleep 0.1
done
echo "::group::${{ inputs.group-icon }} ${{ inputs.name }}"
if [ -f "${{ inputs.log-file }}" ]; then
# Extract metadata
ELAPSED=$(grep "^ELAPSED_TIME=" "${{ inputs.log-file }}" | cut -d= -f2 || echo "unknown")
TOTAL=$(grep "^TOTAL_TIME=" "${{ inputs.log-file }}" | cut -d= -f2 || echo "")
EXIT_CODE=$(grep "^EXIT_CODE=" "${{ inputs.log-file }}" | cut -d= -f2 || echo "1")
# Show output (excluding metadata lines)
if [[ -n "${{ inputs.filter-pattern }}" ]]; then
# Filter output by pattern
grep -E "${{ inputs.filter-pattern }}" "${{ inputs.log-file }}" | grep -v "^ELAPSED_TIME=\|^EXIT_CODE=\|^TOTAL_TIME=" || true
else
# Show full output
if [[ "${{ inputs.max-lines }}" != "0" ]]; then
grep -v "^ELAPSED_TIME=\|^EXIT_CODE=\|^TOTAL_TIME=" "${{ inputs.log-file }}" | head -${{ inputs.max-lines }}
else
grep -v "^ELAPSED_TIME=\|^EXIT_CODE=\|^TOTAL_TIME=" "${{ inputs.log-file }}"
fi
fi
# Show result with timing info
if [ "$EXIT_CODE" = "0" ]; then
if [ -n "$TOTAL" ]; then
echo "✅ ${{ inputs.name }} completed (${ELAPSED}s task, ${TOTAL}s total)"
else
echo "✅ ${{ inputs.name }} completed (${ELAPSED}s)"
fi
else
if [ -n "$TOTAL" ]; then
echo "⚠️ ${{ inputs.name }} had issues (exit code: $EXIT_CODE) (${ELAPSED}s task, ${TOTAL}s total)"
else
echo "⚠️ ${{ inputs.name }} had issues (exit code: $EXIT_CODE) (${ELAPSED}s)"
fi
# Don't exit with failure - let the main job continue so we can see what went wrong
# The actual build steps will fail if packages are missing
fi
else
echo "⚠️ No log file found at ${{ inputs.log-file }}"
fi
echo "::endgroup::"