This repository was archived by the owner on Mar 19, 2026. It is now read-only.
#92: use gha caches for docker build layer caching #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Systems test workflow, next gen, uses quickstart pipelines | ||
|
Check failure on line 1 in .github/workflows/test-workflow.yml
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| runner: | ||
| description: "GitHub runner to use" | ||
| required: false | ||
| type: string | ||
| default: "ubuntu-latest" | ||
| system-test-git-ref: | ||
| description: "the git ref (branch, tag, sha) to use for system-test" | ||
| required: false | ||
| type: string | ||
| default: master | ||
| stellar-cli-repo: | ||
| description: "The git repo for stellar-cli" | ||
| required: false | ||
| type: string | ||
| default: "stellar/stellar-cli" | ||
| stellar-cli-ref: | ||
| description: | | ||
| git ref of stellar cli software version to build | ||
| required: false | ||
| type: string | ||
| stellar-cli-crate-version: | ||
| description: | | ||
| version of stellar-cli crate to use, if not using git ref and repo | ||
| required: false | ||
| type: string | ||
| test-filter: | ||
| description: | | ||
| 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 | ||
| required: false | ||
| type: string | ||
| default: "^TestDappDevelop$/^.*$" | ||
| js-stellar-sdk-npm-version: | ||
| description: | | ||
| set the version of js-stellar-sdk to use, need to choose one of either | ||
| resolution options, using this for npm release or a gh ref using js-stellar-sdk-ref: | ||
| required: false | ||
| type: string | ||
| js-stellar-sdk-repo: | ||
| description: | | ||
| set the version of stellar-sdk based on a gh repo, e.g. stellar/js-stellar-sdk | ||
| if set, takes precedence over js-stellar-sdk-npm-version | ||
| required: false | ||
| type: string | ||
| js-stellar-sdk-ref: | ||
| description: "The git ref (branch, tag, sha) to use for js-stellar-sdk if using gh repo option" | ||
| required: false | ||
| type: string | ||
| stellar-xdr-ref: | ||
| description: "git ref of stellar-xdr to use" | ||
| required: true | ||
| type: string | ||
| stellar-core-ref: | ||
| description: "git ref of stellar-core to use" | ||
| required: true | ||
| type: string | ||
| stellar-rpc-repo: | ||
| description: "The git repo to use for stellar-rpc" | ||
| required: false | ||
| type: string | ||
| default: "stellar/stellar-rpc" | ||
| stellar-rpc-ref: | ||
| description: "git ref of stellar-rpc to use" | ||
| required: true | ||
| type: string | ||
| horizon-ref: | ||
| description: "git ref of horizon to use" | ||
| required: true | ||
| type: string | ||
| lab-ref: | ||
| description: "git ref of stellar laboratory to use" | ||
| required: true | ||
| type: string | ||
| protocol-version: | ||
| description: "Protocol version to use" | ||
| required: true | ||
| type: string | ||
| rust-toolchain-version: | ||
| description: "Version of Rust toolchain to use in test runtime environment" | ||
| required: true | ||
| type: string | ||
| verbose-output: | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| soroban-examples-ref: | ||
| description: "The git ref (branch, tag, sha) to use for soroban-examples" | ||
| required: true | ||
| type: string | ||
| soroban-examples-repo: | ||
| description: "The git repo to use for soroban-examples" | ||
| required: false | ||
| type: string | ||
| default: "stellar/soroban-examples" | ||
| env: | ||
| SYSTEM_TEST_IMAGE: stellar/system-test:cache | ||
| jobs: | ||
| prepare-config: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| images-config: ${{ steps.set-config.outputs.images }} | ||
| system-test-image-cached: "${{ env.SYSTEM_TEST_IMAGE}}_${{ steps.set-cache-key.outputs.cache-key }}" | ||
| steps: | ||
| - id: set-cache-key | ||
| run: | | ||
| # Fetch commit SHAs for each dependency repo | ||
| SYSTEM_TEST_SHA=$(git ls-remote https://github.com/stellar/system-test ${{ inputs.system-test-git-ref }} | awk '{print $1}') | ||
| if [ -z "$SYSTEM_TEST_SHA" ]; then | ||
| echo "Error: Could not find ref ${{ inputs.system-test-git-ref }} in stellar/system-test" | ||
| exit 1 | ||
| fi | ||
| CLI_REF="${{ inputs.stellar-cli-ref }}" | ||
| CLI_REPO="${{ inputs.stellar-cli-repo }}" | ||
| # Only fetch if stellar-cli-ref and repo is provided | ||
| if [ -n "$CLI_REF" ] && [ -n "$CLI_REPO" ]; then | ||
| CLI_URL=https://github.com/$CLI_REPO | ||
| STELLAR_CLI_SHA=$(git ls-remote "$CLI_URL" "$CLI_REF" | awk '{print $1}') | ||
| if [ -z "$STELLAR_CLI_SHA" ]; then | ||
| echo "Error: Could not find ref $CLI_REF in $CLI_URL" | ||
| exit 1 | ||
| fi | ||
| else | ||
| # If no CLI ref provided | ||
| STELLAR_CLI_SHA="${{ inputs.stellar-cli-crate-version }}" | ||
| fi | ||
| # Handle JS Stellar SDK | ||
| if [ -n "${{ inputs.js-stellar-sdk-repo }}" ]; then | ||
| JS_SDK_PART=$(git ls-remote https://github.com/${{ inputs.js-stellar-sdk-repo }} ${{ inputs.js-stellar-sdk-ref }} | awk '{print $1}') | ||
| if [ -z "$JS_SDK_PART" ]; then | ||
| echo "Error: Could not find ref ${{ inputs.js-stellar-sdk-ref }} in ${{ inputs.js-stellar-sdk-repo }}" | ||
| exit 1 | ||
| fi | ||
| else | ||
| JS_SDK_PART="${{ inputs.js-stellar-sdk-npm-version }}" | ||
| fi | ||
| # Create cache key by hashing all components | ||
| CACHE_INPUT="${SYSTEM_TEST_SHA}${STELLAR_CLI_SHA}${JS_SDK_PART}" | ||
| CACHE_KEY=$(echo -n "$CACHE_INPUT" | sha256sum | cut -c1-16) | ||
| echo "cache-key=${CACHE_KEY}" >> $GITHUB_OUTPUT | ||
| echo "Generated cache key: ${CACHE_KEY}" | ||
| - id: set-config | ||
| run: | | ||
| cat <<EOF >> $GITHUB_OUTPUT | ||
| images<<DELIMITER | ||
| [ | ||
| { | ||
| "tag": "rpc-custom", | ||
| "config": { | ||
| "protocol_version_default": ${{ inputs.protocol-version }} | ||
| }, | ||
| "deps": [ | ||
| { "name": "xdr", "repo": "stellar/rs-stellar-xdr", "ref": "${{ inputs.stellar-xdr-ref }}" }, | ||
| { "name": "core", "repo": "stellar/stellar-core", "ref": "${{ inputs.stellar-core-ref }}", "options": { "configure_flags": "--disable-tests" } }, | ||
| { "name": "rpc", "repo": "${{ inputs.stellar-rpc-repo }}", "ref": "${{ inputs.stellar-rpc-ref }}" }, | ||
| { "name": "horizon", "repo": "stellar/go", "ref": "${{ inputs.horizon-ref }}" }, | ||
| { "name": "friendbot", "repo": "stellar/go", "ref": "${{ inputs.horizon-ref }}" }, | ||
| { "name": "lab", "repo": "stellar/laboratory", "ref": "${{ inputs.lab-ref }}" } | ||
| ], | ||
| "additional-tests": [] | ||
| } | ||
| ] | ||
| DELIMITER | ||
| EOF | ||
| build-quickstart: | ||
| needs: prepare-config | ||
| uses: stellar/quickstart/.github/workflows/build.yml@main | ||
| with: | ||
| images: ${{ needs.prepare-config.outputs.images-config }} | ||
| archs: '["amd64"]' | ||
| build-system-test: | ||
| runs-on: ubuntu-latest-4-cores | ||
| needs: [prepare-config] | ||
| env: | ||
| SYSTEM_TEST_IMAGE: ${{ needs.prepare-config.outputs.system-test-image-cached }} | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| repository: stellar/system-test | ||
| ref: ${{ inputs.system-test-git-ref }} | ||
| path: system-test | ||
| - if: inputs.js-stellar-sdk-repo != '' | ||
| name: prepare local js-stellar-sdk | ||
| run: | | ||
| rm -rf $GITHUB_WORKSPACE/system-test/js-stellar-sdk; | ||
| - if: inputs.js-stellar-sdk-repo != '' | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: ${{ inputs.js-stellar-sdk-repo }} | ||
| ref: ${{ inputs.js-stellar-sdk-ref }} | ||
| path: system-test/js-stellar-sdk | ||
| - uses: stellar/actions/rust-cache@main | ||
| - name: Build system test with component versions | ||
| run: | | ||
| cd $GITHUB_WORKSPACE/system-test | ||
| if [ -z "${{ inputs.js-stellar-sdk-repo }}" ]; then \ | ||
| JS_STELLAR_SDK_REF="${{ inputs.js-stellar-sdk-npm-version }}"; \ | ||
| else \ | ||
| JS_STELLAR_SDK_REF="file:/home/tester/js-stellar-sdk"; \ | ||
| fi | ||
| if [ -n "${{ inputs.stellar-cli-ref }}" ] && [ -n "${{ inputs.stellar-cli-repo }}" ]; then \ | ||
| STELLAR_CLI_GIT_REF="https://github.com/${{ inputs.stellar-cli-repo }}.git#${{ inputs.stellar-cli-ref }}"; \ | ||
| else \ | ||
| STELLAR_CLI_CRATE_VERSION="${{ inputs.stellar-cli-crate-version }}"; \ | ||
| fi | ||
| make \ | ||
| USE_GHA_CACHE=true \ | ||
| STELLAR_CLI_GIT_REF=$STELLAR_CLI_GIT_REF \ | ||
| STELLAR_CLI_CRATE_VERSION=$STELLAR_CLI_CRATE_VERSION \ | ||
| RUST_TOOLCHAIN_VERSION=${{ inputs.rust-toolchain-version }} \ | ||
| JS_STELLAR_SDK_NPM_VERSION=$JS_STELLAR_SDK_REF \ | ||
| SYSTEM_TEST_IMAGE=$SYSTEM_TEST_IMAGE \ | ||
| build | ||
| - name: extract image to file | ||
| run: | | ||
| docker save $SYSTEM_TEST_IMAGE -o /tmp/image.tar | ||
| - name: save file to cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| key: ${{ env.SYSTEM_TEST_IMAGE }} | ||
| path: /tmp/image.tar | ||
| integration: | ||
| name: System tests | ||
| needs: [build-system-test, build-quickstart, prepare-config] | ||
| # Run if build-system-test succeeded OR was skipped because image is already in built(cache hit) | ||
| if: always() && (needs.build-system-test.result == 'success' || needs.build-system-test.result == 'skipped') | ||
| strategy: | ||
| matrix: | ||
| scenario-filter: ["${{ inputs.test-filter }}"] | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| SYSTEM_TEST_IMAGE: ${{ needs.prepare-config.outputs.system-test-image-cached }} | ||
| steps: | ||
| - name: Start quickstart with rpc | ||
| uses: stellar/quickstart@main | ||
| with: | ||
| artifact: image-quickstart-rpc-custom-amd64.tar | ||
| tag: rpc-custom-amd64 | ||
| enable: core,rpc | ||
| - name: Get system-test image from cache | ||
| id: get-system-test-image | ||
| uses: actions/cache/restore/v4 | ||
| with: | ||
| key: ${{ env.SYSTEM_TEST_IMAGE }} | ||
| path: /tmp/image.tar | ||
| - name: Fail if cache not found | ||
| run: | | ||
| if [ "${{ steps.get-system-test-image.outputs.cache-hit }}" != "true" ]; then | ||
| echo "Required cache key $SYSTEM_TEST_IMAGE not found, failing job." | ||
| exit 1 | ||
| fi | ||
| - name: load system-test image from cache file | ||
| run: | | ||
| docker load -i /tmp/image.tar | ||
| - name: Run system test scenarios | ||
| run: | | ||
| docker run \ | ||
| --add-host=host.docker.internal:host-gateway \ | ||
| --rm -t --name e2e_test $SYSTEM_TEST_IMAGE \ | ||
| --VerboseOutput ${{ inputs.verbose-output }} \ | ||
| --TargetNetworkRPCURL http://host.docker.internal:8000/rpc \ | ||
| --TestFilter "${{ matrix.scenario-filter }}" \ | ||
| --SorobanExamplesGitHash ${{ inputs.soroban-examples-ref }} \ | ||
| --SorobanExamplesRepoURL https://github.com/${{ inputs.soroban-examples-repo }} | ||