Skip to content

Commit 96c82d3

Browse files
Adding initial GHA (#1)
1 parent a021b57 commit 96c82d3

File tree

5 files changed

+59
-3
lines changed

5 files changed

+59
-3
lines changed

.github/workflows/pull.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: Pull Request
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
jobs:
13+
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Install Golang
18+
uses: actions/setup-go@v3
19+
with:
20+
go-version: '1.20'
21+
22+
- uses: actions/checkout@v3
23+
24+
- name: Start database and migrate
25+
run: |
26+
docker-compose up -d db
27+
docker-compose up migrate
28+
29+
- name: Run tests
30+
run: |
31+
go get -v ./...
32+
go test -test.v ./...

Taskfile.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ tasks:
3838
--to "file://database/schema.hcl" \
3939
--dev-url "docker://postgres/15"
4040
41+
db.update:
42+
cmds:
43+
- |
44+
atlas schema apply \
45+
--auto-approve \
46+
--url "$DATABASE_URL" \
47+
--to "file://database/schema.hcl" \
48+
--dev-url "docker://postgres/15"
49+
4150
db.up:
4251
cmds:
4352
- docker-compose up -d db
@@ -53,4 +62,5 @@ tasks:
5362
test:
5463
cmds:
5564
- (rm /tmp/unit_coverage.out || echo "Deleted Old files")
65+
- go mod vendor
5666
- go test -test.v ./...

docker-compose.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ services:
1616
timeout: 5s
1717
retries: 5
1818

19+
migrate:
20+
container_name: gomin_migrate
21+
depends_on:
22+
- db
23+
image: arigaio/atlas:latest
24+
volumes:
25+
- "./database:/tmp/database"
26+
command: >
27+
schema apply \
28+
--auto-approve \
29+
--url "postgres://test:test@gomin_db:5432/gomin?sslmode=disable" \
30+
--to "file://tmp/database/schema.hcl" \
31+
--dev-url "postgres://test:test@gomin_db:5432/gomin?sslmode=disable"
32+
1933
api:
2034
build:
2135
context: .

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/georgysavva/scany/v2 v2.0.0
77
github.com/google/uuid v1.3.0
88
github.com/jackc/pgx-gofrs-uuid v0.0.0-20230224015001-1d428863c2e2
9-
github.com/jackc/pgx/v5 v5.3.0
9+
github.com/jackc/pgx/v5 v5.3.1
1010
github.com/labstack/echo/v4 v4.10.1
1111
github.com/rs/zerolog v1.29.0
1212
github.com/spf13/viper v1.15.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/
140140
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
141141
github.com/jackc/pgx-gofrs-uuid v0.0.0-20230224015001-1d428863c2e2 h1:QWdhlQz98hUe1xmjADOl2mr8ERLrOqj0KWLdkrnNsRQ=
142142
github.com/jackc/pgx-gofrs-uuid v0.0.0-20230224015001-1d428863c2e2/go.mod h1:Ti7pyNDU/UpXKmBTeFgxTvzYDM9xHLiYKMsLdt4b9cg=
143-
github.com/jackc/pgx/v5 v5.3.0 h1:/NQi8KHMpKWHInxXesC8yD4DhkXPrVhmnwYkjp9AmBA=
144-
github.com/jackc/pgx/v5 v5.3.0/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8=
143+
github.com/jackc/pgx/v5 v5.3.1 h1:Fcr8QJ1ZeLi5zsPZqQeUZhNhxfkkKBOgJuYkJHoBOtU=
144+
github.com/jackc/pgx/v5 v5.3.1/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8=
145145
github.com/jackc/puddle/v2 v2.2.0 h1:RdcDk92EJBuBS55nQMMYFXTxwstHug4jkhT5pq8VxPk=
146146
github.com/jackc/puddle/v2 v2.2.0/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
147147
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=

0 commit comments

Comments
 (0)