-
Notifications
You must be signed in to change notification settings - Fork 5
129 lines (105 loc) · 4.5 KB
/
ci.yml
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
name: CI
on:
push:
pull_request:
workflow_dispatch:
schedule: [cron: "40 1 * * *"]
permissions:
contents: read
env:
RUSTFLAGS: -Dwarnings
SUI_BINARY_VERSION: "1.35.1" # used for downloading a specific Sui binary versions that matches the GraphQL schema for local network tests
jobs:
test:
runs-on: ubuntu-latest
services:
postgres: # we need this postgres instance for running a local network with indexer and graphql
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgrespw
POSTGRES_DB: sui_indexer_v2
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: rust version
run: |
rustc --version
cargo --version
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-nextest
- name: Check if the schema file was modified but not the version needed for the Sui CLI binary
run: |
# we need to keep the version of the Sui binary to be the same as when this schema made it into testnet
# to do so we check if the schema file changed, and if the workflow file changed. If it did not, then
SCHEMA_FILE_CHANGED=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q 'crates/sui-graphql-client/schema/graphql_rpc.graphql' && echo "true" || echo "false")
WORKFLOW_CHANGED=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q '.github/workflows/ci.yml' && echo "true" || echo "false")
if [ "$SCHEMA_FILE_CHANGED" = "true" ] && [ "$WORKFLOW_CHANGED" = "true" ]; then
echo "Both the specific file and the workflow file were changed."
else
echo "If you changed the GraphQL schema, make sure you set the correct Sui SUI_BINARY_VERSION the workflow file. This version should be the one at which this schema was deployed to testnet network."
exit 1 # If you want the job to fail if the conditions aren't met.
fi
- name: feature compatibility
run: make check-features
- name: rustfmt
run: make check-fmt
- name: clippy
run: make clippy
- name: Run tests that do not require local network
run: make test
- name: Get releases JSON file
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-L -o releases.json \
https://api.github.com/repos/MystenLabs/sui/releases
- name: Get the latest Sui testnet binary and start a local network
shell: bash
run: |
os=${{runner.os}}
binary_os=""
if [ $os == "Linux" ]; then
binary_os="ubuntu"
fi
# We need to set the exact binary version that corresponds to the schema used in this repository
# If you update schema, then you need to update this SUI_BINARY_VERSION as well
testnet_url=$(cat releases.json | jq --arg os $binary_os --arg version $SUI_BINARY_VERSION '.[] | .assets[] | select(.name | contains("testnet")) | select(.name | contains($os)) | select(.name | contains("x86")) | select(.name | contains($version))'| jq -csr '.[0] | .browser_download_url')
filename="sui-$binary_os.tar.gz"
echo "Downloading testnet binary from $testnet_url"
wget -q $testnet_url -O $filename
tar -zxvf $filename ./sui
./sui start --force-regenesis --with-faucet --with-indexer --with-graphql --pg-port 5432 --pg-db-name sui_indexer_v2 --epoch-duration-ms 10000 &
- name: Run tests that require local network
run: |
make test-with-localnet
- name: rustdoc
run: make doc
wasm:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: rust version
run: |
rustc --version
cargo --version
- uses: taiki-e/install-action@wasm-pack
- name: Install clang
run: sudo apt-get install -y clang
- name: Run tests in wasm
run: make wasm