Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ecce04c

Browse files
committedMar 4, 2025··
first version of github job
1 parent 00afa45 commit ecce04c

File tree

3 files changed

+287
-0
lines changed

3 files changed

+287
-0
lines changed
 

‎.github/workflows/main.yml

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Systems test workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
# the pre-compiled image to use of quickstart, or the git ref to build
7+
# from source.
8+
# TODO: allow other versions
9+
# SYSTEM_TEST_QUICKSTART_IMAGE:
10+
# required: true
11+
# type: string
12+
# TODO allow building from source
13+
# SYSTEM_TEST_QUICKSTART_GIT_REF: "https://github.com/stellar/quickstart.git#master"
14+
15+
# the version of components built in quickstart. only used if quickstart
16+
# is configured above to build from source.
17+
# SYSTEM_TEST_PROTOCOL_VERSION_DEFAULT: 21
18+
# SYSTEM_TEST_RS_XDR_GIT_REF: v21.0.1
19+
# SYSTEM_TEST_CORE_IMAGE:
20+
# SYSTEM_TEST_CORE_GIT_REF: https://github.com/stellar/stellar-core.git#v21.0.0rc1
21+
# SYSTEM_TEST_CORE_COMPILE_CONFIGURE_FLAGS: "--disable-tests"
22+
# SYSTEM_TEST_SOROBAN_RPC_REF: https://github.com/stellar/soroban-rpc.git#v21.0.1
23+
24+
# the soroban CLI & RPC source code to compile and run from system test
25+
# refers to checked out source of current git hub ref context
26+
SOROBAN_CLI_REF:
27+
type: string
28+
SOROBAN_CLI_BRANCH:
29+
type: string
30+
default: main
31+
32+
# TODO: do we still want it?
33+
# sets the version of rust toolchain that will be pre-installed in the
34+
# test runtime environment, tests invoke rustc/cargo
35+
# SYSTEM_TEST_RUST_TOOLCHAIN_VERSION:
36+
# required: true
37+
# type: string
38+
# default: stable
39+
40+
41+
# set the version of js-stellar-sdk to use, need to choose one of either
42+
# resolution options, using npm release or a gh ref:
43+
# option #1, set the version of stellar-sdk based on a npm release version
44+
JS_STELLAR_SDK_NPM_VERSION:
45+
required: true
46+
type: string
47+
default: 12.2.0
48+
49+
# TODO allow other options
50+
# option #2, set the version of stellar-sdk used as a ref to a gh repo if
51+
# a value is set on SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO, it takes
52+
# precedence over any SYSTEM_TEST_JS_STELLAR_SDK_NPM_VERSION
53+
# SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO:
54+
# SYSTEM_TEST_JS_STELLAR_SDK_GH_REF:
55+
56+
# triggers system test to log out details from quickstart's logs and test steps
57+
VERBOSE_OUTPUT:
58+
required: true
59+
type: boolean
60+
default: true
61+
62+
# the soroban test cases will compile various contracts from the examples repo
63+
SOROBAN_EXAMPLES_GIT_HASH:
64+
required: true
65+
type: string
66+
67+
jobs:
68+
systems-test:
69+
# TODO: allow other runners
70+
runs-on: ubuntu-latest
71+
# TODO: allow other versions
72+
services:
73+
rpc:
74+
image: stellar/quickstart:testing
75+
ports:
76+
- 8000:8000
77+
env:
78+
ENABLE_LOGS: true
79+
NETWORK: local
80+
ENABLE_SOROBAN_RPC: true
81+
options: >-
82+
--health-cmd "curl --no-progress-meter --fail-with-body -X POST \"http://localhost:8000/rpc\" -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"id\":8675309,\"method\":\"getNetwork\"}' && curl --no-progress-meter \"http://localhost:8000/friendbot\" | grep '\"invalid_field\": \"addr\"'"
83+
--health-interval 10s
84+
--health-timeout 5s
85+
--health-retries 50
86+
steps:
87+
- uses: actions/checkout@v4
88+
- uses: stellar/actions/rust-cache@main
89+
- run: rustup update
90+
- run: cargo install --git https://github.com/stellar/stellar-cli --rev ${{ inputs.SOROBAN_CLI_REF }}
91+
if: ${{ inputs.SOROBAN_CLI_REF != '' }}
92+
- run: cargo install --git https://github.com/stellar/stellar-cli --branch ${{ inputs.SOROBAN_CLI_BRANCH }}
93+
if: ${{ inputs.SOROBAN_CLI_REF == '' }}
94+
- run: sudo apt update && sudo apt install -y libudev-dev libdbus-1-dev
95+
- run: go mod download
96+
- run: |
97+
go test -c -o ./bin/dapp_develop_test.bin ./features/dapp_develop/...
98+
cp features/dapp_develop/dapp_develop.feature ./bin
99+
cp features/dapp_develop/soroban_config.exp ./bin
100+
cp invoke.ts ./bin
101+
cp events.ts ./bin
102+
- run: npm install -g ts-node
103+
- run: yarn add "@stellar/stellar-sdk@${{ inputs.JS_STELLAR_SDK_NPM_VERSION }}" --network-concurrency 1
104+
# TODO: get rid of the script
105+
- run: ./start-ci

