Skip to content

Commit a5707b0

Browse files
authored
github workflow v1 (#119)
* first version of github job * fix cargo install * fix order * rustup toolchain * Install missing toolchains * Switch verbose output * Add wasm for 1.81 * install expect * delete start-ci script * Add missing env vars * refactoring * Small fixes * Update stellar-cli ref * Update ref * fix * update command * update commands * Install openssl * fix
1 parent 955a592 commit a5707b0

File tree

5 files changed

+187
-23
lines changed

5 files changed

+187
-23
lines changed

.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/test.yml

.github/workflows/test.yml

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Systems test workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
# the soroban CLI source code to compile and run from system test
7+
# refers to checked out source of current GitHub ref context or branch
8+
stellar-cli-ref:
9+
required: false
10+
type: string
11+
stellar-cli-version:
12+
required: false
13+
type: string
14+
default: "22.3.0"
15+
16+
# example filter for all combos of one scenario outline: ^TestDappDevelop$/^DApp developer compiles, deploys and invokes a contract.*$
17+
# each row in example data for a scenario outline is postfixed with '#01', '#02', example:
18+
# TestDappDevelop/DApp developer compiles, deploys and invokes a contract#01
19+
test-filter:
20+
required: false
21+
type: string
22+
default: ""
23+
24+
# set the version of js-stellar-sdk to use, need to choose one of either
25+
# resolution options, using npm release or a gh ref:
26+
# option #1, set the version of stellar-sdk based on a npm release version
27+
js-stellar-sdk-npm-version:
28+
required: false
29+
type: string
30+
default: 12.2.0
31+
32+
# triggers system test to log out details from test steps
33+
verbose-output:
34+
required: false
35+
type: boolean
36+
default: true
37+
38+
############################################################################################################
39+
################## Configurations above are supported by original start.sh but ##################
40+
################## is not yet supported here (not used by stellar-cli e2e tests) ##################
41+
############################################################################################################
42+
43+
# the pre-compiled image to use of quickstart, or the git ref to build
44+
# from source.
45+
# TODO: allow other versions
46+
# SYSTEM_TEST_QUICKSTART_IMAGE:
47+
# required: true
48+
# type: string
49+
# TODO allow building from source
50+
# SYSTEM_TEST_QUICKSTART_GIT_REF: "https://github.com/stellar/quickstart.git#master"
51+
52+
53+
# the version of components built in quickstart. only used if quickstart
54+
# is configured above to build from source.
55+
# SYSTEM_TEST_PROTOCOL_VERSION_DEFAULT: 21
56+
# SYSTEM_TEST_RS_XDR_GIT_REF: v21.0.1
57+
# SYSTEM_TEST_CORE_IMAGE:
58+
# SYSTEM_TEST_CORE_GIT_REF: https://github.com/stellar/stellar-core.git#v21.0.0rc1
59+
# SYSTEM_TEST_CORE_COMPILE_CONFIGURE_FLAGS: "--disable-tests"
60+
# SYSTEM_TEST_SOROBAN_RPC_REF: https://github.com/stellar/soroban-rpc.git#v21.0.1
61+
62+
# TODO
63+
# the soroban test cases will compile various contracts from the examples repo
64+
# SOROBAN_EXAMPLES_GIT_HASH:
65+
#type: string
66+
67+
# TODO: do we still want it?
68+
# sets the version of rust toolchain that will be pre-installed in the
69+
# test runtime environment, tests invoke rustc/cargo
70+
# SYSTEM_TEST_RUST_TOOLCHAIN_VERSION:
71+
# required: true
72+
# type: string
73+
# default: stable
74+
75+
# TODO allow other options
76+
# option #2, set the version of stellar-sdk used as a ref to a gh repo if
77+
# a value is set on SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO, it takes
78+
# precedence over any SYSTEM_TEST_js-stellar-sdk-npm-version
79+
# SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO:
80+
# SYSTEM_TEST_JS_STELLAR_SDK_GH_REF:
81+
82+
env:
83+
SorobanExamplesGitHash: "main"
84+
SorobanExamplesRepoURL: "https://github.com/stellar/soroban-examples.git"
85+
# the target network under test
86+
TargetNetworkPassPhrase: "Standalone Network ; February 2017"
87+
TargetNetworkSecretKey: "SC5O7VZUXDJ6JBDSZ74DSERXL7W3Y5LTOAMRF7RQRL3TAGAPS7LUVG3L"
88+
TargetNetworkPublicKey: "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"
89+
TargetNetworkRPCURL: "http://localhost:8000/soroban/rpc"
90+
# the relative path to runtime directory on image that feature files will be found at (constant)
91+
FeaturePath: .
92+
LocalCore: false
93+
94+
jobs:
95+
systems-test:
96+
# TODO: allow other runners
97+
runs-on: ubuntu-latest
98+
# TODO: allow other versions
99+
services:
100+
rpc:
101+
image: stellar/quickstart:testing
102+
ports:
103+
- 8000:8000
104+
env:
105+
ENABLE_LOGS: true
106+
NETWORK: local
107+
ENABLE_SOROBAN_RPC: true
108+
options: >-
109+
--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\"'"
110+
--health-interval 10s
111+
--health-timeout 5s
112+
--health-retries 50
113+
steps:
114+
- uses: actions/checkout@v4
115+
with:
116+
repository: "stellar/system-test"
117+
- uses: stellar/actions/rust-cache@main
118+
- run: sudo apt update && sudo apt install -y expect libudev-dev libdbus-1-dev
119+
- run: rustup update
120+
- run: rustup show active-toolchain || rustup toolchain install
121+
- run: rustup toolchain install 1.81-x86_64-unknown-linux-gnu
122+
- run: rustup target add wasm32-unknown-unknown
123+
- run: rustup target add wasm32-unknown-unknown --toolchain 1.81-x86_64-unknown-linux-gnu
124+
- run: cargo install --git https://github.com/stellar/stellar-cli soroban-cli --rev ${{ inputs.stellar-cli-ref }}
125+
if: ${{ inputs.stellar-cli-ref != '' }}
126+
- run: cargo install stellar-cli@${{ inputs.stellar-cli-version }}
127+
if: ${{ inputs.stellar-cli-ref == '' }}
128+
- run: go mod download
129+
- run: |
130+
go test -c -o ./bin/dapp_develop_test.bin ./features/dapp_develop/...
131+
cp features/dapp_develop/dapp_develop.feature ./bin
132+
cp features/dapp_develop/soroban_config.exp ./bin
133+
cp invoke.ts ./bin
134+
cp events.ts ./bin
135+
- run: npm install -g ts-node
136+
- run: yarn add "@stellar/stellar-sdk@${{ inputs.js-stellar-sdk-npm-version }}" --network-concurrency 1
137+
- run: |
138+
for file in ./*;
139+
do
140+
if [[ "$file" =~ ^.*\.bin$ ]]; then
141+
# these bin files were compiled from go feature tests in the Dockerfile during image build
142+
echo "Running test binary ${file} ... "
143+
${file} -test.v ${{ inputs.test-filter }}
144+
fi
145+
done
146+
name: "System test"
147+
working-directory: "./bin"
148+
env:
149+
VerboseOutput: ${{ inputs.verbose-output}}

features/dapp_develop/cli.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ func invokeContractFromCliTool(deployedContractId, contractName, functionName, f
3030
args = append(args, functionParams)
3131
}
3232

33-
envCmd := cmd.NewCmd("soroban", args...)
33+
envCmd := cmd.NewCmd("stellar", args...)
3434

3535
status, stdOutLines, err := e2e.RunCommand(envCmd, e2eConfig)
3636
stdOut := strings.TrimSpace(strings.Join(stdOutLines, "\n"))
3737

3838
if status != 0 || err != nil {
39-
return "", fmt.Errorf("soroban cli invoke of example contract %s had error %v, %v, stdout: %v", contractName, status, err, stdOut)
39+
return "", fmt.Errorf("stellar cli invoke of example contract %s had error %v, %v, stdout: %v", contractName, status, err, stdOut)
4040
}
4141

4242
if stdOut == "" {
43-
return "", fmt.Errorf("soroban cli invoke of example contract %s did not emit successful response", contractName)
43+
return "", fmt.Errorf("stellar cli invoke of example contract %s did not emit successful response", contractName)
4444
}
4545

4646
return stdOut, nil
@@ -62,17 +62,17 @@ func invokeContractFromCliToolWithConfig(deployedContractId, contractName, funct
6262
args = append(args, strings.Split(parameters, " ")...)
6363
}
6464

65-
envCmd := cmd.NewCmd("soroban", args...)
65+
envCmd := cmd.NewCmd("stellar", args...)
6666

6767
status, stdOutLines, err := e2e.RunCommand(envCmd, e2eConfig)
6868
stdOut := strings.TrimSpace(strings.Join(stdOutLines, "\n"))
6969

7070
if status != 0 || err != nil {
71-
return "", fmt.Errorf("soroban cli invoke of example contract with config states, %s had error %v, %v, stdout: %v", contractName, status, err, stdOut)
71+
return "", fmt.Errorf("stellar cli invoke of example contract with config states, %s had error %v, %v, stdout: %v", contractName, status, err, stdOut)
7272
}
7373

7474
if stdOut == "" {
75-
return "", fmt.Errorf("soroban cli invoke of example contract with config states, %s did not emit successful response", contractName)
75+
return "", fmt.Errorf("stellar cli invoke of example contract with config states, %s did not emit successful response", contractName)
7676
}
7777

7878
return stdOut, nil
@@ -90,13 +90,13 @@ func getEventsFromCliTool(ledgerFrom uint32, deployedContractId string, size uin
9090
"--output", "json",
9191
}
9292

93-
envCmd := cmd.NewCmd("soroban", args...)
93+
envCmd := cmd.NewCmd("stellar", args...)
9494

9595
status, stdOutLines, err := e2e.RunCommand(envCmd, e2eConfig)
9696
var jsonEvents []map[string]interface{}
9797

9898
if status != 0 || err != nil {
99-
return jsonEvents, fmt.Errorf("soroban cli get events had error %v, %v", status, err)
99+
return jsonEvents, fmt.Errorf("stellar cli get events had error %v, %v", status, err)
100100
}
101101

102102
// put commas between any json event objects if more than one found
@@ -107,7 +107,7 @@ func getEventsFromCliTool(ledgerFrom uint32, deployedContractId string, size uin
107107

108108
err = json.Unmarshal([]byte(stdOutEventsValidJson), &jsonEvents)
109109
if err != nil {
110-
return jsonEvents, fmt.Errorf("soroban cli get events console output %v was not parseable as event json, %e", strings.Join(stdOutLines, "\n"), err)
110+
return jsonEvents, fmt.Errorf("stellar cli get events console output %v was not parseable as event json, %e", strings.Join(stdOutLines, "\n"), err)
111111
}
112112

113113
return jsonEvents, nil

features/dapp_develop/main.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func deployContract(compiledContractFileName string, contractWorkingDirectory st
4343
var envCmd *cmd.Cmd
4444

4545
if installedContractId != "" {
46-
envCmd = cmd.NewCmd("soroban",
46+
envCmd = cmd.NewCmd("stellar",
4747
"contract",
4848
"deploy",
4949
"--quiet",
@@ -52,7 +52,7 @@ func deployContract(compiledContractFileName string, contractWorkingDirectory st
5252
"--source", e2eConfig.TargetNetworkSecretKey,
5353
"--network-passphrase", e2eConfig.TargetNetworkPassPhrase)
5454
} else {
55-
envCmd = cmd.NewCmd("soroban",
55+
envCmd = cmd.NewCmd("stellar",
5656
"contract",
5757
"deploy",
5858
"--quiet",
@@ -65,18 +65,18 @@ func deployContract(compiledContractFileName string, contractWorkingDirectory st
6565
status, stdOut, err := e2e.RunCommand(envCmd, e2eConfig)
6666

6767
if status != 0 || err != nil {
68-
return "", fmt.Errorf("soroban cli deployment of example contract %s had error %v, %v", compiledContractFileName, status, err)
68+
return "", fmt.Errorf("stellar cli deployment of example contract %s had error %v, %v", compiledContractFileName, status, err)
6969
}
7070

7171
if len(stdOut) < 1 {
72-
return "", fmt.Errorf("soroban cli deployment of example contract %s returned no contract id", compiledContractFileName)
72+
return "", fmt.Errorf("stellar cli deployment of example contract %s returned no contract id", compiledContractFileName)
7373
}
7474

7575
return stdOut[0], nil
7676
}
7777

7878
func deployContractUsingConfigParams(compiledContractFileName string, contractWorkingDirectory string, contractExamplesSubPath string, identityName string, networkConfigName string, e2eConfig *e2e.E2EConfig) (string, error) {
79-
envCmd := cmd.NewCmd("soroban",
79+
envCmd := cmd.NewCmd("stellar",
8080
"contract",
8181
"deploy",
8282
"--quiet",
@@ -87,19 +87,19 @@ func deployContractUsingConfigParams(compiledContractFileName string, contractWo
8787
status, stdOut, err := e2e.RunCommand(envCmd, e2eConfig)
8888

8989
if status != 0 || err != nil {
90-
return "", fmt.Errorf("soroban cli deployment of example contract %s had error %v, %v", compiledContractFileName, status, err)
90+
return "", fmt.Errorf("stellar cli deployment of example contract %s had error %v, %v", compiledContractFileName, status, err)
9191
}
9292

9393
if len(stdOut) < 1 {
94-
return "", fmt.Errorf("soroban cli deployment of example contract %s returned no contract id", compiledContractFileName)
94+
return "", fmt.Errorf("stellar cli deployment of example contract %s returned no contract id", compiledContractFileName)
9595
}
9696

9797
return stdOut[0], nil
9898
}
9999

100100
// returns the installed contract id
101101
func installContract(compiledContractFileName string, contractWorkingDirectory string, contractExamplesSubPath string, e2eConfig *e2e.E2EConfig) (string, error) {
102-
envCmd := cmd.NewCmd("soroban",
102+
envCmd := cmd.NewCmd("stellar",
103103
"contract",
104104
"install",
105105
"--quiet",
@@ -111,18 +111,18 @@ func installContract(compiledContractFileName string, contractWorkingDirectory s
111111
status, stdOut, err := e2e.RunCommand(envCmd, e2eConfig)
112112

113113
if status != 0 || err != nil {
114-
return "", fmt.Errorf("soroban cli install of example contract %s had error %v, %v", compiledContractFileName, status, err)
114+
return "", fmt.Errorf("stellar cli install of example contract %s had error %v, %v", compiledContractFileName, status, err)
115115
}
116116

117117
if len(stdOut) < 1 {
118-
return "", fmt.Errorf("soroban cli install of example contract %s returned no contract id", compiledContractFileName)
118+
return "", fmt.Errorf("stellar cli install of example contract %s returned no contract id", compiledContractFileName)
119119
}
120120

121121
return stdOut[0], nil
122122
}
123123

124124
func createNetworkConfig(configName string, rpcUrl string, networkPassphrase string, e2eConfig *e2e.E2EConfig) error {
125-
envCmd := cmd.NewCmd("soroban",
125+
envCmd := cmd.NewCmd("stellar",
126126
"network",
127127
"add",
128128
"--rpc-url", rpcUrl,
@@ -132,7 +132,7 @@ func createNetworkConfig(configName string, rpcUrl string, networkPassphrase str
132132
status, _, err := e2e.RunCommand(envCmd, e2eConfig)
133133

134134
if status != 0 || err != nil {
135-
return fmt.Errorf("soroban cli create network config %s had error %v, %v", configName, status, err)
135+
return fmt.Errorf("stellar cli create network config %s had error %v, %v", configName, status, err)
136136
}
137137

138138
return nil
@@ -148,7 +148,7 @@ func createIdentityConfig(identityName string, secretKey string, e2eConfig *e2e.
148148
status, _, err := e2e.RunCommand(envCmd, e2eConfig)
149149

150150
if status != 0 || err != nil {
151-
return fmt.Errorf("soroban cli create identity config %s had error %v, %v", identityName, status, err)
151+
return fmt.Errorf("stellar cli create identity config %s had error %v, %v", identityName, status, err)
152152
}
153153

154154
return nil

features/dapp_develop/soroban_config.exp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set KEY_NAME [lindex $argv 0]
33
set KEY [lindex $argv 1]
44
set timeout -1
5-
spawn soroban keys add --secret-key $KEY_NAME
5+
spawn stellar keys add --secret-key $KEY_NAME
66
expect "Type a secret key"
77
send -- "$KEY\r"
88
expect eof

0 commit comments

Comments
 (0)