-
Notifications
You must be signed in to change notification settings - Fork 2.2k
187 lines (160 loc) · 6.09 KB
/
relayer-tests.yaml
File metadata and controls
187 lines (160 loc) · 6.09 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: relayer-test
# NOTE: could be parametrized with which package to test when we have a specific transaction manager different from the relayer itself.
on:
pull_request:
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
check-changes:
name: relayer-test/check-changes
permissions:
actions: 'read' # Required to read workflow run information
contents: 'read' # Required to checkout repository code
pull-requests: 'read' # Required to read pull request information
runs-on: ubuntu-latest
outputs:
changes-rust-files: ${{ steps.filter.outputs.rust-files }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: 'false'
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
rust-files:
- .github/workflows/relayer-tests.yaml
- relayer/**
unit-test:
name: relayer-test/unit-test (bpr)
needs: check-changes
if: ${{ needs.check-changes.outputs.changes-rust-files == 'true' }}
permissions:
contents: 'read' # Required to checkout repository code
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
token: ${{ secrets.BLOCKCHAIN_ACTIONS_TOKEN }}
submodules: recursive
- name: Setup Rust toolchain file
run: cp relayer/rust-toolchain.toml .
- name: Rust setup
uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1
- name: Cache Rust dependencies and build artifacts
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
workspaces: relayer
key: rust-build-relayer
cache-targets: true
cache-all-crates: true
- name: Format
working-directory: relayer
run: cargo fmt --all -- --check
- name: Build for tests (no rpc mock)
working-directory: relayer
run: cargo test --no-run --lib
- name: Unit tests
working-directory: relayer
run: RUST_BACKTRACE=full make test-unit
clippy:
name: relayer-test/clippy (bpr)
needs: check-changes
if: ${{ needs.check-changes.outputs.changes-rust-files == 'true' }}
permissions:
contents: 'read' # Required to checkout repository code
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
token: ${{ secrets.BLOCKCHAIN_ACTIONS_TOKEN }}
submodules: recursive
- name: Setup Rust toolchain file
run: cp relayer/rust-toolchain.toml .
- name: Setup Rust
uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
workspaces: relayer
key: rust-build-relayer
- name: Clippy
working-directory: relayer
run: cargo clippy -- -D warnings
integration-test:
name: relayer-test/integration-test (bpr)
needs: check-changes
if: ${{ needs.check-changes.outputs.changes-rust-files == 'true' }}
permissions:
contents: 'read' # Required to checkout repository code
runs-on: ubuntu-latest
services:
postgres:
image: cgr.dev/zama.ai/postgres:17.9@sha256:d42847b7c5f9ece73655164588b2387dcd5fadd618ea64761c19d3484498cef0
credentials:
username: ${{ secrets.CGR_USERNAME }}
password: ${{ secrets.CGR_PASSWORD }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: relayer_db
ports:
- 5432
options: >-
--health-cmd "pg_isready -U postgres -d relayer_db"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
SQLX_OFFLINE: true # Use cached queries for compilation (speeds up CI)
APP_GLOBAL__MOCK_TEST: true
DB_USER: postgres
DB_PASSWORD: postgres
DB_NAME: relayer_db
steps:
- name: Checkout Project
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
token: ${{ secrets.BLOCKCHAIN_ACTIONS_TOKEN }}
submodules: recursive
- name: Set database URLs
env:
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
run: |
{
echo "DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}"
echo "APP_STORAGE__SQL_DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}"
echo "TEST_DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}"
} >> "$GITHUB_ENV"
- name: Setup Rust toolchain file
run: cp relayer/rust-toolchain.toml .
- name: Setup Rust
uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1
- name: Cache Rust dependencies and build artifacts
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
workspaces: relayer
key: rust-build-relayer
cache-targets: true
cache-all-crates: true
- name: Install SQLx CLI
run: |
if ! command -v sqlx &> /dev/null; then
echo "Installing sqlx-cli..."
cargo install sqlx-cli --no-default-features --features postgres
else
echo "sqlx-cli found in cache."
fi
- name: Migrate Database
working-directory: relayer/relayer-migrate
run: sqlx migrate run
- name: Run tests
working-directory: relayer
run: RUST_BACKTRACE=full make test-run