Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .github/workflows/test-with-openzeppelin-contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Test with OpenZeppelin contracts

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

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

permissions: {}
Comment thread
leighmcculloch marked this conversation as resolved.

defaults:
run:
shell: bash

jobs:
build-cli:
runs-on: ubuntu-latest-8-cores
steps:
- uses: actions/checkout@v6
- uses: stellar/actions/rust-cache@main
- run: rustup update
- run: sudo apt update && sudo apt install -y libudev-dev libdbus-1-dev
- run: make install
- uses: actions/upload-artifact@v4
with:
name: stellar-cli
path: ~/.cargo/bin/stellar

collect-crates:
runs-on: ubuntu-latest
outputs:
dirs: ${{ steps.dirs.outputs.dirs }}
steps:
- uses: actions/checkout@v6
with:
repository: OpenZeppelin/stellar-contracts
- id: dirs
run: |
dirs=$(cargo metadata --no-deps --format-version 1 \
| jq -r --arg pwd "$(pwd)" \
'[.workspace_members[] as $id | .packages[] | select(.id == $id) | select(any(.dependencies[]; .name == "soroban-sdk") and any(.targets[]; any(.crate_types[]; . == "cdylib"))) | .manifest_path | sub("^\($pwd)/"; "") | sub("/Cargo.toml$"; "")] | tojson' \
)
echo "dirs=$dirs" | tee -a $GITHUB_OUTPUT

build-crate:
needs: [build-cli, collect-crates]
if: ${{ needs.collect-crates.outputs.dirs != '[]' }}
strategy:
fail-fast: false
matrix:
dir: ${{ fromJSON(needs.collect-crates.outputs.dirs) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
repository: OpenZeppelin/stellar-contracts
- uses: actions/download-artifact@v4
with:
name: stellar-cli
path: stellar-cli
- run: chmod +x stellar-cli/stellar
- run: echo "${{ github.workspace }}/stellar-cli" >> $GITHUB_PATH
- run: rustup update
- run: rustup target add wasm32v1-none
- name: Build ${{ matrix.dir }}
run: stellar contract build --manifest-path ${{ matrix.dir }}/Cargo.toml
- name: Find wasm
id: find-wasm
run: |
wasm=$(find . -name '*.wasm' -path '*/wasm32v1-none/*' | head -1)
echo "wasm=$wasm" | tee -a $GITHUB_OUTPUT
Comment thread
leighmcculloch marked this conversation as resolved.
- name: Verify interface
run: |
output=$(stellar contract info interface --wasm ${{ steps.find-wasm.outputs.wasm }} --output json)
echo "$output"
count=$(echo "$output" | jq 'length')
if [ "$count" -lt 1 ]; then
echo "ERROR: interface is empty"
exit 1
fi
Comment thread
leighmcculloch marked this conversation as resolved.
- name: Verify env-meta
run: |
output=$(stellar contract info env-meta --wasm ${{ steps.find-wasm.outputs.wasm }} --output json)
echo "$output"
if [ "$(echo "$output" | jq 'length')" -lt 1 ]; then
echo "ERROR: env-meta is empty"
exit 1
fi
- name: Verify meta
run: |
output=$(stellar contract info meta --wasm ${{ steps.find-wasm.outputs.wasm }} --output json)
echo "$output"
if [ "$(echo "$output" | jq 'length')" -lt 1 ]; then
echo "ERROR: meta is empty"
exit 1
fi
- name: Verify spec
run: stellar contract spec-verify --wasm ${{ steps.find-wasm.outputs.wasm }}
109 changes: 109 additions & 0 deletions .github/workflows/test-with-soroban-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Test with soroban-examples

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

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

permissions: {}
Comment thread
leighmcculloch marked this conversation as resolved.

defaults:
run:
shell: bash

jobs:
build-cli:
runs-on: ubuntu-latest-8-cores
steps:
- uses: actions/checkout@v6
- uses: stellar/actions/rust-cache@main
- run: rustup update
- run: sudo apt update && sudo apt install -y libudev-dev libdbus-1-dev
- run: make install
- uses: actions/upload-artifact@v4
with:
name: stellar-cli
path: ~/.cargo/bin/stellar

collect-examples:
runs-on: ubuntu-latest
outputs:
dirs: ${{ steps.dirs.outputs.dirs }}
steps:
- uses: actions/checkout@v6
with:
repository: stellar/soroban-examples
ref: main
- id: dirs
run: |
dirs=$(
for dir in $(find . -type f -name 'Makefile' -mindepth 2 | xargs dirname | sed 's|^\./||'); do
if (cargo metadata --manifest-path "$dir/Cargo.toml" --no-deps --format-version 1 \
| jq -r \
'.packages[0] | (any(.dependencies[]; .name == "soroban-sdk") and any(.targets[]; any(.crate_types[]; . == "cdylib")))' \
| grep -q '^true$'); then
echo "$dir"
fi
done | jq -Rnc '[inputs | "\(.)"]'
)
echo "dirs=$dirs" | tee -a $GITHUB_OUTPUT

build-example:
needs: [build-cli, collect-examples]
if: ${{ needs.collect-examples.outputs.dirs != '[]' }}
strategy:
fail-fast: false
matrix:
dir: ${{ fromJSON(needs.collect-examples.outputs.dirs) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
repository: stellar/soroban-examples
ref: main
- uses: actions/download-artifact@v4
with:
name: stellar-cli
path: stellar-cli
- run: chmod +x stellar-cli/stellar
- run: echo "${{ github.workspace }}/stellar-cli" >> $GITHUB_PATH
- run: rustup update
- run: rustup target add wasm32v1-none
- name: Build ${{ matrix.dir }}
run: make -C ${{ matrix.dir }} build
- name: Find wasm
id: find-wasm
run: |
wasm=$(find ${{ matrix.dir }}/target -name '*.wasm' -path '*/wasm32v1-none/*' | head -1)
echo "wasm=$wasm" | tee -a $GITHUB_OUTPUT
- name: Verify interface
run: |
output=$(stellar contract info interface --wasm ${{ steps.find-wasm.outputs.wasm }} --output json)
echo "$output"
count=$(echo "$output" | jq 'length')
if [ "$count" -lt 1 ]; then
echo "ERROR: interface is empty"
exit 1
fi
Comment thread
leighmcculloch marked this conversation as resolved.
- name: Verify env-meta
run: |
output=$(stellar contract info env-meta --wasm ${{ steps.find-wasm.outputs.wasm }} --output json)
echo "$output"
if [ "$(echo "$output" | jq 'length')" -lt 1 ]; then
echo "ERROR: env-meta is empty"
exit 1
fi
- name: Verify meta
run: |
output=$(stellar contract info meta --wasm ${{ steps.find-wasm.outputs.wasm }} --output json)
echo "$output"
if [ "$(echo "$output" | jq 'length')" -lt 1 ]; then
echo "ERROR: meta is empty"
exit 1
fi
- name: Verify spec
run: stellar contract spec-verify --wasm ${{ steps.find-wasm.outputs.wasm }}
Loading