|
| 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@v2 |
| 16 | + |
| 17 | + - uses: actions-rs/toolchain@v1 |
| 18 | + with: |
| 19 | + profile: minimal |
| 20 | + toolchain: stable |
| 21 | + override: true |
| 22 | + |
| 23 | + - uses: Swatinem/rust-cache@v1 |
| 24 | + with: |
| 25 | + key: sqlx-cli |
| 26 | + |
| 27 | + - uses: actions-rs/cargo@v1 |
| 28 | + with: |
| 29 | + command: build |
| 30 | + args: > |
| 31 | + -p sqlx-cli |
| 32 | + --bin sqlx |
| 33 | + --release |
| 34 | + --no-default-features |
| 35 | + --features mysql,postgres,sqlite |
| 36 | +
|
| 37 | + - uses: actions/upload-artifact@v3 |
| 38 | + with: |
| 39 | + name: sqlx-cli |
| 40 | + path: target/release/sqlx |
| 41 | + |
| 42 | + mysql: |
| 43 | + name: MySQL Examples |
| 44 | + runs-on: ubuntu-latest |
| 45 | + needs: sqlx-cli |
| 46 | + |
| 47 | + services: |
| 48 | + mysql: |
| 49 | + image: mysql:latest |
| 50 | + env: |
| 51 | + MYSQL_ROOT_PASSWORD: password |
| 52 | + ports: |
| 53 | + - 3306:3306 |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Get SQLx-CLI |
| 57 | + uses: actions/download-artifact@v3 |
| 58 | + with: |
| 59 | + name: sqlx-cli |
| 60 | + # $HOME is interpreted differently by the shell |
| 61 | + path: /home/runner/.local/bin |
| 62 | + |
| 63 | + - run: | |
| 64 | + ls -R /home/runner/.local/bin |
| 65 | + chmod +x /home/runner/.local/bin/sqlx |
| 66 | + echo /home/runner/.local/bin >> $GITHUB_PATH |
| 67 | + sleep 10 |
| 68 | +
|
| 69 | + - uses: actions/checkout@v2 |
| 70 | + |
| 71 | + - uses: actions-rs/toolchain@v1 |
| 72 | + with: |
| 73 | + profile: minimal |
| 74 | + toolchain: stable |
| 75 | + override: true |
| 76 | + |
| 77 | + - uses: Swatinem/rust-cache@v1 |
| 78 | + with: |
| 79 | + key: mysql-examples |
| 80 | + |
| 81 | + - name: Todos (Setup) |
| 82 | + working-directory: examples/mysql/todos |
| 83 | + env: |
| 84 | + DATABASE_URL: mysql://root:password@localhost:3306/todos?ssl-mode=disabled |
| 85 | + run: sqlx db setup |
| 86 | + |
| 87 | + - name: Todos (Run) |
| 88 | + uses: actions-rs/cargo@v1 |
| 89 | + env: |
| 90 | + DATABASE_URL: mysql://root:password@localhost:3306/todos?ssl-mode=disabled |
| 91 | + with: |
| 92 | + # TODO: test full CLI |
| 93 | + command: run |
| 94 | + args: -p sqlx-example-mysql-todos |
| 95 | + |
| 96 | + postgres: |
| 97 | + name: PostgreSQL Examples |
| 98 | + runs-on: ubuntu-latest |
| 99 | + needs: sqlx-cli |
| 100 | + |
| 101 | + services: |
| 102 | + postgres: |
| 103 | + image: postgres:latest |
| 104 | + env: |
| 105 | + POSTGRES_PASSWORD: password |
| 106 | + ports: |
| 107 | + - 5432:5432 |
| 108 | + |
| 109 | + steps: |
| 110 | + - name: Get SQLx-CLI |
| 111 | + uses: actions/download-artifact@v3 |
| 112 | + with: |
| 113 | + name: sqlx-cli |
| 114 | + path: /home/runner/.local/bin |
| 115 | + |
| 116 | + - run: | |
| 117 | + ls -R /home/runner/.local/bin |
| 118 | + chmod +x $HOME/.local/bin/sqlx |
| 119 | + echo $HOME/.local/bin >> $GITHUB_PATH |
| 120 | + sleep 10 |
| 121 | +
|
| 122 | + - uses: actions/checkout@v2 |
| 123 | + |
| 124 | + - uses: actions-rs/toolchain@v1 |
| 125 | + with: |
| 126 | + profile: minimal |
| 127 | + toolchain: stable |
| 128 | + override: true |
| 129 | + |
| 130 | + - uses: Swatinem/rust-cache@v1 |
| 131 | + with: |
| 132 | + key: pg-examples |
| 133 | + |
| 134 | + - name: Axum Social with Tests (Setup) |
| 135 | + working-directory: examples/postgres/axum-social-with-tests |
| 136 | + env: |
| 137 | + DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social |
| 138 | + run: sqlx db setup |
| 139 | + |
| 140 | + - name: Axum Social with Tests (Check) |
| 141 | + uses: actions-rs/cargo@v1 |
| 142 | + env: |
| 143 | + DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social |
| 144 | + with: |
| 145 | + command: check |
| 146 | + args: -p sqlx-example-postgres-axum-social |
| 147 | + |
| 148 | + - name: Axum Social with Tests (Test) |
| 149 | + uses: actions-rs/cargo@v1 |
| 150 | + env: |
| 151 | + DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social |
| 152 | + with: |
| 153 | + command: test |
| 154 | + args: -p sqlx-example-postgres-axum-social |
| 155 | + |
| 156 | + - name: Files (Setup) |
| 157 | + working-directory: examples/postgres/files |
| 158 | + env: |
| 159 | + DATABASE_URL: postgres://postgres:password@localhost:5432/files |
| 160 | + run: sqlx db setup |
| 161 | + |
| 162 | + - name: Files (Run) |
| 163 | + uses: actions-rs/cargo@v1 |
| 164 | + env: |
| 165 | + DATABASE_URL: postgres://postgres:password@localhost:5432/files |
| 166 | + with: |
| 167 | + command: run |
| 168 | + args: -p sqlx-example-postgres-files |
| 169 | + |
| 170 | + - name: JSON (Setup) |
| 171 | + working-directory: examples/postgres/json |
| 172 | + env: |
| 173 | + DATABASE_URL: postgres://postgres:password@localhost:5432/json |
| 174 | + run: sqlx db setup |
| 175 | + |
| 176 | + - name: JSON (Run) |
| 177 | + uses: actions-rs/cargo@v1 |
| 178 | + env: |
| 179 | + DATABASE_URL: postgres://postgres:password@localhost:5432/json |
| 180 | + with: |
| 181 | + command: run |
| 182 | + args: -p sqlx-example-postgres-json |
| 183 | + |
| 184 | + - name: Listen (Setup) |
| 185 | + working-directory: examples/postgres/listen |
| 186 | + env: |
| 187 | + DATABASE_URL: postgres://postgres:password@localhost:5432/listen |
| 188 | + run: sqlx db create |
| 189 | + |
| 190 | + - name: Listen (Run) |
| 191 | + uses: actions-rs/cargo@v1 |
| 192 | + env: |
| 193 | + DATABASE_URL: postgres://postgres:password@localhost:5432/listen |
| 194 | + with: |
| 195 | + command: run |
| 196 | + args: -p sqlx-example-postgres-listen |
| 197 | + |
| 198 | + - name: Mockable TODOs (Setup) |
| 199 | + working-directory: examples/postgres/mockable-todos |
| 200 | + env: |
| 201 | + DATABASE_URL: postgres://postgres:password@localhost:5432/mockable-todos |
| 202 | + run: sqlx db setup |
| 203 | + |
| 204 | + - name: Mockable TODOs (Run) |
| 205 | + uses: actions-rs/cargo@v1 |
| 206 | + env: |
| 207 | + DATABASE_URL: postgres://postgres:password@localhost:5432/mockable-todos |
| 208 | + with: |
| 209 | + # TODO: test full CLI |
| 210 | + command: run |
| 211 | + args: -p sqlx-example-postgres-mockable-todos |
| 212 | + |
| 213 | + - name: TODOs (Setup) |
| 214 | + working-directory: examples/postgres/todos |
| 215 | + env: |
| 216 | + DATABASE_URL: postgres://postgres:password@localhost:5432/todos |
| 217 | + run: sqlx db setup |
| 218 | + |
| 219 | + - name: TODOs (Run) |
| 220 | + uses: actions-rs/cargo@v1 |
| 221 | + env: |
| 222 | + DATABASE_URL: postgres://postgres:password@localhost:5432/todos |
| 223 | + with: |
| 224 | + # TODO: test full CLI |
| 225 | + command: run |
| 226 | + args: -p sqlx-example-postgres-todos |
| 227 | + |
| 228 | + - name: Transaction (Setup) |
| 229 | + working-directory: examples/postgres/transaction |
| 230 | + env: |
| 231 | + DATABASE_URL: postgres://postgres:password@localhost:5432/txn |
| 232 | + run: sqlx db setup |
| 233 | + |
| 234 | + - name: Transaction (Run) |
| 235 | + uses: actions-rs/cargo@v1 |
| 236 | + env: |
| 237 | + DATABASE_URL: postgres://postgres:password@localhost:5432/txn |
| 238 | + with: |
| 239 | + command: run |
| 240 | + args: -p sqlx-example-postgres-transaction |
| 241 | + |
| 242 | + sqlite: |
| 243 | + name: SQLite Examples |
| 244 | + runs-on: ubuntu-latest |
| 245 | + needs: sqlx-cli |
| 246 | + |
| 247 | + steps: |
| 248 | + - name: Get SQLx-CLI |
| 249 | + uses: actions/download-artifact@v3 |
| 250 | + with: |
| 251 | + name: sqlx-cli |
| 252 | + path: /home/runner/.local/bin |
| 253 | + |
| 254 | + - run: | |
| 255 | + ls -R /home/runner/.local/bin |
| 256 | + chmod +x /home/runner/.local/bin/sqlx |
| 257 | + echo /home/runner/.local/bin >> $GITHUB_PATH |
| 258 | +
|
| 259 | + - uses: actions/checkout@v2 |
| 260 | + |
| 261 | + - uses: actions-rs/toolchain@v1 |
| 262 | + with: |
| 263 | + profile: minimal |
| 264 | + toolchain: stable |
| 265 | + override: true |
| 266 | + |
| 267 | + - uses: Swatinem/rust-cache@v1 |
| 268 | + with: |
| 269 | + key: sqlite-examples |
| 270 | + |
| 271 | + - name: TODOs (Setup) |
| 272 | + env: |
| 273 | + DATABASE_URL: sqlite://todos.sqlite |
| 274 | + run: sqlx db setup --source=examples/sqlite/todos/migrations |
| 275 | + |
| 276 | + - name: TODOs (Run) |
| 277 | + uses: actions-rs/cargo@v1 |
| 278 | + env: |
| 279 | + DATABASE_URL: sqlite://todos.sqlite |
| 280 | + with: |
| 281 | + command: run |
| 282 | + args: -p sqlx-example-sqlite-todos |
0 commit comments