| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -13,6 +13,8 @@ RUNS="20" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					COOKIE_JAR=/tmp/cookies | 
					 | 
					 | 
					 | 
					COOKIE_JAR=/tmp/cookies | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					CRUMB=$(curl -s --cookie-jar $COOKIE_JAR 'https://jenkins.comma.life/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)') | 
					 | 
					 | 
					 | 
					CRUMB=$(curl -s --cookie-jar $COOKIE_JAR 'https://jenkins.comma.life/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)') | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					FIRST_LOOP=1 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					function loop() { | 
					 | 
					 | 
					 | 
					function loop() { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  JENKINS_BRANCH="__jenkins_loop_${BRANCH}" | 
					 | 
					 | 
					 | 
					  JENKINS_BRANCH="__jenkins_loop_${BRANCH}" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  API_ROUTE="https://jenkins.comma.life/job/openpilot/job/$JENKINS_BRANCH" | 
					 | 
					 | 
					 | 
					  API_ROUTE="https://jenkins.comma.life/job/openpilot/job/$JENKINS_BRANCH" | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -20,15 +22,8 @@ function loop() { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  for run in $(seq 1 $((RUNS / 2))); do | 
					 | 
					 | 
					 | 
					  for run in $(seq 1 $((RUNS / 2))); do | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    N=2 | 
					 | 
					 | 
					 | 
					    N=2 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    TEST_BUILDS=() | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # Try to find previous builds | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ALL_BUILDS=( $(curl -s $API_ROUTE/api/json | jq .builds.[].number 2> /dev/null || :) ) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # Jenkins branches get deactivated after some time | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    BUILDABLE=$(curl -s $API_ROUTE/api/json | jq -e '.buildable' 2> /dev/null || echo "false") | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if [[ ${#ALL_BUILDS[@]} -eq 0 || $BUILDABLE != "true" ]]; then | 
					 | 
					 | 
					 | 
					    if [[ $FIRST_LOOP ]]; then | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      TEMP_DIR=$(mktemp -d) | 
					 | 
					 | 
					 | 
					      TEMP_DIR=$(mktemp -d) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      GIT_LFS_SKIP_SMUDGE=1 git clone --quiet -b $BRANCH --depth=1 --no-tags git@github.com:commaai/openpilot $TEMP_DIR | 
					 | 
					 | 
					 | 
					      GIT_LFS_SKIP_SMUDGE=1 git clone --quiet -b $BRANCH --depth=1 --no-tags git@github.com:commaai/openpilot $TEMP_DIR | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      git -C $TEMP_DIR checkout --quiet -b $JENKINS_BRANCH | 
					 | 
					 | 
					 | 
					      git -C $TEMP_DIR checkout --quiet -b $JENKINS_BRANCH | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -42,34 +37,21 @@ function loop() { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      echo 'waiting on Jenkins...' | 
					 | 
					 | 
					 | 
					      echo 'waiting on Jenkins...' | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      echo '' | 
					 | 
					 | 
					 | 
					      echo '' | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      sleep 90 | 
					 | 
					 | 
					 | 
					      sleep 90 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    else | 
					 | 
					 | 
					 | 
					      FIRST_LOOP="" | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      # Found some builds. Wait for them to end if they are still running | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      for i in ${ALL_BUILDS[@]}; do | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        running=$(curl -s $API_ROUTE/$i/api/json/ | jq .inProgress) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if [[ $running == "false" ]]; then | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          continue | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        fi | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        TEST_BUILDS=( ${ALL_BUILDS[@]} ) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        N=${#TEST_BUILDS[@]} | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        break | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      done | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    fi | 
					 | 
					 | 
					 | 
					    fi | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # No running builds found | 
					 | 
					 | 
					 | 
					    FIRST_BUILD=$(curl -s $API_ROUTE/api/json | jq .nextBuildNumber) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if [[ ${#TEST_BUILDS[@]} -eq 0 ]]; then | 
					 | 
					 | 
					 | 
					    LAST_BUILD=$((FIRST_BUILD+N-1)) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      FIRST_BUILD=$(curl -s $API_ROUTE/api/json | jq .nextBuildNumber) | 
					 | 
					 | 
					 | 
					    TEST_BUILDS=( $(seq $FIRST_BUILD $LAST_BUILD) ) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      LAST_BUILD=$((FIRST_BUILD+N-1)) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      TEST_BUILDS=( $(seq $FIRST_BUILD $LAST_BUILD) ) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      # Start N new builds | 
					 | 
					 | 
					 | 
					    # Start N new builds | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      for i in ${TEST_BUILDS[@]}; | 
					 | 
					 | 
					 | 
					    for i in ${TEST_BUILDS[@]}; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      do | 
					 | 
					 | 
					 | 
					    do | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        echo "Starting build $i" | 
					 | 
					 | 
					 | 
					      echo "Starting build $i" | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        curl -s --output /dev/null --cookie $COOKIE_JAR -H "$CRUMB" -X POST $API_ROUTE/build?delay=0sec | 
					 | 
					 | 
					 | 
					      curl -s --output /dev/null --cookie $COOKIE_JAR -H "$CRUMB" -X POST $API_ROUTE/build?delay=0sec | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        sleep 5 | 
					 | 
					 | 
					 | 
					      sleep 5 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      done | 
					 | 
					 | 
					 | 
					    done | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      echo "" | 
					 | 
					 | 
					 | 
					    echo "" | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    fi | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # Wait for all builds to end | 
					 | 
					 | 
					 | 
					    # Wait for all builds to end | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    while true; do | 
					 | 
					 | 
					 | 
					    while true; do | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |