-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathaction.yml
More file actions
124 lines (118 loc) · 4.04 KB
/
action.yml
File metadata and controls
124 lines (118 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: 'Run quickstart'
description: 'Runs quickstart docker image'
inputs:
tag:
description: "Image tag of quickstart image to use"
required: true
default: "latest"
artifact:
description: "Artifact to collect image from"
default: ""
image:
description: "Image for the quickstart image to use"
default: ""
enable:
description: "Services to enable"
default: "core,horizon,rpc"
network:
description: "Network to run"
default: "local"
protocol_version:
description: "Protocol version to run for 'local' network only (leave blank for default for image)"
default: ""
core_log_level:
description: "Stellar Core log level (FATAL, ERROR, WARNING, INFO, DEBUG, TRACE)"
default: ""
enable_logs:
description: "Boolean flag enabling the logs"
default: "true"
health_interval:
description: "Time between running the check (in seconds)"
default: "10"
health_timeout:
description: "Maximum time to allow one check to run (in seconds)"
default: "5"
health_retries:
description: "Consecutive failures needed to report unhealthy"
default: "50"
runs:
using: "composite"
steps:
- name: Update Homebrew
if: runner.os == 'macos'
shell: bash
run: |
echo "::group::Updating Homebrew"
brew update
echo "::endgroup::"
- name: Install Colima & Docker
if: runner.os == 'macos'
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
echo "::group::Installing Colima & Docker"
brew install colima docker
echo "::endgroup::"
- name: Start Colima
if: runner.os == 'macos'
shell: bash
run: |
echo "::group::Starting Colima"
CPU_COUNT=$(sysctl -n hw.ncpu)
TOTAL_MEMORY=$(sysctl hw.memsize | awk '{print $2/1024/1024/1024}')
MEMORY=$(awk "BEGIN {printf \"%.0f\", $TOTAL_MEMORY * 0.75}")
echo "CPU_COUNT: $CPU_COUNT"
echo "TOTAL_MEMORY: $TOTAL_MEMORY"
echo "MEMORY: $MEMORY"
colima start --arch x86_64 --vm-type=vz --mount-type=9p --cpu $CPU_COUNT --memory $TOTAL_MEMORY
export DOCKER_HOST=unix:///Users/runner/.colima/default/docker.sock
echo "DOCKER_HOST=unix:///Users/runner/.colima/default/docker.sock" >> $GITHUB_ENV
echo "::endgroup::"
- if: inputs.artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact }}
path: /tmp/
- if: inputs.artifact
run: docker load -i /tmp/image
shell: bash
- run: >
docker run -d --name stellar
-p 8000:8000
-p 11626:11626
-p 11726:11726
-p 11826:11826
-e ENABLE_LOGS="${{ inputs.enable_logs }}"
-e ENABLE="${{ inputs.enable }}"
-e NETWORK="${{ inputs.network }}"
-e PROTOCOL_VERSION="${{ inputs.protocol_version }}"
-e CORE_LOG_LEVEL="${{ inputs.core_log_level }}"
--health-cmd "curl --no-progress-meter -X POST -H 'Content-Type: application/json' -d
'{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"getHealth\"}' 'http://localhost:8000/rpc'
| grep 'healthy'
&& curl --no-progress-meter \"http://localhost:8000/friendbot\" |
grep '\"invalid_field\": \"addr\"'"
--health-interval ${{ inputs.health_interval }}s
--health-timeout ${{ inputs.health_timeout }}s
--health-retries ${{ inputs.health_retries }}
${{ inputs.image || (inputs.artifact && 'quickstart' || 'docker.io/stellar/quickstart') }}:${{ inputs.tag }}
shell: bash
- name: "Wait for container to be healthy"
run: |
i=0
while true; do
status=`docker inspect -f {{.State.Health.Status}} stellar`
echo "stellar image status: $status"
if [ "$status" == "healthy" ]; then
break
fi
sleep 1;
i=$((i + 1))
if (( $i > 300 )); then
echo "stellar image is slow to start, printing logs:"
i=$((i - 300))
docker logs stellar
fi
done;
shell: bash