diff --git a/actions/persistent-stores/action.yml b/actions/persistent-stores/action.yml index 8bb5ad3..1e022fd 100644 --- a/actions/persistent-stores/action.yml +++ b/actions/persistent-stores/action.yml @@ -81,9 +81,28 @@ runs: # https://github.com/hashicorp/consul/issues/22822 so we need to run # 1.20.1 until they fix the issue run: | - choco install consul --version=1.20.1 + # The chocolatey package would otherwise register Consul as a Windows + # service which races with the dev agent for port binding. /noservice + # skips that registration so only the dev agent runs. + choco install consul --version=1.20.1 --params="'/noservice'" + Start-Process consul -ArgumentList 'agent', '-dev', '-http-port=${{ inputs.consul_port }}' + # consul members exits non-zero until the agent's HTTP API responds. + # In dev mode the leader is self-elected immediately on startup, so + # this is purely a process-readiness check. + $deadline = (Get-Date).AddSeconds(30) + $ready = $false + while ((Get-Date) -lt $deadline) { + consul members -http-addr="http://127.0.0.1:${{ inputs.consul_port }}" 2>&1 | Out-Null + if ($LASTEXITCODE -eq 0) { $ready = $true; break } + Start-Sleep -Seconds 1 + } + if (-not $ready) { + Write-Error "Consul did not become ready within 30 seconds" + exit 1 + } + - name: "DynamoDB for Windows" shell: powershell if: ${{ inputs.dynamodb == 'true' && runner.os == 'Windows' }}