Skip to content

Fix broken pipe during test and gracefully exit the server #53

Fix broken pipe during test and gracefully exit the server

Fix broken pipe during test and gracefully exit the server #53

Workflow file for this run

name: flakiness
defaults:
run:
shell: bash
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true
on:
# Run on PRs that touch relevant areas and on manual dispatch
pull_request:
branches:
- '**'
paths:
- 'scripts/flaky-test-loop.sh'
- 'scripts/flaky-test-patterns.txt'
- 'ghcide/**'
- 'ghcide-test/**'
- 'hls-test-utils/**'
- 'src/**'
- 'exe/**'
- 'plugins/**'
- 'cabal.project'
- 'stack.yaml'
- 'haskell-language-server.cabal'
- '.github/workflows/flakiness.yml'
workflow_dispatch:
inputs:
max_iter:
description: 'Maximum iterations to attempt'
required: false
default: '1000'
sleep_secs:
description: 'Seconds to sleep between iterations'
required: false
default: '0'
test_patterns:
description: 'Comma-separated Tasty patterns to run each iteration (overrides default)'
required: false
default: ''
jobs:
loop:
name: Flakiness Test (broken pipe and test failures)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup GHC and caching
uses: ./.github/actions/setup-build
with:
ghc: '9.12'
os: ${{ runner.os }}
- name: Show cabal and GHC versions
run: |
cabal --version
ghc --version
- name: Build
env:
PATTERN_FILE: 'scripts/flaky-test-patterns.txt'
RUN_MODE: 'build'
run: HLS_TEST_EXE="$(cabal exec which hls)" bash scripts/flaky-test-loop.sh
- name: Run flakiness loop
id: run-loop
# Let this run for a while; build is done once inside the script
timeout-minutes: 60
env:
# Use workflow_dispatch inputs when present, else defaults
SLEEP_SECS: ${{ github.event.inputs.sleep_secs || '0' }}
LOG_STDERR: '1'
TEST_PATTERNS: ${{ github.event.inputs.test_patterns }}
PATTERN_FILE: 'scripts/flaky-test-patterns.txt'
NO_BUILD_ONCE: '1'
RUN_MODE: 'run'
# HLS_TEST_EXE: 'hls' # HLS_WRAPPER_TEST_EXE: 'hls-wrapper'
run: |
# Run with a sensible default of 500 iterations on PRs;
max_iter="${{ github.event.inputs.max_iter }}"
max_iter="${max_iter:-500}"
# copy hls to current dir so the script can find it
HLS_TEST_EXE="$(cabal exec which hls)" bash scripts/flaky-test-loop.sh "${max_iter}"
ec=$?
# Interpret exit codes from flaky-test-loop.sh
# 0 => no issues reproduced within MAX_ITER -> pass job
# 1 => issue reproduced (broken pipe or test failure) -> fail job
# 2+ => setup/infra error -> fail job
if [[ $ec -eq 1 ]]; then
echo "Issue reproduced (broken pipe or test failure): failing job"
exit 1
elif [[ $ec -eq 0 ]]; then
echo "No issues reproduced within MAX_ITER=${max_iter}: passing"
exit 0
else
echo "Loop script error (exit $ec): failing"
exit $ec
fi