|
1 | | -name: build |
| 1 | +name: CI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - master |
7 | 7 | pull_request: |
8 | 8 |
|
| 9 | +env: |
| 10 | + # Database to connect to that can create other databases with `CREATE DATABASE`. |
| 11 | + ADMIN_DATABASE_URL: postgres://postgres:postgres@localhost:5432 |
| 12 | + |
| 13 | + # A suitable name/URL for non-test database. |
| 14 | + DATABASE_NAME: river_dev |
| 15 | + DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/river_dev |
| 16 | + |
| 17 | + # Test database. |
| 18 | + TEST_DATABASE_NAME: river_test |
| 19 | + TEST_DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/river_test |
| 20 | + |
9 | 21 | jobs: |
10 | | - build: |
| 22 | + build_and_test: |
11 | 23 | runs-on: ubuntu-latest |
12 | 24 |
|
| 25 | + services: |
| 26 | + postgres: |
| 27 | + image: postgres:latest |
| 28 | + env: |
| 29 | + POSTGRES_PASSWORD: postgres |
| 30 | + options: >- |
| 31 | + --health-cmd pg_isready |
| 32 | + --health-interval 2s |
| 33 | + --health-timeout 5s |
| 34 | + --health-retries 5 |
| 35 | + ports: |
| 36 | + - 5432:5432 |
| 37 | + |
13 | 38 | steps: |
14 | 39 | - name: Checkout |
15 | 40 | uses: actions/checkout@v4 |
16 | 41 |
|
17 | | - - name: Install the latest version of rye |
| 42 | + - name: Install Rye |
18 | 43 | uses: eifinger/setup-rye@v3 |
19 | 44 |
|
20 | | - - name: Rye setup |
| 45 | + # Needed for River's CLI. There is a version of Go on Actions' base image, |
| 46 | + # but it's old and can't read modern `go.mod` annotations correctly. |
| 47 | + - name: Install Go |
| 48 | + uses: actions/setup-go@v5 |
| 49 | + with: |
| 50 | + go-version: "stable" |
| 51 | + check-latest: true |
| 52 | + |
| 53 | + - name: Rye sync |
21 | 54 | run: rye sync |
22 | 55 |
|
23 | 56 | - name: Format check |
|
32 | 65 | - name: Build |
33 | 66 | run: rye build |
34 | 67 |
|
| 68 | + - name: Install River CLI |
| 69 | + run: go install github.com/riverqueue/river/cmd/river@latest |
| 70 | + |
| 71 | + - name: Create database |
| 72 | + run: psql --echo-errors --quiet -c '\timing off' -c "CREATE DATABASE ${TEST_DATABASE_NAME};" ${ADMIN_DATABASE_URL} |
| 73 | + |
| 74 | + - name: river migrate-up |
| 75 | + run: river migrate-up --database-url "$TEST_DATABASE_URL" |
| 76 | + |
35 | 77 | - name: Test |
36 | | - run: RIVER_USE_DOCKER=true rye test |
| 78 | + run: rye test |
| 79 | + |
| 80 | + examples_run: |
| 81 | + runs-on: ubuntu-latest |
| 82 | + |
| 83 | + services: |
| 84 | + postgres: |
| 85 | + image: postgres:latest |
| 86 | + env: |
| 87 | + POSTGRES_PASSWORD: postgres |
| 88 | + options: >- |
| 89 | + --health-cmd pg_isready |
| 90 | + --health-interval 2s |
| 91 | + --health-timeout 5s |
| 92 | + --health-retries 5 |
| 93 | + ports: |
| 94 | + - 5432:5432 |
| 95 | + |
| 96 | + steps: |
| 97 | + - name: Checkout |
| 98 | + uses: actions/checkout@v4 |
| 99 | + |
| 100 | + - name: Install Rye |
| 101 | + uses: eifinger/setup-rye@v3 |
| 102 | + |
| 103 | + # Needed for River's CLI. There is a version of Go on Actions' base image, |
| 104 | + # but it's old and can't read modern `go.mod` annotations correctly. |
| 105 | + - name: Install Go |
| 106 | + uses: actions/setup-go@v5 |
| 107 | + with: |
| 108 | + go-version: "stable" |
| 109 | + check-latest: true |
| 110 | + |
| 111 | + - name: Rye sync |
| 112 | + run: rye sync |
| 113 | + |
| 114 | + - name: Install River CLI |
| 115 | + run: go install github.com/riverqueue/river/cmd/river@latest |
| 116 | + |
| 117 | + - name: Create database |
| 118 | + run: psql --echo-errors --quiet -c '\timing off' -c "CREATE DATABASE ${DATABASE_NAME};" ${ADMIN_DATABASE_URL} |
| 119 | + |
| 120 | + - name: river migrate-up |
| 121 | + run: river migrate-up --database-url "$DATABASE_URL" |
| 122 | + |
| 123 | + - name: Run examples |
| 124 | + run: rye run python3 -m examples.all |
0 commit comments