diff --git a/docs/haf-app-testing.md b/docs/haf-app-testing.md index a826d67ed3741cc3607bd57d3adfcabe0246f2c7..ac601c18599d76235f3dc70203683666cc742b51 100644 --- a/docs/haf-app-testing.md +++ b/docs/haf-app-testing.md @@ -348,6 +348,73 @@ sync: - # Full sync logic ``` +## Early Exit Templates + +Early exit templates let jobs run but exit immediately when no work is needed. Unlike skip rules, these jobs show as "passed" in the pipeline. + +### .haf_app_early_exit_on_skip + +Exit early when `AUTO_SKIP_SYNC=true` or `AUTO_SKIP_BUILD=true`: + +```yaml +build_something: + script: + - !reference [.haf_app_early_exit_on_skip, script] + - # Actual build logic (only runs if not skipped) +``` + +### .haf_app_early_exit_on_quick_test + +Exit early when `QUICK_TEST=true`: + +```yaml +prepare_data: + script: + - !reference [.haf_app_early_exit_on_quick_test, script] + - # Data preparation (skipped in quick test mode) +``` + +### .haf_app_early_exit_on_cached + +Exit early on either condition (QUICK_TEST or AUTO_SKIP): + +```yaml +sync: + script: + - !reference [.haf_app_early_exit_on_cached, script] + - # Sync logic (skipped if using cached data) +``` + +## Skip Pattern Presets + +Pre-configured skip patterns for common HAF app types. + +### .haf_app_skip_patterns_standard + +Standard patterns for HAF apps without a GUI: + +```yaml +detect_changes: + extends: + - .haf_app_detect_changes + - .haf_app_skip_patterns_standard +``` + +Skips: `tests/`, `docs/`, `*.md`, `README`, `CHANGELOG`, `LICENSE`, `CLAUDE`, `.gitlab-ci` + +### .haf_app_skip_patterns_with_gui + +For HAF apps with a frontend GUI: + +```yaml +detect_changes: + extends: + - .haf_app_detect_changes + - .haf_app_skip_patterns_with_gui +``` + +Skips: All standard patterns plus `gui/` + ## Quick Test Mode For rapid iteration, set these variables to skip full HAF sync: diff --git a/templates/haf_app_testing.gitlab-ci.yml b/templates/haf_app_testing.gitlab-ci.yml index 417d743fb46297019b371d25c40205923ac9251e..1cab222e010042ef9d0e3dcba83d1e695ad631e7 100644 --- a/templates/haf_app_testing.gitlab-ci.yml +++ b/templates/haf_app_testing.gitlab-ci.yml @@ -587,6 +587,79 @@ include: when: never - when: on_success +# ============================================================================= +# EARLY EXIT TEMPLATES +# ============================================================================= +# These templates allow jobs to RUN but EXIT EARLY when no work is needed. +# Use these when you want the job to appear as "passed" rather than "skipped". +# +# Difference from .skip_on_* rules: +# - .skip_on_* rules: Job never runs (shows as "skipped" in pipeline) +# - .early_exit_*: Job runs but exits immediately (shows as "passed") +# +# Use early exit when: +# - You need the job to exist for dependency chains +# - You want explicit "nothing to do" feedback in logs +# - The job has artifacts that downstream jobs expect (even if empty) + +# Early exit script for docs/tests-only changes +# Use with !reference in your script section: +# script: +# - !reference [.haf_app_early_exit_on_skip, script] +# - # Your actual work here... +.haf_app_early_exit_on_skip: + script: + - | + if [[ "${AUTO_SKIP_SYNC:-false}" == "true" ]] || [[ "${AUTO_SKIP_BUILD:-false}" == "true" ]]; then + echo "=== Early Exit: No work needed ===" + echo "Only documentation, tests, or non-critical files changed." + echo "Exiting with success." + exit 0 + fi + +# Early exit for QUICK_TEST mode +.haf_app_early_exit_on_quick_test: + script: + - | + if [[ "${QUICK_TEST:-false}" == "true" ]]; then + echo "=== Early Exit: QUICK_TEST mode ===" + echo "Using pre-cached data, skipping this job." + exit 0 + fi + +# Combined early exit (either condition) +.haf_app_early_exit_on_cached: + script: + - | + if [[ "${QUICK_TEST:-false}" == "true" ]]; then + echo "=== Early Exit: QUICK_TEST mode ===" + echo "Using pre-cached data, skipping this job." + exit 0 + fi + if [[ "${AUTO_SKIP_SYNC:-false}" == "true" ]] || [[ "${AUTO_SKIP_BUILD:-false}" == "true" ]]; then + echo "=== Early Exit: No work needed ===" + echo "Only documentation, tests, or non-critical files changed." + exit 0 + fi + +# ============================================================================= +# SKIP PATTERN PRESETS +# ============================================================================= +# Common skip pattern configurations for different app types. +# Override HAF_APP_SKIP_PATTERNS in your detect_changes job. + +# Standard HAF app patterns (tests, docs, markdown, CI config) +# Use: extends: .haf_app_skip_patterns_standard +.haf_app_skip_patterns_standard: + variables: + HAF_APP_SKIP_PATTERNS: '^tests/|^docs/|\.md$|^README|^CHANGELOG|^LICENSE|^CLAUDE|^\.gitlab-ci' + +# HAF app with GUI (adds gui/ directory to skip list) +# Use: extends: .haf_app_skip_patterns_with_gui +.haf_app_skip_patterns_with_gui: + variables: + HAF_APP_SKIP_PATTERNS: '^tests/|^docs/|^gui/|\.md$|^README|^CHANGELOG|^LICENSE|^CLAUDE|^\.gitlab-ci' + # ============================================================================= # SYNC JOB COMPONENTS # =============================================================================