Skip to content

Commit 5620728

Browse files
bgentrybrandur
andcommittedNov 8, 2023
initial import
Co-authored-by: Brandur Leach <brandur@brandur.org>
0 parents  commit 5620728

File tree

139 files changed

+22353
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+22353
-0
lines changed
 

‎.github/dependabot.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "gomod"
9+
directory: "/" # Location of package manifests
10+
groups:
11+
go-dependencies:
12+
update-types:
13+
- "minor"
14+
- "patch"
15+
schedule:
16+
interval: "weekly"

‎.github/workflows/ci.yml

+212
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
name: CI
2+
3+
env:
4+
# Database to connect to that can create other databases with `CREATE DATABASE`.
5+
ADMIN_DATABASE_URL: postgres://postgres:postgres@localhost:5432
6+
7+
# Just a common place for steps to put binaries they need and which is added
8+
# to GITHUB_PATH/PATH.
9+
BIN_PATH: /home/runner/bin
10+
11+
# A suitable URL for non-test database.
12+
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/river_dev?sslmode=disable
13+
14+
on:
15+
- push
16+
17+
jobs:
18+
build_and_test:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
go-version:
23+
- "1.21"
24+
timeout-minutes: 5
25+
26+
services:
27+
postgres:
28+
image: postgres
29+
env:
30+
POSTGRES_PASSWORD: postgres
31+
options: >-
32+
--health-cmd pg_isready
33+
--health-interval 2s
34+
--health-timeout 5s
35+
--health-retries 5
36+
ports:
37+
- 5432:5432
38+
39+
steps:
40+
- uses: actions/checkout@v3
41+
42+
- name: Setup Go ${{ matrix.go-version }}
43+
uses: actions/setup-go@v4
44+
with:
45+
go-version: ${{ matrix.go-version }}
46+
47+
- name: Display Go version
48+
run: go version
49+
50+
- name: Install dependencies
51+
run: |
52+
echo "::group::go get"
53+
go get -t ./...
54+
echo "::endgroup::"
55+
56+
- name: Set up test DBs
57+
run: go run ./internal/cmd/testdbman create
58+
env:
59+
PGHOST: 127.0.0.1
60+
PGPORT: 5432
61+
PGUSER: postgres
62+
PGPASSWORD: postgres
63+
PGSSLMODE: disable
64+
65+
- name: Test
66+
run: go test -p 1 -race ./...
67+
env:
68+
TEST_DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/river_testdb?sslmode=disable
69+
70+
cli:
71+
runs-on: ubuntu-latest
72+
timeout-minutes: 3
73+
74+
services:
75+
postgres:
76+
image: postgres
77+
env:
78+
POSTGRES_PASSWORD: postgres
79+
options: >-
80+
--health-cmd pg_isready
81+
--health-interval 2s
82+
--health-timeout 5s
83+
--health-retries 5
84+
ports:
85+
- 5432:5432
86+
87+
steps:
88+
- uses: actions/setup-go@v4
89+
with:
90+
go-version: "stable"
91+
check-latest: true
92+
93+
- name: Checkout
94+
uses: actions/checkout@v3
95+
96+
- name: Build CLI
97+
run: go build ./cmd/river
98+
99+
- name: Create database
100+
run: psql --echo-errors --quiet -c '\timing off' -c "CREATE DATABASE river_dev;" ${ADMIN_DATABASE_URL}
101+
102+
- name: river migrate-up
103+
run: ./river migrate-up --database-url $DATABASE_URL
104+
105+
- name: river migrate-down
106+
run: ./river migrate-down --database-url $DATABASE_URL --max-steps 100
107+
108+
golangci:
109+
name: lint
110+
runs-on: ubuntu-latest
111+
permissions:
112+
contents: read
113+
# allow read access to pull request. Use with `only-new-issues` option.
114+
pull-requests: read
115+
steps:
116+
- uses: actions/setup-go@v4
117+
with:
118+
go-version: "stable"
119+
check-latest: true
120+
121+
- name: Checkout
122+
uses: actions/checkout@v3
123+
124+
- name: golangci-lint
125+
uses: golangci/golangci-lint-action@v3
126+
with:
127+
# Optional: show only new issues if it's a pull request. The default value is `false`.
128+
only-new-issues: true
129+
130+
version: v1.54.2
131+
132+
producer_sample:
133+
runs-on: ubuntu-latest
134+
timeout-minutes: 2
135+
136+
services:
137+
postgres:
138+
image: postgres
139+
env:
140+
POSTGRES_PASSWORD: postgres
141+
options: >-
142+
--health-cmd pg_isready
143+
--health-interval 2s
144+
--health-timeout 5s
145+
--health-retries 5
146+
ports:
147+
- 5432:5432
148+
149+
steps:
150+
- uses: actions/checkout@v3
151+
152+
- name: Setup Go ${{ matrix.go-version }}
153+
uses: actions/setup-go@v4
154+
with:
155+
go-version: "stable"
156+
check-latest: true
157+
158+
- name: Display Go version
159+
run: go version
160+
161+
- name: Install dependencies
162+
run: |
163+
echo "::group::go get"
164+
go get -t ./...
165+
echo "::endgroup::"
166+
167+
- name: Build CLI
168+
run: go build ./cmd/river
169+
170+
- name: Create database
171+
run: psql --echo-errors --quiet -c '\timing off' -c "CREATE DATABASE river_dev;" ${ADMIN_DATABASE_URL}
172+
173+
- name: river migrate-up
174+
run: ./river migrate-up --database-url $DATABASE_URL
175+
176+
- name: Build producersample
177+
run: go build ./internal/cmd/producersample
178+
179+
- name: Run producersample
180+
run: |
181+
( sleep 5 && killall -SIGTERM producersample ) &
182+
./producersample
183+
184+
sqlc_generates:
185+
runs-on: ubuntu-latest
186+
timeout-minutes: 2
187+
188+
env:
189+
SQLC_VERSION: 1.22.0
190+
191+
steps:
192+
- name: Create BIN_PATH and add to PATH
193+
run: |
194+
mkdir -p "$BIN_PATH"
195+
echo "$BIN_PATH" >> $GITHUB_PATH
196+
197+
- name: Install sqlc
198+
run: |
199+
curl -L https://github.com/kyleconroy/sqlc/releases/download/v${{ env.SQLC_VERSION }}/sqlc_${{ env.SQLC_VERSION }}_linux_amd64.tar.gz | tar -xz -C $BIN_PATH
200+
chmod +x $BIN_PATH/sqlc
201+
202+
- name: Checkout
203+
uses: actions/checkout@v3
204+
205+
- name: Run sqlc
206+
run: make generate
207+
208+
- name: Check git diff
209+
working-directory: ./internal/dbsqlc
210+
run: |
211+
echo "Please make sure that all sqlc changes are checked in!"
212+
git diff --exit-code .

0 commit comments

Comments
 (0)
Please sign in to comment.