Debian Codegraph @

.github/workflows/examples.yml

raw symbols SCIP
1 name: Examples
2
3 on:
4 pull_request:
5 push:
6 branches:
7 - main
8 - '*-dev'
9
10 jobs:
11 sqlx-cli:
12 name: Build SQLx CLI
13 runs-on: ubuntu-latest
14 steps:
15 - uses: actions/checkout@v4
16
17 - name: Use latest Rust
18 run: rustup override set stable
19
20 - uses: Swatinem/rust-cache@v2
21 with:
22 key: sqlx-cli
23
24 - run: >
25 cargo build
26 -p sqlx-cli
27 --bin sqlx
28 --release
29 --no-default-features
30 --features mysql,postgres,sqlite
31
32 - uses: actions/upload-artifact@v4
33 with:
34 name: sqlx-cli
35 path: target/release/sqlx
36
37 mysql:
38 name: MySQL Examples
39 runs-on: ubuntu-latest
40 needs: sqlx-cli
41
42 services:
43 mysql:
44 image: mysql:latest
45 env:
46 MYSQL_ROOT_PASSWORD: password
47 ports:
48 - 3306:3306
49
50 steps:
51 - name: Get SQLx-CLI
52 uses: actions/download-artifact@v4
53 with:
54 name: sqlx-cli
55 # $HOME is interpreted differently by the shell
56 path: /home/runner/.local/bin
57
58 - run: |
59 ls -R /home/runner/.local/bin
60 chmod +x /home/runner/.local/bin/sqlx
61 echo /home/runner/.local/bin >> $GITHUB_PATH
62 sleep 10
63
64 - uses: actions/checkout@v4
65
66 - uses: Swatinem/rust-cache@v2
67 with:
68 key: mysql-examples
69
70 - name: Todos (Setup)
71 working-directory: examples/mysql/todos
72 env:
73 DATABASE_URL: mysql://root:password@localhost:3306/todos?ssl-mode=disabled
74 run: sqlx db setup
75
76 - name: Todos (Run)
77 env:
78 DATABASE_URL: mysql://root:password@localhost:3306/todos?ssl-mode=disabled
79 run: cargo run -p sqlx-example-mysql-todos
80
81 postgres:
82 name: PostgreSQL Examples
83 runs-on: ubuntu-latest
84 needs: sqlx-cli
85
86 services:
87 postgres:
88 image: postgres:latest
89 env:
90 POSTGRES_PASSWORD: password
91 ports:
92 - 5432:5432
93
94 steps:
95 - name: Get SQLx-CLI
96 uses: actions/download-artifact@v4
97 with:
98 name: sqlx-cli
99 path: /home/runner/.local/bin
100
101 - run: |
102 ls -R /home/runner/.local/bin
103 chmod +x $HOME/.local/bin/sqlx
104 echo $HOME/.local/bin >> $GITHUB_PATH
105 sleep 10
106
107 - uses: actions/checkout@v4
108
109 - uses: Swatinem/rust-cache@v2
110 with:
111 key: pg-examples
112
113 - name: Axum Social with Tests (Setup)
114 working-directory: examples/postgres/axum-social-with-tests
115 env:
116 DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social
117 run: sqlx db setup
118
119 - name: Axum Social with Tests (Check)
120 env:
121 DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social
122 run: cargo check -p sqlx-example-postgres-axum-social
123
124 - name: Axum Social with Tests (Test)
125 env:
126 DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social
127 run: cargo test -p sqlx-example-postgres-axum-social
128
129 # The Chat example has an interactive TUI which is not trivial to test automatically,
130 # so we only check that it compiles.
131 - name: Chat (Check)
132 run: cargo check -p sqlx-example-postgres-chat
133
134 - name: Files (Setup)
135 working-directory: examples/postgres/files
136 env:
137 DATABASE_URL: postgres://postgres:password@localhost:5432/files
138 run: sqlx db setup
139
140 - name: Files (Run)
141 env:
142 DATABASE_URL: postgres://postgres:password@localhost:5432/files
143 run: cargo run -p sqlx-example-postgres-files
144
145 - name: JSON (Setup)
146 working-directory: examples/postgres/json
147 env:
148 DATABASE_URL: postgres://postgres:password@localhost:5432/json
149 run: sqlx db setup
150
151 - name: JSON (Run)
152 env:
153 DATABASE_URL: postgres://postgres:password@localhost:5432/json
154 run: cargo run -p sqlx-example-postgres-json
155
156 - name: Listen (Setup)
157 working-directory: examples/postgres/listen
158 env:
159 DATABASE_URL: postgres://postgres:password@localhost:5432/listen
160 run: sqlx db create
161
162 - name: Listen (Run)
163 env:
164 DATABASE_URL: postgres://postgres:password@localhost:5432/listen
165 run: cargo run -p sqlx-example-postgres-listen
166
167 - name: Mockable TODOs (Setup)
168 working-directory: examples/postgres/mockable-todos
169 env:
170 DATABASE_URL: postgres://postgres:password@localhost:5432/mockable-todos
171 run: sqlx db setup
172
173 - name: Mockable TODOs (Run)
174 env:
175 DATABASE_URL: postgres://postgres:password@localhost:5432/mockable-todos
176 run: cargo run -p sqlx-example-postgres-mockable-todos
177
178 - name: TODOs (Setup)
179 working-directory: examples/postgres/todos
180 env:
181 DATABASE_URL: postgres://postgres:password@localhost:5432/todos
182 run: sqlx db setup
183
184 - name: TODOs (Run)
185 env:
186 DATABASE_URL: postgres://postgres:password@localhost:5432/todos
187 # TODO: test full CLI
188 run: cargo run -p sqlx-example-postgres-todos
189
190 - name: Transaction (Setup)
191 working-directory: examples/postgres/transaction
192 env:
193 DATABASE_URL: postgres://postgres:password@localhost:5432/txn
194 run: sqlx db setup
195
196 - name: Transaction (Run)
197 env:
198 DATABASE_URL: postgres://postgres:password@localhost:5432/txn
199 run: cargo run -p sqlx-example-postgres-transaction
200
201 sqlite:
202 name: SQLite Examples
203 runs-on: ubuntu-latest
204 needs: sqlx-cli
205
206 steps:
207 - name: Get SQLx-CLI
208 uses: actions/download-artifact@v4
209 with:
210 name: sqlx-cli
211 path: /home/runner/.local/bin
212
213 - run: |
214 ls -R /home/runner/.local/bin
215 chmod +x /home/runner/.local/bin/sqlx
216 echo /home/runner/.local/bin >> $GITHUB_PATH
217
218 - uses: actions/checkout@v4
219
220 - uses: Swatinem/rust-cache@v2
221 with:
222 key: sqlite-examples
223
224 - name: TODOs (Setup)
225 env:
226 DATABASE_URL: sqlite://todos.sqlite
227 run: sqlx db setup --source=examples/sqlite/todos/migrations
228
229 - name: TODOs (Run)
230 env:
231 DATABASE_URL: sqlite://todos.sqlite
232 run: cargo run -p sqlx-example-sqlite-todos