Skip to content

Commit 42bbfbe

Browse files
committed
Refactor flakiness workflow and CI
1 parent 73ce412 commit 42bbfbe

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

.github/workflows/flakiness.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ jobs:
6666
run: |
6767
cabal --version
6868
ghc --version
69-
- name: build
70-
run: |
71-
cabal build all
69+
- name: Build
70+
env:
71+
PATTERN_FILE: 'scripts/flaky-test-patterns.txt'
72+
RUN_MODE: 'build'
73+
run: HLS_TEST_EXE="$(cabal exec which hls)" bash scripts/flaky-test-loop.sh
7274

7375
- name: Run flakiness loop
7476
id: run-loop
@@ -81,6 +83,7 @@ jobs:
8183
TEST_PATTERNS: ${{ github.event.inputs.test_patterns }}
8284
PATTERN_FILE: 'scripts/flaky-test-patterns.txt'
8385
NO_BUILD_ONCE: '1'
86+
RUN_MODE: 'run'
8487
# HLS_TEST_EXE: 'hls' # HLS_WRAPPER_TEST_EXE: 'hls-wrapper'
8588
run: |
8689
# Run with a sensible default of 500 iterations on PRs;

scripts/flaky-test-loop.sh

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# SHOW_EVERY : print progress/iteration header every N iterations (default: 100, 1 = every run, <=0 = disabled)
1111
# LOG_STDERR : set to 1 to enable verbose stderr logging (HLS_TEST_LOG_STDERR & HLS_TEST_HARNESS_STDERR) (default: 1)
1212
# NO_BUILD_ONCE : set to non-empty to skip the initial cabal build step
13+
# RUN_MODE : choose 'build' (build once and exit), 'run' (skip upfront build and just run), or 'both' (default)
1314
#
1415
# Test selection:
1516
# TEST_PATTERNS : comma-separated list of entries to run each iteration.
@@ -37,6 +38,7 @@ MAX_ITER="${MAX_ITER:-}"
3738
SLEEP_SECS="${SLEEP_SECS:-0}"
3839
SHOW_EVERY="${SHOW_EVERY:-1}"
3940
LOG_STDERR="${LOG_STDERR:-1}"
41+
RUN_MODE="${RUN_MODE:-both}" # build | run | both
4042

4143
# Allow providing a positional max iteration: ./open-close-loop.sh 50
4244
if [[ $# -ge 1 && -z "${MAX_ITER}" ]]; then
@@ -96,10 +98,11 @@ if [[ ${#items[@]} -eq 0 ]]; then
9698
exit 2
9799
fi
98100

99-
# Build required test binaries once upfront (unless NO_BUILD_ONCE is set)
100-
if [[ -z "${NO_BUILD_ONCE:-}" ]]; then
101-
# collect unique BIN names
101+
# Helper to build required test binaries once
102+
build_required_bins_once() {
103+
# collect unique BIN names from global 'items'
102104
declare -a bins_to_build=()
105+
local it bin seen b
103106
for it in "${items[@]}"; do
104107
bin="${it%%::*}"; seen=0
105108
if (( ${#bins_to_build[@]} > 0 )); then
@@ -110,11 +113,40 @@ if [[ -z "${NO_BUILD_ONCE:-}" ]]; then
110113
if (( ${#bins_to_build[@]} > 0 )); then
111114
echo "[loop] Building test targets once upfront: ${bins_to_build[*]}" >&2
112115
if ! cabal build "${bins_to_build[@]}" >&2; then
113-
echo "[loop][error] Build failed. Cannot proceed with tests." >&2
114-
exit 2
116+
echo "[loop][error] Build failed." >&2
117+
return 2
115118
fi
116-
echo "[loop] Build succeeded. Proceeding with tests." >&2
119+
echo "[loop] Build succeeded." >&2
117120
fi
121+
return 0
122+
}
123+
124+
# Honor RUN_MODE before any build/run
125+
case "${RUN_MODE}" in
126+
build)
127+
if ! build_required_bins_once; then exit 2; fi
128+
echo "[loop] RUN_MODE=build completed. Exiting without running tests." >&2
129+
exit 0
130+
;;
131+
run)
132+
echo "[loop] RUN_MODE=run: skipping upfront build, proceeding to run loop." >&2
133+
;;
134+
both)
135+
: # default behavior below
136+
;;
137+
*)
138+
echo "[loop][error] Invalid RUN_MODE='${RUN_MODE}'. Use one of: build | run | both." >&2
139+
exit 2
140+
;;
141+
esac
142+
143+
# Build required test binaries once upfront (unless NO_BUILD_ONCE is set or RUN_MODE=run)
144+
if [[ -z "${NO_BUILD_ONCE:-}" && "${RUN_MODE}" != "run" ]]; then
145+
if ! build_required_bins_once; then
146+
echo "[loop][error] Cannot proceed with tests due to build failure." >&2
147+
exit 2
148+
fi
149+
echo "[loop] Proceeding with tests." >&2
118150
fi
119151

120152
# Resolve binary path by name (cache results)

scripts/flaky-test-patterns.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# One tasty pattern per line. Lines starting with # are comments.
22
# Blank lines are ignored.
33

4-
# open close
4+
open close
55
# non local variable
66
# Notification Handlers
77
# bidirectional module dependency with hs-boot
@@ -17,4 +17,4 @@
1717
# hls-hlint-plugin-tests::adding hlint flags to plugin configuration removes hlint diagnostics
1818
# hls-explicit-imports-plugin-tests::ExplicitUsualCase inlay hints with client caps
1919
# hls-class-plugin-tests::Creates a placeholder for fmap
20-
hls-rename-plugin-tests::Rename
20+
# hls-rename-plugin-tests::Rename

0 commit comments

Comments
 (0)