‎.github/workflows/systems-test.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Systems test
2+
3+
on:
4+
push:
5+
branches: [main, release/**]
6+
pull_request:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref_protected == 'true' && github.sha || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
systems-test:
14+
name: System tests
15+
uses: ./.github/workflows/main.yml

‎start-ci

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#! /usr/bin/env bash
2+
set -e
3+
set -o pipefail
4+
5+
# the versions of software that tests will use
6+
SOROBAN_EXAMPLES_GIT_HASH="main"
7+
SOROBAN_EXAMPLES_REPO_URL="https://github.com/stellar/soroban-examples.git"
8+
DEBUG_MODE=
9+
10+
# the target network under test
11+
# TODO: support other networks
12+
TARGET_NETWORK_PASSPHRASE="Standalone Network ; February 2017"
13+
TARGET_NETWORK_SECRET_KEY="SC5O7VZUXDJ6JBDSZ74DSERXL7W3Y5LTOAMRF7RQRL3TAGAPS7LUVG3L"
14+
TARGET_NETWORK_PUBLIC_KEY="GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"
15+
TARGET_NETWORK_RPC_URL="http://localhost:8000/soroban/rpc"
16+
QUICKSTART_LOG_FILE=/var/log/system-test-quickstart.log
17+
LOCAL_CORE=false
18+
ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=--enable-soroban-diagnostic-events
19+
20+
# example filter for all combos of one scenario outline: ^TestDappDevelop$/^DApp developer compiles, deploys and invokes a contract.*$
21+
# each row in example data for a scenario outline is postfixed with '#01', '#02', example:
22+
# TestDappDevelop/DApp developer compiles, deploys and invokes a contract#01
23+
TEST_FILTER=""
24+
VERBOSE_OUTPUT=false
25+
CANCELLED=false
26+
# the relative path to runtime directory on image that feature files will be found at
27+
# these files are aggregated into this directory by Dockerfile
28+
FEATURE_PATH=.
29+
30+
function print_screen_output() {
31+
echo "$1"
32+
}
33+
34+
print_screen_output "Starting system test ..."
35+
36+
trap printout SIGINT
37+
printout() {
38+
echo "Cancelling and exit."
39+
exit 1
40+
}
41+
42+
function main() {
43+
process_args "$@"
44+
45+
if [ ! -z "$TARGET_NETWORK_RPC_URL" ] && [ ! -z "$TARGET_NETWORK" ]; then
46+
echo "Invalid TargetNetwork config, must set TargetNetwork or TargetNetworkRPCURL, aborting test ..." >&2
47+
exit 1
48+
fi
49+
50+
stellar_rpc_status
51+
52+
print_screen_output " RUST_TOOLCHAIN_VERSION=$(rustc --version 2>/dev/null || echo"n/a" )"
53+
print_screen_output " SOROBAN_CLI_CRATE_VERSION=$(soroban version 2>/dev/null || echo "n/a" )"
54+
print_screen_output " SOROBAN_EXAMPLES_GIT_HASH=$SOROBAN_EXAMPLES_GIT_HASH"
55+
print_screen_output " SOROBAN_EXAMPLES_REPO_URL=$SOROBAN_EXAMPLES_REPO_URL"
56+
print_screen_output " TARGET_NETWORK_PASSPHRASE=$TARGET_NETWORK_PASSPHRASE"
57+
print_screen_output " TARGET_NETWORK_SECRET_KEY=$TARGET_NETWORK_SECRET_KEY"
58+
print_screen_output " TARGET_NETWORK_PUBLIC_KEY=$TARGET_NETWORK_PUBLIC_KEY"
59+
print_screen_output " TARGET_NETWORK_RPC_URL=$TARGET_NETWORK_RPC_URL"
60+
print_screen_output " TEST_FILTER=${TEST_FILTER}"
61+
print_screen_output "Tests can now begin ..."
62+
63+
cd ./bin
64+
65+
export SorobanExamplesGitHash=${SOROBAN_EXAMPLES_GIT_HASH}
66+
export SorobanExamplesRepoURL=${SOROBAN_EXAMPLES_REPO_URL}
67+
export TargetNetworkPassPhrase="${TARGET_NETWORK_PASSPHRASE}"
68+
export TargetNetworkSecretKey=${TARGET_NETWORK_SECRET_KEY}
69+
export TargetNetworkPublicKey=${TARGET_NETWORK_PUBLIC_KEY}
70+
export TargetNetworkRPCURL=${TARGET_NETWORK_RPC_URL}
71+
export VerboseOutput=${VERBOSE_OUTPUT}
72+
export LocalCore=${LOCAL_CORE}
73+
export FeaturePath=${FEATURE_PATH}
74+
75+
for file in ./*;
76+
do
77+
if [ "$CANCELLED" = "true" ]; then
78+
break
79+
fi
80+
81+
if [[ "$file" =~ ^.*\.bin$ ]]; then
82+
# these bin files were compiled from go feature tests in the Dockerfile during image build
83+
print_screen_output "Running test binary ${file} ... "
84+
${file} -test.v ${TEST_FILTER}
85+
fi
86+
done
87+
}
88+
89+
function process_args() {
90+
while [[ -n "$1" ]]; do
91+
ARG="$1"
92+
shift
93+
94+
case "${ARG}" in
95+
--DebugMode)
96+
DEBUG_MODE="$1"
97+
shift
98+
;;
99+
--SorobanExamplesGitHash)
100+
SOROBAN_EXAMPLES_GIT_HASH="$1"
101+
shift
102+
;;
103+
--SorobanExamplesRepoURL)
104+
SOROBAN_EXAMPLES_REPO_URL="$1"
105+
shift
106+
;;
107+
--TestFilter)
108+
TEST_FILTER="-test.run ""$1"""
109+
shift
110+
;;
111+
--VerboseOutput)
112+
VERBOSE_OUTPUT="$1"
113+
shift
114+
;;
115+
--TargetNetwork)
116+
TARGET_NETWORK="$1"
117+
shift
118+
;;
119+
--TargetNetworkPassphrase)
120+
TARGET_NETWORK_PASSPHRASE="$1"
121+
shift
122+
;;
123+
--TargetNetworkTestAccountSecret)
124+
TARGET_NETWORK_SECRET_KEY="$1"
125+
shift
126+
;;
127+
--TargetNetworkTestAccountPublic)
128+
TARGET_NETWORK_PUBLIC_KEY="$1"
129+
shift
130+
;;
131+
--TargetNetworkRPCURL)
132+
TARGET_NETWORK_RPC_URL="$1"
133+
shift
134+
;;
135+
*)
136+
esac
137+
done
138+
}
139+
140+
function stellar_rpc_status () {
141+
print_screen_output "waiting for soroban rpc to report ready state..."
142+
COUNTER=1
143+
while ! $(curl --silent --location --request POST "$TARGET_NETWORK_RPC_URL" \
144+
--header 'Content-Type: application/json' \
145+
--data-raw '{
146+
"jsonrpc": "2.0",
147+
"id": 10235,
148+
"method": "getHealth"
149+
150+
}' | jq --exit-status '.result.status == "healthy"' 2>/dev/null | grep -o true || echo false );
151+
do
152+
if [ $(expr $COUNTER % 12) -eq 0 ]; then
153+
print_screen_output "waited $(expr $COUNTER / 12) minutes for Stellar RPC to report ready state..."
154+
fi
155+
COUNTER=$[$COUNTER +1]
156+
157+
if [ $COUNTER -gt 900 ]; then
158+
echo "Waited longer than 15 minutes for Stellar RPC, cancelling and exit."
159+
exit 1
160+
fi
161+
162+
sleep 5
163+
done
164+
print_screen_output "Stellar RPC reported ready status, the service can be used by tools/cli now ..."
165+
}
166+
167+
main "$@"

0 commit comments

Comments
 (0)
Please sign in to comment.