|
10 | 10 | CARGO_TERM_COLOR: always |
11 | 11 |
|
12 | 12 | jobs: |
13 | | - prepare-sqlx-cache: |
14 | | - name: Prepare sqlx offline cache |
15 | | - runs-on: ubuntu-latest |
16 | | - env: |
17 | | - SQLX_OFFLINE: false |
18 | | - services: |
19 | | - postgres: |
20 | | - image: postgres:16 |
21 | | - env: |
22 | | - POSTGRES_USER: postgres |
23 | | - POSTGRES_PASSWORD: postgres |
24 | | - POSTGRES_DB: stacker |
25 | | - ports: |
26 | | - - 5432:5432 |
27 | | - options: >- |
28 | | - --health-cmd "pg_isready -U postgres" |
29 | | - --health-interval 10s |
30 | | - --health-timeout 5s |
31 | | - --health-retries 5 |
32 | | - steps: |
33 | | - - uses: actions/checkout@v4 |
34 | | - - name: Install Rust toolchain |
35 | | - uses: actions-rs/toolchain@v1 |
36 | | - with: |
37 | | - toolchain: stable |
38 | | - profile: minimal |
39 | | - override: true |
40 | | - - name: Install sqlx-cli |
41 | | - run: cargo install sqlx-cli --no-default-features --features postgres,rustls |
42 | | - - name: Set DATABASE_URL |
43 | | - run: echo "DATABASE_URL=postgres://postgres:postgres@localhost:5432/stacker" >> $GITHUB_ENV |
44 | | - - name: Wait for Postgres |
45 | | - run: | |
46 | | - for i in {1..10}; do |
47 | | - pg_isready -h localhost -U postgres && break |
48 | | - sleep 3 |
49 | | - done |
50 | | - - name: Create database (idempotent) |
51 | | - run: sqlx database create || true |
52 | | - - name: Run migrations |
53 | | - run: sqlx migrate run |
54 | | - - name: Check project compiles first |
55 | | - run: cargo check --all-targets |
56 | | - - name: Generate sqlx offline cache (sqlx 0.6) |
57 | | - run: cargo sqlx prepare |
58 | | - - name: Verify .sqlx/ cache was generated |
59 | | - run: | |
60 | | - if [ ! -d ".sqlx" ]; then |
61 | | - echo "ERROR: .sqlx directory was not created" |
62 | | - exit 1 |
63 | | - fi |
64 | | - echo ".sqlx directory contents:" |
65 | | - ls -lh .sqlx/ || echo "Directory empty or inaccessible" |
66 | | - echo "Query cache files:" |
67 | | - find .sqlx -type f | head -20 |
68 | | - - name: Upload .sqlx cache |
69 | | - uses: actions/upload-artifact@v4 |
70 | | - with: |
71 | | - name: sqlx-cache |
72 | | - path: .sqlx |
73 | | - if-no-files-found: error |
74 | | - |
75 | 13 | build: |
76 | 14 | name: Build binaries (Linux/macOS) |
77 | | - needs: prepare-sqlx-cache |
78 | 15 | env: |
79 | 16 | SQLX_OFFLINE: true |
80 | 17 | strategy: |
|
92 | 29 | runs-on: ${{ matrix.os }} |
93 | 30 | steps: |
94 | 31 | - uses: actions/checkout@v4 |
95 | | - - name: Download sqlx cache |
96 | | - uses: actions/download-artifact@v4 |
97 | | - with: |
98 | | - name: sqlx-cache |
99 | | - path: . |
100 | 32 | - name: Verify .sqlx/ cache exists |
101 | 33 | run: | |
102 | 34 | ls -lh .sqlx/ || echo ".sqlx directory not found" |
|
0 commit comments