-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathtest-with-openzeppelin-contracts.yml
More file actions
130 lines (123 loc) · 4.89 KB
/
Copy pathtest-with-openzeppelin-contracts.yml
File metadata and controls
130 lines (123 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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: {}
defaults:
run:
shell: bash
jobs:
build-cli:
runs-on: ubuntu-latest-8-cores
steps:
- uses: actions/checkout@v7
- 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@v7.0.1
with:
name: stellar-cli
path: ~/.cargo/bin/stellar
collect-crates:
runs-on: ubuntu-latest
outputs:
dirs: ${{ steps.dirs.outputs.dirs }}
steps:
- uses: actions/checkout@v7
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) }}
experimental_spec_shaking_v2: [true, false]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
repository: OpenZeppelin/stellar-contracts
- uses: actions/download-artifact@v8.0.1
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: Enable experimental_spec_shaking_v2 feature
if: matrix.experimental_spec_shaking_v2
run: |
find . -name Cargo.toml | while read -r file; do
# Add feature to entries with existing features
sed -i '/soroban-sdk = {/s|features = \[|features = ["experimental_spec_shaking_v2", |' "$file"
# Add features field to entries without features
sed -i '/soroban-sdk = {/{/features/!s| }|, features = ["experimental_spec_shaking_v2"] }|}' "$file"
done
cargo update -p soroban-sdk
- name: Diff
run: git diff
- name: Build ${{ matrix.dir }}
run: stellar contract build --manifest-path ${{ matrix.dir }}/Cargo.toml
- name: Find wasm
id: find-wasm
run: |
root=$(dirname "$(cargo locate-project --workspace --message-format plain --manifest-path ${{ matrix.dir }}/Cargo.toml)")
wasm=$(find "$root/target" -name '*.wasm' -path '*/wasm32v1-none/release/*' -not -path '*/deps/*' | head -1)
echo "wasm=$wasm" | tee -a $GITHUB_OUTPUT
- name: Set artifact name
id: artifact-name
run: echo "name=wasm-$(echo ${{ matrix.dir }} | sed 's/\//-/g')${{ matrix.experimental_spec_shaking_v2 && '-spec-shaking-v2' || '' }}" | tee -a $GITHUB_OUTPUT
- name: Upload WASM artifacts
uses: actions/upload-artifact@v7.0.1
with:
name: ${{ steps.artifact-name.outputs.name }}
path: ${{ steps.find-wasm.outputs.wasm }}
retention-days: 3
- name: Verify interface
if: ${{ startsWith(matrix.dir, 'examples/') }}
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
- name: Verify env-meta
if: ${{ startsWith(matrix.dir, 'examples/') }}
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
if: ${{ startsWith(matrix.dir, 'examples/') }}
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
if: ${{ startsWith(matrix.dir, 'examples/') }}
run: stellar contract spec-verify --wasm ${{ steps.find-wasm.outputs.wasm }}
- name: Diff
run: git add -N . && git diff HEAD