Skip to content

Adam make post page #75

Adam make post page

Adam make post page #75

Workflow file for this run

name: Backend
on:
push:
paths:
- backend/**
- .github/workflows/backend.yml
branches: ['main']
pull_request:
paths:
- backend/**
- .github/workflows/backend.yml
branches: ['main']
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.21.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go Modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: 'Create env file'
run: |
touch .env
cat .env
- name: Install Linters
run: |
cd backend
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: Lint Go code
run: make backend-lint
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.21.x]
container: node:latest
services:
postgres:
image: postgres:14.1-alpine
env:
POSTGRES_PASSWORD: pwd
POSTGRES_USER: user
POSTGRES_DB: algo
ports:
- 5432:5432
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
--health-retries 5
steps:
- name: Install PostgreSQL client
run: |
apt-get update
apt-get install --yes postgresql-client
- name: Check out repository code
uses: actions/checkout@v4
- name: 'Create env file'
run: |
touch .env
cat .env
- name: Import DB seed data
run: |
for file in $(ls -1 ./ | sort); do
psql -d postgresql://user:[email protected]:5432/algo -f "$file"
done
working-directory: ./backend/src/db/migrations/
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go Modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Dependencies
run: make backend-dep
- name: Run Go tests
run: |
make backend-test
format:
name: Format
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.21.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 'Create env file'
run: |
touch .env
cat .env
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go Modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Format Go Code
run: |
make backend-format
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.21.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 'Create env file'
run: |
touch .env
cat .env
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go Modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build Go app
run: |
cd backend
go build -v