Skip to content

Update README.md

Update README.md #13

Workflow file for this run

# 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
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
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