-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (55 loc) · 2.13 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: ci-test
# event that triggers teh workflow
on:
# run test when changes are pushed to master branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
# Copied, search github actions postgres, it sets the postgres db
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:alpine
# Provide the password for postgres
env:
POSTGRES_USER: root
POSTGRES_DB: chat-db
POSTGRES_PASSWORD: mysecretpassword
# Set health checks to wait until postgres has started
# health check options tell teh runner how to check if postgres has started successfully or not
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
# provides input parameters to the action
with:
go-version: '1.21.3'
# not necessary deleted in the video, because app will be built automatically when we run go test
# - name: Build
# run: go build -v ./...
# Installing migrate, to run the migrate commands
- name: Install golang-migrate
# first we install pre-built binary, then, mv it to usr/bin, so that it can be used by go, then, test whether it installed successfully or not using which migrate
# Note - we use usr/bin/migrate, so the binary file moved to usr/bin will have a new name - migrate, which is used in our commands
run: |
curl -L https://github.com/golang-migrate/migrate/releases/download/v4.16.2/migrate.linux-amd64.tar.gz | tar xvz
sudo mv migrate /usr/bin/
which migrate
# Creates the db schema in the postgres db that was setup
- name: Run migrations
run: make migrate-up
- name: Test
# test command in Makefile
run: make test