Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github workflow v1 #119

Merged
merged 20 commits into from
Mar 12, 2025
15 changes: 15 additions & 0 deletions .github/workflows/systems-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Systems test

on:
push:
branches: [main, release/**]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_protected == 'true' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
systems-test:
name: System tests
uses: ./.github/workflows/test.yml
149 changes: 149 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Systems test workflow

on:
workflow_call:
inputs:
# the soroban CLI source code to compile and run from system test
# refers to checked out source of current GitHub ref context or branch
stellar-cli-ref:
required: false
type: string
stellar-cli-version:
required: false
type: string
default: "22.3.0"

# example filter for all combos of one scenario outline: ^TestDappDevelop$/^DApp developer compiles, deploys and invokes a contract.*$
# each row in example data for a scenario outline is postfixed with '#01', '#02', example:
# TestDappDevelop/DApp developer compiles, deploys and invokes a contract#01
test-filter:
required: false
type: string
default: ""

# set the version of js-stellar-sdk to use, need to choose one of either
# resolution options, using npm release or a gh ref:
# option #1, set the version of stellar-sdk based on a npm release version
js-stellar-sdk-npm-version:
required: false
type: string
default: 12.2.0

# triggers system test to log out details from test steps
verbose-output:
required: false
type: boolean
default: true

############################################################################################################
################## Configurations above are supported by original start.sh but ##################
################## is not yet supported here (not used by stellar-cli e2e tests) ##################
############################################################################################################

# the pre-compiled image to use of quickstart, or the git ref to build
# from source.
# TODO: allow other versions
# SYSTEM_TEST_QUICKSTART_IMAGE:
# required: true
# type: string
# TODO allow building from source
# SYSTEM_TEST_QUICKSTART_GIT_REF: "https://github.com/stellar/quickstart.git#master"


# the version of components built in quickstart. only used if quickstart
# is configured above to build from source.
# SYSTEM_TEST_PROTOCOL_VERSION_DEFAULT: 21
# SYSTEM_TEST_RS_XDR_GIT_REF: v21.0.1
# SYSTEM_TEST_CORE_IMAGE:
# SYSTEM_TEST_CORE_GIT_REF: https://github.com/stellar/stellar-core.git#v21.0.0rc1
# SYSTEM_TEST_CORE_COMPILE_CONFIGURE_FLAGS: "--disable-tests"
# SYSTEM_TEST_SOROBAN_RPC_REF: https://github.com/stellar/soroban-rpc.git#v21.0.1

# TODO
# the soroban test cases will compile various contracts from the examples repo
# SOROBAN_EXAMPLES_GIT_HASH:
#type: string

# TODO: do we still want it?
# sets the version of rust toolchain that will be pre-installed in the
# test runtime environment, tests invoke rustc/cargo
# SYSTEM_TEST_RUST_TOOLCHAIN_VERSION:
# required: true
# type: string
# default: stable

# TODO allow other options
# option #2, set the version of stellar-sdk used as a ref to a gh repo if
# a value is set on SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO, it takes
# precedence over any SYSTEM_TEST_js-stellar-sdk-npm-version
# SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO:
# SYSTEM_TEST_JS_STELLAR_SDK_GH_REF:

env:
SorobanExamplesGitHash: "main"
SorobanExamplesRepoURL: "https://github.com/stellar/soroban-examples.git"
# the target network under test
TargetNetworkPassPhrase: "Standalone Network ; February 2017"
TargetNetworkSecretKey: "SC5O7VZUXDJ6JBDSZ74DSERXL7W3Y5LTOAMRF7RQRL3TAGAPS7LUVG3L"
TargetNetworkPublicKey: "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"
TargetNetworkRPCURL: "http://localhost:8000/soroban/rpc"
# the relative path to runtime directory on image that feature files will be found at (constant)
FeaturePath: .
LocalCore: false

jobs:
systems-test:
# TODO: allow other runners
runs-on: ubuntu-latest
# TODO: allow other versions
services:
rpc:
image: stellar/quickstart:testing
ports:
- 8000:8000
env:
ENABLE_LOGS: true
NETWORK: local
ENABLE_SOROBAN_RPC: true
options: >-
--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\"'"
--health-interval 10s
--health-timeout 5s
--health-retries 50
steps:
- uses: actions/checkout@v4
with:
repository: "stellar/system-test"
- uses: stellar/actions/rust-cache@main
- run: sudo apt update && sudo apt install -y expect libudev-dev libdbus-1-dev
- run: rustup update
- run: rustup show active-toolchain || rustup toolchain install
- run: rustup toolchain install 1.81-x86_64-unknown-linux-gnu
- run: rustup target add wasm32-unknown-unknown
- run: rustup target add wasm32-unknown-unknown --toolchain 1.81-x86_64-unknown-linux-gnu
- run: cargo install --git https://github.com/stellar/stellar-cli soroban-cli --rev ${{ inputs.stellar-cli-ref }}
if: ${{ inputs.stellar-cli-ref != '' }}
- run: cargo install stellar-cli@${{ inputs.stellar-cli-version }}
if: ${{ inputs.stellar-cli-ref == '' }}
- run: go mod download
- run: |
go test -c -o ./bin/dapp_develop_test.bin ./features/dapp_develop/...
cp features/dapp_develop/dapp_develop.feature ./bin
cp features/dapp_develop/soroban_config.exp ./bin
cp invoke.ts ./bin
cp events.ts ./bin
- run: npm install -g ts-node
- run: yarn add "@stellar/stellar-sdk@${{ inputs.js-stellar-sdk-npm-version }}" --network-concurrency 1
- run: |
for file in ./*;
do
if [[ "$file" =~ ^.*\.bin$ ]]; then
# these bin files were compiled from go feature tests in the Dockerfile during image build
echo "Running test binary ${file} ... "
${file} -test.v ${{ inputs.test-filter }}
fi
done
name: "System test"
working-directory: "./bin"
env:
VerboseOutput: ${{ inputs.verbose-output}}
18 changes: 9 additions & 9 deletions features/dapp_develop/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ func invokeContractFromCliTool(deployedContractId, contractName, functionName, f
args = append(args, functionParams)
}

envCmd := cmd.NewCmd("soroban", args...)
envCmd := cmd.NewCmd("stellar", args...)

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

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

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

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

envCmd := cmd.NewCmd("soroban", args...)
envCmd := cmd.NewCmd("stellar", args...)

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

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

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

return stdOut, nil
Expand All @@ -90,13 +90,13 @@ func getEventsFromCliTool(ledgerFrom uint32, deployedContractId string, size uin
"--output", "json",
}

envCmd := cmd.NewCmd("soroban", args...)
envCmd := cmd.NewCmd("stellar", args...)

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

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

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

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

return jsonEvents, nil
Expand Down
26 changes: 13 additions & 13 deletions features/dapp_develop/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func deployContract(compiledContractFileName string, contractWorkingDirectory st
var envCmd *cmd.Cmd

if installedContractId != "" {
envCmd = cmd.NewCmd("soroban",
envCmd = cmd.NewCmd("stellar",
"contract",
"deploy",
"--quiet",
Expand All @@ -52,7 +52,7 @@ func deployContract(compiledContractFileName string, contractWorkingDirectory st
"--source", e2eConfig.TargetNetworkSecretKey,
"--network-passphrase", e2eConfig.TargetNetworkPassPhrase)
} else {
envCmd = cmd.NewCmd("soroban",
envCmd = cmd.NewCmd("stellar",
"contract",
"deploy",
"--quiet",
Expand All @@ -65,18 +65,18 @@ func deployContract(compiledContractFileName string, contractWorkingDirectory st
status, stdOut, err := e2e.RunCommand(envCmd, e2eConfig)

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

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

return stdOut[0], nil
}

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

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

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

return stdOut[0], nil
}

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

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

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

return stdOut[0], nil
}

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

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

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

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

return nil
Expand Down
2 changes: 1 addition & 1 deletion features/dapp_develop/soroban_config.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set KEY_NAME [lindex $argv 0]
set KEY [lindex $argv 1]
set timeout -1
spawn soroban keys add --secret-key $KEY_NAME
spawn stellar keys add --secret-key $KEY_NAME
expect "Type a secret key"
send -- "$KEY\r"
expect eof
Loading