Skip to content

Commit

Permalink
DO NOT MERGE - Debug Script
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard84 committed Aug 20, 2024
1 parent 58ec2e7 commit c24590c
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 293 deletions.
69 changes: 0 additions & 69 deletions .github/workflows/branches-and-prs.yml

This file was deleted.

62 changes: 0 additions & 62 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/debug-script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'Debug Script'

on:
push:
branches-ignore:
- master
- gh-pages
pull_request:
merge_group:

# https://stackoverflow.com/a/72408109/16358266
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build-and-verify:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
variant: ['3.0', '4.0']
java: ['21', '22']
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
steps:
- uses: actions/checkout@v4
with:
# Codecov needs fetch-depth > 1
fetch-depth: 2
- name: 'Set up JDKs'
uses: ./.github/actions/setup-build-env
with:
additional-java-version: ${{ matrix.java }}
- name: 'Build Spock'
# secrets are not injected for pull requests
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
run: ./repeatUntilFailure.sh ./gradlew --stacktrace :spock-specs:test --rerun "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.java }}"
38 changes: 0 additions & 38 deletions .github/workflows/docs-pr.yml

This file was deleted.

10 changes: 0 additions & 10 deletions .github/workflows/gradle-wrapper-validation.yml

This file was deleted.

114 changes: 0 additions & 114 deletions .github/workflows/release.yml

This file was deleted.

59 changes: 59 additions & 0 deletions repeatUntilFailure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Ensure that a command is provided as an argument
if [ $# -eq 0 ]; then
echo "No command provided. Usage: ./run_until_fail.sh <command>"
exit 1
fi

# Command to run (passed as script arguments)
COMMAND="$@"
MAX_RETRIES=10 # Set the maximum number of retries
COUNTER=0 # Initialize the retry counter
CHECK_INTERVAL=5 # Interval in seconds to check if the command is still running

while [ $COUNTER -lt $MAX_RETRIES ]; do
# Increment the retry counter
COUNTER=$((COUNTER + 1))
echo "Attempt $COUNTER of $MAX_RETRIES..."

# Start the command in the background
bash -c "$COMMAND" &
COMMAND_PID=$!

# Track elapsed time
ELAPSED_TIME=0

# Check periodically if the command has completed
while ps -p $COMMAND_PID > /dev/null; do
sleep $CHECK_INTERVAL
ELAPSED_TIME=$((ELAPSED_TIME + CHECK_INTERVAL))

if [ $ELAPSED_TIME -ge 60 ]; then
echo "Warning: The command has been running for more than 1 minute."

# Run the jcmd command to print thread information
jcmd $(jps -v | grep SpockTestConfig.groovy | awk '{print $1}') Thread.print

# Wait for the command to complete
wait $COMMAND_PID
break
fi
done

# Capture the exit status
wait $COMMAND_PID
STATUS=$?

# Check if the command failed
if [ $STATUS -ne 0 ]; then
echo "The command failed with exit status $STATUS. Exiting loop."
break
fi

# Check if the retry limit has been reached
if [ $COUNTER -ge $MAX_RETRIES ]; then
echo "Reached the maximum number of retries ($MAX_RETRIES). Exiting."
break
fi
done

0 comments on commit c24590c

Please sign in to comment.