-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (97 loc) · 3.59 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
name: Rust Playground CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
name: Build and Test All Tutorials
runs-on: ubuntu-latest
services:
# refer to: https://docs.github.com/en/actions/use-cases-and-examples/using-containerized-services/creating-postgresql-service-containers
postgres:
image: postgres
env:
POSTGRES_DB: defaultdb
POSTGRES_PASSWORD: admin
POSTGRES_USER: admin
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: "1.82.0"
override: true
- name: Check PostgreSQL SetUp OK
run: |
echo "Check PostgreSQL SetUp OK"
ps -ef | grep postgres
- name: Build and Test tutorial-1
working-directory: ./tutorial-1
env:
RUSTFLAGS: "-Awarnings" # Suppress warnings
run: |
cargo build --verbose
cargo test --verbose -- --nocapture
- name: Build and Test tutorial-2
working-directory: ./tutorial-2
env:
RUSTFLAGS: "-Awarnings" # Suppress warnings
run: |
cargo build --verbose
cargo test --verbose -- --nocapture
- name: Build and Test tutorial-3
working-directory: ./tutorial-3
env:
RUSTFLAGS: "-Awarnings" # Suppress warnings
run: |
cargo build --verbose
cargo test --verbose -- --nocapture
- name: Build and Test tutorial-5
working-directory: ./tutorial-5
env:
RUSTFLAGS: "-Awarnings" # Suppress warnings
DATABASE_URL: "postgresql://admin:admin@localhost:5432/defaultdb" # Set database URL for tests
GETH_URL: "ws://localhost:8546" # Set local setup Geth Endpoint
run: |
echo "Install dependencies for Geth on local"
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt update
sudo apt install -y geth
echo "Start Geth in the background with necessary flags"
nohup geth --http --http.api "eth,web3,net" --ws --ws.api "eth,web3,net" --syncmode snap --ws.addr 0.0.0.0 --ws.port 8546 > geth.log 2>&1 &
sleep 30 # Wait for Geth to fully start
echo "Run Tests to Interact with Geth"
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:8545
echo "Install sqlx... "
cargo install sqlx-cli --no-default-features --features postgres
echo "Migrate via sqlx ..."
sqlx migrate run --database-url postgres://admin:admin@localhost:5432/defaultdb
echo "cargo sqlx prepare "
cargo sqlx prepare
echo "Begin cargo build in tutorial-5"
cargo build --verbose
echo "Begin cargo test in tutorial-5"
cargo test --verbose -- --nocapture
echo "Shutdown Geth Node"
pkill geth
- name: Build and Test tutorial-6
working-directory: ./tutorial-6
run: |
echo "cargo build"
cargo build --verbose
echo "cargo test"
cargo test --verbose -- --nocapture